Using Linux now for a long time I am still not really familiar with systemd and have a question on its usage. Maybe this is the wrong place to ask it. In this case please point me to an appropiate forum.
I am using systemd automount units (see below) to mount network shares on my laptop (debian bullseye). This works fine in principle but I have one big issue: At home it is enough to set TimeoutSec to 2 s in the mount unit. Normally the server is available and the share is mounted. If the server is down I need to wait for just 2 s until I see it is not there. Thats ok. But when not at home and using a vpn, the mount unit will not mount with TimeoutSec set to 2 s. I need to set it to at least 10 s. Then the mount works. But using 10 s means I always have to wait 10 s for each share the system tries to reach and is not available. This is really annoying when starting libreoffice for example (which seems to check for the last used documents on startup). What I would like to do is to put a test for server availabilty (e.g. ping -c 1 $SERVER) into the automount file. When the server is not available, automount is not run. Is this possible? Or do I need to create a special unit and put something like Requires=nfs-server-online.target in my automount unit? And how would the nfs-server-online unit look like? What I am doing at the moment is running a script that checks availability of the nfs server every some seconds (via ping) and turns on/off the automount unit accordingly (via systemctl start/stop mnt-share.automount). This works, but its not a very elegant solution. I am pretty sure it can be done better using systemd only. Regards, Jürgen /etc/systemd/system/mnt-share.automount: [Unit] Description=autoount share [Automount] Where=/mnt/share TimeoutIdleSec=1min [Install] WantedBy=multi-user.target /etc/systemd/system/mnt-share.mount: [Unit] Description=Mount share [Mount] Where=/mnt/share What=lana:/share Type=nfs Options=soft,async TimeoutSec=10 [Install] WantedBy=multi-user.target