You are not logged in.

#1 2024-12-23 18:06:35

zw
Member
Registered: 2022-05-31
Posts: 19

Unmount a device if it isn't being used

I have started using gocryptfs, which lets you store encrypted files in a directory, then mount (via FUSE) the directory to a decrypted view so you can read/edit the contents.

One downside of this is that you have to remember to umount the directory when you are done working.

I was thinking about putting

if mountpoint -q /plain/view/mountpoint; then
  umount /plain/view/mountpoint
fi

in a cron job so that the directory gets automatically unmounted if I forget about it. But sometimes, I want to set up a long file operation to run unattended for several hours, and I don't want this cron job to interrupt it if the cron job happens to fire in the moment between copying two files (and thus, the device is not busy and gets unmounted).

Is there a good way to "mark" a device as busy until a certain operation completes and prevent unmounting it until then?

Last edited by zw (2024-12-23 18:09:11)

Offline

#2 2024-12-23 18:14:59

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 8,738
Website

Re: Unmount a device if it isn't being used

Try using the x-systemd.automount option with an appropriate x-systemd.idle-timeout setting, as per systemd.mount(5).

EDIT: corrected man page reference.

Last edited by Head_on_a_Stick (2024-12-23 18:38:08)


Para todos todo, para nosotros nada

Offline

#3 2024-12-23 21:16:42

bulletmark
Member
From: Brisbane, Australia
Registered: 2013-10-22
Posts: 681

Re: Unmount a device if it isn't being used

Note that gocryptfs has a -idle option which will unmount the filesystem if idle for the specified duration.

Offline

#4 2024-12-30 18:37:25

linuxmasteraxe
Member
From: waco texas
Registered: 2024-12-30
Posts: 15

Re: Unmount a device if it isn't being used

arch linux auto unmounts / directory for you when pressing off button


"i love central processing unit text mode" - By: Camden Miles (thats my name)

Offline

Board footer

Powered by FluxBB