You are not logged in.
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
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
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
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
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
ftr, https://github.com/systemd/systemd/issues/3332
Sanity check: can you "sudo umount /mnt/hdd" w/o error?
Offline
Yes, I can "sudo umount /mnt/hdd" and it works as expected.
Offline
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
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
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