You are not logged in.

#1 2021-11-03 19:15:22

Automath
Member
Registered: 2016-05-16
Posts: 115

How to automatically unmount a filesystem if there is an iddle time?

I wan't to do this to prevent erroneous operations happening on my media, so I consider a good practice that my drives don't be mounted all the time.

I triede with specifying the option x-systemd.idle-timeout=Xmin but it isn't working, so I asked somewhere else and they told me to use autofs, but I don't want to over complicate the thing, also I see there are so many options for this and I'm not sure wich to choose, I would stay with fstab as it is specified to be the preferred one. Any help please?

@loqs here is an example on which I was testing:

/etc/fstab:

LABEL=cache            /disks/cache     ext4             rw,user,x-mount.mkdir,x-umount.rmdir,relatime,noauto,errors=remount-ro,x-systemd.idle-timeout=1min  0 0

Note that I think that the option x-umount.rmdir probably doesn't exist and the system should ignore it if it has humor (because you told me I think that there wasn't difference between udisksctl and fstab and now here I am fighting against something that doesn't work), despite that the drive mounts correctly and I think that I already tested it without that probavly inexistent option with the results stated in tjis post.

Last edited by Automath (2021-11-05 18:31:43)

Offline

#2 2021-11-03 19:19:11

dreamycrane
Member
Registered: 2019-03-18
Posts: 25

Re: How to automatically unmount a filesystem if there is an iddle time?

Plz use autofs

Offline

#3 2021-11-03 19:21:25

Automath
Member
Registered: 2016-05-16
Posts: 115

Re: How to automatically unmount a filesystem if there is an iddle time?

dreamycrane wrote:

Plz use autofs

Why fstab option doesn't work? Even it's stated in this section: https://wiki.archlinux.org/title/Fstab# … ic_unmount

Offline

#4 2021-11-03 19:55:04

loqs
Member
Registered: 2014-03-06
Posts: 18,993

Re: How to automatically unmount a filesystem if there is an iddle time?

Please post your current fstab.

Offline

#5 2021-11-03 20:49:16

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,223

Re: How to automatically unmount a filesystem if there is an iddle time?

I wan't to do this to prevent erroneous operations happening on my media

If you're using x-systemd.automount: think hard why that's not gonna fit your usecase…

You could write a daemon that freqently polls https://www.kernel.org/doc/Documentation/block/stat.txt and if it doesn't change for the device and a long enough time, umount the device.

Offline

Board footer

Powered by FluxBB