As I have found a way to run a command to mount an sftp folder when the qube/vm starts (described here), now I need to run a different command to umount the sftp folder when the qube/vm is going to shutdown.
Is there an opposite to rc.local
that will run a command before the qube/vm starts to shutdown if the user selects shutdown the respective qube/vm?
You need to use systemd, and something like Before=shutdown.target
It can sometimes be difficult to find the right target that allows you to unmount before the network is offline, if you do it too late the network share might stall waiting for a network timeout.
Is that not working automatically for you? Shutting down a VM sends a SIGTERM signal to the sshfs
process, which should normally cause it to unmount.
Edit: Ah okay, since you’re running sshfs
from rc.local
I guess it’s possible that it would receive the SIGTERM signal after the network has already been stopped.
Edit 2:
1 Like