Is there a way that I can stop a .automount
without unmounting the filesystem?
I just want to prevent any future automounting, but I don't want to unmount the currently mounted filesystem.
Why can't I just remount the filesystem you ask?
Well, just as umount --lazy
is dangerous and it's impossible to know when it has completed, it seems that stopping the .automount
unit also uses the same MNT_DETACH
flag.
A demonstration:
$ # Call this shell #1:
$ # I block permissions on the unmounted mountpoint:
$ ls -ld /media/backup/
dr-------- 1 root root 0 Nov 19 14:16 /media/backup/
$ ls /media/backup
ls: cannot open directory '/media/backup': Permission denied
# Enable the automounter:
$ sudo systemctl start media-backup.automount
$ # Now I can see the contents:
$ ls /media/backup
blockchain btrbk syncthing
$ # Pin it down with a working directory:
$ cd /media/backup/
# Stop the automounter:
$ sudo systemctl stop media-backup.automount
$ # Note there is no complaint about a mounted filesytem...
At this point in time, in another shell:
$ # Shell #2
$ ls /media/backup/
ls: cannot open directory '/media/backup/': Permission denied
So, it's unmounted when viewed from shell #2, but still accessible in Shell #1:
$ # Shell #1
$ ls
blockchain btrbk syncthing
How do I stop the .automount
unit without unmounting the currently mounted filesystem?