Timeout for mounted hard drive

I have a second internal HDD which I use as a backup and only mount when I want to change something on it manually. I would like the disk to unmount itself 10 minutes after the last write access or a certain time after mounting. Here is my previous entry in /etc/fstab:

UUID=367e5c21-a249-45f4-9b5e-b5252c0a2813   /run/media/backup   ext4     defaults,noatime,noauto,user   0    0

With which option in fstab can I achieve this timeout?

https://wiki.archlinux.org/index.php/Fstab#Automatic_unmount

3 Likes

thanks @jonathon

1 Like

Would noauto,x-systemd.automount,x-systemd.idle-timeout=1min be an addendum to the below?

/dev/disk/by-id/wwn-0x5000c50092e490e9-part1 /mnt/Master\040Backups/ auto nosuid,nodev,nofail,x-gvfs-show 0 0

They are mount options, so go in the options part of the line (e.g. after x-gvfs-show).

1 Like

already done :wink:

UUID=367e5c21-a249-45f4-9b5e-b5252c0a2813   /run/media/backup   ext4     defaults,noatime,noauto,user,x-systemd.automount,x-systemd.idle-timeout=10min   0     0
1 Like

Isn’t gvfs a tool that only works under gnome? Can comment=x-gvfs-show also be used with KDE?

I was replying to

Different thing - you don’t need those options too.

:wink:

So yes an addendum.

/dev/disk/by-id/wwn-0x5000c50092e490e9-part1 /mnt/Master\040Backups/ auto nosuid,nodev,nofail,x-gvfs-show, noauto,x-systemd.automount,x-systemd.idle-timeout=1min 0 0

When I install and change my mount points to folders under /mnt/ that’s what’s created by the system for Master Backups, so yes looks like that isn’t just a Gnome option.

1 Like

So would it be better to mount this backup HDD under /mnt instead of /run/media? I assumed that mountpoints under /mnt would only be for drives that are mounted at boot time.

I honestly couldn’t tell you. I just like the idea of having all the mounts in one folder.

II have now mounted said hard disk in /mnt. But I have a question about the mount options. If I have the necessary options

defaults,noatime,noauto,user,x-systemd.automount,x-systemd.idle-timeout=10min 0 0

If I set a defaults, isn’t it ineffective or partially eliminated? I think it would be cleaner if I left out defaults, don’t you?

Edit: The translator is to blame for my bad english, not me :wink:

2 Likes

You don’t need to add defaults if you have at least one option specified; defaults is only used as a “placeholder” if no other options are used.

In other words, you only need to specify defaults if the field would otherwise be empty.

In your case, you have multiple options, so you don’t need defaults; it doesn’t hurt anything having it there, but it’s not necessary.

6 Likes

OK, thanks @anon3337769 :grinning:

1 Like