On Sun, 2021-03-14 at 07:37 +0800, Ed Greshko wrote:
Your dock.service, if run, would power-up and then immediately power-down the dock.
Indeed. Does that mean I need separate dock-up and dock-down services?
I suppose. But, I can't say that there is a way to start a service went the auto-unmount occurs.
That is starting to look like the show-stopper. The only way round it may be a separate monitoring process outside of systemd.
Anyway, taking one thing at a time, I have the dock permanently on while I try to get the automounting to work:
Also, the .service is not being invoked by the .mount (I shouldn't have to start it manually), presumably because the .automount isn't running.
I modified my aux.mount unit to be
[Unit] Description=nfs mount aux Wants=dock.service
[Mount] What=[2001:b030:112f::19]:/volume1/aux Where=/aux Options=rw,noauto,soft,fg,x-systemd.mount-timeout=30 Type=nfs4
[Install] WantedBy=multi-user.target
My raid.mount now looks like this (the previous version was missing the 'What' and 'Options' lines):
# cat raid.mount [Unit] Description=External /raid mount
Wants=dock.service
[Mount] What=/dev/md0p1 Where=/raid Options=rw,noauto,soft,fg,x-systemd.mount-timeout=30 Type=ext4
[Install] WantedBy=multi-user.target
Everything else is the same. Recall that the .automount file is:
# cat raid.automount [Unit] Description=Automount /raid [Automount] Where=/raid TimeoutIdleSec=300
[Install] WantedBy=multi-user.target
and dock.service is:
# cat dock.service [Unit] Description=Power the dock up After=multi-user.target DefaultDependencies=no
[Service] #Type=oneshot ExecStart=/usr/local/bin/dock up
I commented out the 'Type=oneshot' line as this is the default. I could add 'RemainAfterExit=on' in order to keep the state as 'running but I don't see that this makes any material difference here.
It then rebooted and.....
[egreshko@f33k ~]$ ll /var/tmp/auto/ total 0 -rw-r--r--. 1 root root 0 Mar 14 07:26 start -rw-r--r--. 1 root root 0 Mar 14 07:26 stop
I rebooted and got:
# findmnt /raid # ls /raid # findmnt /raid #
IOW nothing happens.
poc