You are not logged in.

#1 2021-05-06 02:50:28

hsantanna
Member
Registered: 2017-02-13
Posts: 7

x-systemd.automount with x-systemd.idle-timeout=60 won't umount

I want to have a partition auto-mounted when accessed and unmounted when idle.

I had setup /etc/fstab with

UUID=123e4567-e89b-12d3-a456-426655440000   /mnt/hdd     ext4   rw,noatime,lazytime,noauto,x-systemd.automount,x-systemd.idle-timeout=60   0 2

When I do:

$ ls /mnt/hdd

The partition will be correctly auto-mounted and it will result with the correct listing.

The problem is that it will never automatically get unmounted, besides what is expected by the x-systemd.idle-timeout=60 parameter.


Here is the content of /run/systemd/generator/mnt-hdd.automount:

# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)

[Automount]
Where=/mnt/hdd
TimeoutIdleSec=60

$ systemctl status mnt-hdd.automount

● mnt-hdd.automount
     Loaded: loaded (/etc/fstab; generated)
     Active: active (running) since Tue 2021-05-04 16:34:48 -03; 1 day 7h ago
   Triggers: ● mnt-hdd.mount
      Where: /mnt/hdd
       Docs: man:fstab(5)
             man:systemd-fstab-generator(8)

mai 04 16:34:48 anarch systemd[1]: Set up automount mnt-hdd.automount.
mai 04 16:44:00 anarch systemd[1]: mnt-hdd.automount: Got automount request for /mnt/hdd, triggered by 4309 (ls)

$ systemctl status mnt-hdd.mount

● mnt-hdd.mount - /mnt/hdd
     Loaded: loaded (/etc/fstab; generated)
     Active: active (mounted) since Tue 2021-05-04 16:44:00 -03; 1 day 6h ago
TriggeredBy: ● mnt-hdd.automount
      Where: /mnt/hdd
       What: /dev/sda4
       Docs: man:fstab(5)
             man:systemd-fstab-generator(8)
      Tasks: 0 (limit: 18951)
     Memory: 312.0K
        CPU: 6ms
     CGroup: /system.slice/mnt-hdd.mount

mai 04 16:44:00 anarch systemd[1]: Mounting /mnt/hdd...
mai 04 16:44:00 anarch systemd[1]: Mounted /mnt/hdd.

Offline

#2 2021-05-06 08:02:20

seth
Member
Registered: 2012-09-03
Posts: 64,524

Re: x-systemd.automount with x-systemd.idle-timeout=60 won't umount

Are you sure nothing keeps the mount busy?
Use lsof for a static check (is something open there right now) and inotifywatch to monitor access (could be a problem if there're MAAAAAANY files on that disk)

Offline

#3 2021-05-07 20:38:48

hsantanna
Member
Registered: 2017-02-13
Posts: 7

Re: x-systemd.automount with x-systemd.idle-timeout=60 won't umount

lsof will return nothing, tryed with

lsof +D /mnt/hdd

This is an 1.1 TiB ext4 local partition, containing an old Arch install and home subdirectories with MAAAAAANY user files.

Since the automount was trigged just by a

ls /mnt/hdd

I'm not expecting that are any files or directories being accessed, which lsof seems to confirm.

Offline

#4 2021-05-07 21:01:42

seth
Member
Registered: 2012-09-03
Posts: 64,524

Re: x-systemd.automount with x-systemd.idle-timeout=60 won't umount

Some file indexers might be prone to access the disk.
If you send it to sleep or standby w/ eg. "hdparm -Y" and leave it alone, is it still there 60s later ("hdparm -C")?

Offline

#5 2021-05-08 00:04:00

hsantanna
Member
Registered: 2017-02-13
Posts: 7

Re: x-systemd.automount with x-systemd.idle-timeout=60 won't umount

Tested with hdparm and yes, the HD will be on standby for the 60s (and much more, as far as I could see).

Even so, the partition was not automatically unmounted and lsblk returns

├─sda4        8:4    0   1,1T  0 part  /mnt/hdd

Last edited by hsantanna (2021-05-08 03:06:30)

Offline

#6 2021-05-08 06:18:12

seth
Member
Registered: 2012-09-03
Posts: 64,524

Re: x-systemd.automount with x-systemd.idle-timeout=60 won't umount

ftr, https://github.com/systemd/systemd/issues/3332

Sanity check: can you "sudo umount /mnt/hdd" w/o error?

Offline

#7 2021-05-12 16:39:16

hsantanna
Member
Registered: 2017-02-13
Posts: 7

Re: x-systemd.automount with x-systemd.idle-timeout=60 won't umount

Yes, I can "sudo umount /mnt/hdd" and it works as expected.

Offline

#8 2021-05-12 19:51:41

seth
Member
Registered: 2012-09-03
Posts: 64,524

Re: x-systemd.automount with x-systemd.idle-timeout=60 won't umount

Last question before we blame lennart: which kernel do you use and does it happen w/ the LTS kernel?
Are all FS affected or can you eg. idle-out VFAT?

Offline

#9 2021-05-13 19:40:20

hsantanna
Member
Registered: 2017-02-13
Posts: 7

Re: x-systemd.automount with x-systemd.idle-timeout=60 won't umount

I'm using stable kernel.

So I tested with LTS kernel and both, ext4 and VFAT, file systems presented the same behavior on LTS as found on stable kernel.
Which means that neither will get unmounted after being auto-mounted.

Offline

#10 2021-05-15 15:56:23

seth
Member
Registered: 2012-09-03
Posts: 64,524

Re: x-systemd.automount with x-systemd.idle-timeout=60 won't umount

Since it affects multiple kernels and filesystems and you can umount yourself and the disk doesn't wake up interim:

          It's lennarts fault™.

(At least I can't think of another cause right now)
https://github.com/systemd/systemd/comm … 0f1d308f8c
and
https://github.com/systemd/systemd/comm … 0f1d308f8c
look suspicious enough, but could be entirely unrelated.

Offline

Board footer

Powered by FluxBB