I would like to auto-mount some partitions the way USB drives and external HDDs are currently mounted on my system.
I understand that to auto-mount internal HDDs at startup, I need to place it in the /etc/fstab
and map its mount point, etc. But I like how my USB drives and external HDDs are automatically mounted to /run/media/myuser/drive-label
when I plug them in.
To do this to my internal HDDs, I'd have to use udiskctl mount --block-device /dev/sda4
and it then gets mounted to /run/media/myuser/sda4-label
. Is there a way of doing it automatically on boot?
I'm currently using Antergos (Arch Linux)
Best Answer
Take a look at the AutoFS service which can facilitate more elaborate automounting scenarios than can be accomplished via the
/etc/fstab
file.You can do a variety of things such as automounting devices via a script, when a directory path is accessed.
In this scenario if someone were to access
/media/ssh
the script/etc/autofs/auto.ssh
would execute and "mount" whatever directory they attempted to access under/media/ssh
.After 60 secs. of inactivity
autofs
will unmount the directory.