systemd: autofs containing autofs does not unmount
2
votes
1
answer
2201
views
I'm trying to set up two directories, each automounted:
*
/mnt/dir
* /mnt/dir/subdir
In my case, these are:
* /mnt/btrfs-vol/rootfs
(read only)
* /mnt/btrfs-vol/rootfs/btrbk-snap
(RW for taking snapshots with [btrbk
](https://github.com/digint/btrbk))
My /etc/fstab
contains:
LABEL=rootfs /mnt/btrfs-vol/rootfs btrfs ro,subvol=/,lazytime,compress=lzo,ssd,discard,noauto,x-systemd.automount,x-systemd.idle-timeout=2
LABEL=rootfs /mnt/btrfs-vol/rootfs/btrbk-snap btrfs rw,subvol=/btrbk-snap,lazytime,compress=lzo,ssd,discard,noauto,x-systemd.automount,x-systemd.idle-timeout=2,x-systemd.requires-mounts-for=/mnt/btrfs-vol/rootfs
I do:
svelte ~# systemctl daemon-reload && systemctl restart local-fs.target
svelte ~# mount | grep btrfs-vol/rootfs
systemd-1 on /mnt/btrfs-vol/rootfs type autofs (rw,relatime,fd=32,pgrp=1,timeout=2,minproto=5,maxproto=5,direct)
Strangely, /mnt/btrfs-vol/rootfs
, is already mounted.
If I unmount /mnt/btrfs-vol/rootfs
, it is immediately remounted:
svelte ~# umount /mnt/btrfs-vol/rootfs
svelte ~# mount | grep btrfs-vol/rootfs
systemd-1 on /mnt/btrfs-vol/rootfs type autofs (rw,relatime,fd=32,pgrp=1,timeout=2,minproto=5,maxproto=5,direct)
Now if I ping the subdirectory, it automounts:
svelte ~# (cd /mnt/btrfs-vol/rootfs/btrbk-snap/ && mount | grep btrfs-vol/rootfs)
systemd-1 on /mnt/btrfs-vol/rootfs type autofs (rw,relatime,fd=32,pgrp=1,timeout=2,minproto=5,maxproto=5,direct)
/dev/mapper/vg_svelte-rootfs on /mnt/btrfs-vol/rootfs type btrfs (ro,relatime,lazytime,compress=lzo,ssd,discard,space_cache,subvolid=5,subvol=/)
Note that the fstype
of /dev/mapper/vg_svelte-rootfs
has changed from autofs
to btrfs
.
A few seconds later (I have timeout=2
for testing`):
svelte ~# mount | grep btrfs-vol/rootfssystemd-1 on /mnt/btrfs-vol/rootfs type autofs (rw,relatime,fd=32,pgrp=1,timeout=2,minproto=5,maxproto=5,direct)
The subdirectory is unmounted, and the fstype
of /dev/mapper/vg_svelte-rootfs
reverts to autofs
, *but it stays mounted*.
**How do I get it to automatically unmount?**
Possibly useful information:
journal
output:
Feb 21 17:16:07 svelte systemd: Reloading.
Feb 21 17:16:23 svelte systemd: Mounting /mnt/btrfs-vol/rootfs...
Feb 21 17:16:23 svelte systemd: Set up automount mnt-btrfs\x2dvol-home-btrbk\x2dsnap.automount.
Feb 21 17:16:23 svelte systemd: Mounted /mnt/btrfs-vol/rootfs.
Feb 21 17:16:23 svelte systemd: mnt-btrfs\x2dvol-rootfs-btrbk\x2dsnap.automount: Directory /mnt/btrfs-vol/rootfs/btrbk-snap to mount over is not empty, mounting anyway.
Feb 21 17:16:23 svelte systemd: Set up automount mnt-btrfs\x2dvol-rootfs-btrbk\x2dsnap.automount.
Feb 21 17:16:23 svelte systemd: Reached target Local File Systems.
Feb 21 17:16:25 svelte systemd: Stopped target Local File Systems.
Feb 21 17:16:25 svelte systemd: Unset automount mnt-btrfs\x2dvol-rootfs-btrbk\x2dsnap.automount.
Feb 21 17:16:25 svelte systemd: Unmounting /mnt/btrfs-vol/rootfs...
Feb 21 17:16:25 svelte systemd: Unmounted /mnt/btrfs-vol/rootfs.
Feb 21 17:17:44 svelte systemd: Unset automount mnt-btrfs\x2dvol-home-btrbk\x2dsnap.automount.
Checking that nothing has the directory open:
svelte ~# lsof /mnt/btrfs-vol/rootfs
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
Output information may be incomplete.
svelte ~# ls -l /run/user/1000 | grep gvfs
ls: cannot access '/run/user/1000/gvfs': Permission denied
d????????? ? ? ? ? ? gvfs
I've never seen ?
where I'd expect the rwx
placehoders to be before.
Asked by Tom Hale
(32892 rep)
Feb 21, 2017, 10:04 AM
Last activity: May 30, 2025, 09:06 AM
Last activity: May 30, 2025, 09:06 AM