Systemd automount ignores timeouts on disconnected devices: processes hang forever

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
twolf

Systemd automount ignores timeouts on disconnected devices: processes hang forever

Post by twolf »

I'm trying to manage an external usb disk (which I use as destination for automatic backups in a multi-user installation) by systemd automount feature. This is how I coded its line in /etc/fstab:

Code: Select all

/dev/disk/by-uuid/68d4697d-5748-40a6-a68b-b66f9ecc0e4c /media/BACKUP auto noauto,x-systemd.automount,x-systemd.device-timeout=5,x-systemd.idle-timeout=300,nosuid,nodev,nofail,x-gvfs-show,users 0 0
Almost everything works as desired: the device, connected or not, is never considered to be mounted at boot. If connected, it's rightly mounted if any operation references the content of mount point and rightly unmounted after not being referenced since 5 minutes (thanks to option x-systemd.idle-timeout).
Very cool, but.... if the device is not connected every operation referencing the mount point (even just an ls or a bash tab completion about it) hangs FOREVER and does not recover even if the device is connected afterwards. x-systemd.device-timeout options seems not to be honored by the kernel.
You can easily reproduce this issue.
Here follows the additional information I can give, syslog when an ls hangs:

Code: Select all

Jun 21 12:17:17 roberto-VirtualBox systemd[1]: media-BACKUP.automount: Got automount request for /media/BACKUP, triggered by 2324 (ls)
Jun 21 12:17:18 roberto-VirtualBox systemd[1]: dev-disk-by\x2duuid-68d4697d\x2d5748\x2d40a6\x2da68b\x2db66f9ecc0e4c.device: Job dev-disk-by\x2duuid-68d4697d\x2d5748\x2d40a6\x2da68b\x2db66f9ecc0e4c.device/start timed out.
Jun 21 12:17:18 roberto-VirtualBox systemd[1]: Timed out waiting for device dev-disk-by\x2duuid-68d4697d\x2d5748\x2d40a6\x2da68b\x2db66f9ecc0e4c.device.
Jun 21 12:17:18 roberto-VirtualBox systemd[1]: Dependency failed for /media/BACKUP.
Jun 21 12:17:18 roberto-VirtualBox systemd[1]: media-BACKUP.mount: Job media-BACKUP.mount/start failed with result 'dependency'.
Jun 21 12:17:18 roberto-VirtualBox systemd[1]: dev-disk-by\x2duuid-68d4697d\x2d5748\x2d40a6\x2da68b\x2db66f9ecc0e4c.device: Job dev-disk-by\x2duuid-68d4697d\x2d5748\x2d40a6\x2da68b\x2db66f9ecc0e4c.device/start failed with result 'timeout'.
and the dead state of the mount unit:

Code: Select all

roberto-VirtualBox etc # systemctl list-units --type=mount --all
  UNIT                          LOAD      ACTIVE   SUB     DESCRIPTION
  -.mount                       loaded    active   mounted /
  dev-hugepages.mount           loaded    active   mounted Huge Pages File System
  dev-mqueue.mount              loaded    active   mounted POSIX Message Queue File System
  home.mount                    loaded    active   mounted /home
  [b]media-BACKUP.mount            loaded    inactive dead    /media/BACKUP[/b]
  media-sf_Bidone.mount         loaded    active   mounted /media/sf_Bidone
  proc-sys-fs-binfmt_misc.mount loaded    active   mounted Arbitrary Executable File Formats File System
  run-cgmanager-fs.mount        loaded    active   mounted /run/cgmanager/fs
  run-user-1000-gvfs.mount      loaded    active   mounted /run/user/1000/gvfs
  run-user-1000.mount           loaded    active   mounted /run/user/1000
  sys-fs-fuse-connections.mount loaded    active   mounted FUSE Control File System
  sys-kernel-config.mount       loaded    inactive dead    Configuration File System
  sys-kernel-debug.mount        loaded    active   mounted Debug File System
●[b] tmp.mount                     not-found inactive dead    tmp.mount[/b]

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
Here follows other people remarking the issue but not giving a solution (at least understandable to me):

https://github.com/systemd/systemd/issues/2181

https://bbs.archlinux.org/viewtopic.php?id=186030

I'm using Mint 18.1 Xfce with no levels 4/5 updates (kernel is 4.4.0-53-generic, systemd is 229-4ubuntu12, mount is 2.27.1-6ubuntu3.2), but even applying those updates (including kernel 4.4.0-81-generic and systemd 229-4ubuntu17) does not fix.

Any help would be welcome.
A workaround could be making systemd deleting the mount point when it's unmounted (as well as it is created if not exixsting during mount), but I can't figure out how it could be possible.

Thanks and Bye
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Locked

Return to “Other topics”