You are not logged in.
I have remote disk connected to network and I have created systemd mount file (/etc/systemd/system/run-media-yesnt-diskz.mount) with the following content:
[Unit]
Description=Disk Z
Requires=systemd-networkd.service
After=network-online.target
Wants=network-online.target
[Mount]
What=\\192.168.8.2\wspolne
Where=/run/media/yesnt/diskz
Options=vers=2.1,credentials=/etc/samba/disk_z.cred,iocharset=utf8,rw,x-systemd.automount
Type=cifs
TimeoutSec=30
[Install]
WantedBy=multi-user.target
The problem is if I am not connected on the same network, or disk is currently unavailable systemd will wait from 5 to 30 seconds when starting up (it's kinda random) and 1.5 minute when shuting down.
My questing is, would it be possible to run mount for this unit asynchronously, so it wouldn't block rest of the system, and if it is possible to ignore unmounting without blocking shutdown?
Last edited by someReallyRandomName (2022-10-17 11:42:54)
Offline
Maybe create a new systemd target for when you're on that network and add it to that target. At minimum it would let you more easily start and stop related services.
Whether it's possible to have it automatically load that target when you're on that network, I'm not sure, but it should be! Sorry I don't have all the details but just a thought. A google search isn't immediately showing a way to do that, but it seems like something that obviously should be doable. With systemd adding features for every situation but the kitchen sink, this seems like an obvious addition.
Offline
So, I found something called "remote-fs.target" while running "systemctl list-units --type=target" but I couldn't find too much documentation.
I myself couldn't find a way to trigger it only when I am connected to that specific network.
Also I couldn't find a way to just kinda 'ignore' it when it isn't connected/mounted.
Offline
x-systemd.automount can indeed be helpful here, but it is an option for fstab. If you want to write the unit files yourself, you have to create an automount unit in addition to the mount unit and only enable the former (like with timer+service units).
Offline
Sorry, but I am not an expert at systemd and I have no idea what you have just explained to me.
I would appreciate if you could like show me some example?
Offline
try adding "nofail" to the options
Offline
nofail is also an option for fstab... One can read about its effects in the man page and implement that in the unit files, but that seems to be too much:
Sorry, but I am not an expert at systemd and I have no idea what you have just explained to me.
I would appreciate if you could like show me some example?
Then why create mount units yourself? Use fstab as recommended and let systemd generate the units.
Last edited by Raynman (2022-10-17 09:50:39)
Offline
Thanks jonno2002.
It worked.
Then why create mount units yourself? Use fstab as recommended and let systemd generate the units.
Well, it was the first method that I found working so this is what I am using.
But, I will look into fstab as you proposed.
Offline