Neil Bothwick regularly
backs up his brain to an external drive.
Q Filling fstab
I’m on Ubuntu 22.04 and using it for a lot of video/audio projects. That’s resulted in the accumulation of a lot of drives. Since I often have dormant projects mixed with active as well as archived ones, my drives are not always plugged in. Until now, I’ve just used my Dolphin file manager to mount a drive by simply clicking it. With a bunch of drives, though, it can get to be a nuisance.
I’d like to have the system, when booting, auto-mount whatever drives are plugged in (and ignore any not plugged in). I’m assuming this might be accomplished by listing the drives in fstab and that it may be time to start entering all of them. Is fstab a good way to handle this? The listing of drives in fstab could get quite long. Is that bad?
Jay Robson
A
It can be done with fstab, but as you mention Dolphin, it sounds like you use a KDE Plasma desktop and that provides a simpler solution. Open System Settings and go to Hardware > Removable Storage > Removable Devices. There you will see an entry for All Known Devices. Tick the On Login or On Attach box (or both) and any drives you have previously used will be automatically mounted when they are plugged in, while any new devices still ask whether you want to mount them.
It sounds like this is what you need, but if you want to use fstab, or you are using a different desktop, that is a way to do it. It could make for a long fstab file if you have a lot of drives, but that’s not a problem as long as you keep it organised. Keeping all your removable drives together, along with sensible use of comments and blank lines, will keep the fstab file readable. As the devices could be plugged in at any time, their device nodes could change, so you need to identify them by UUID or LABEL. If possible, give each of your filesystems a unique and meaningful label, to keep fstab readable. Otherwise you need to use UUIDs and comment each entry.
You also need to change the options for each drive and there are two approaches you could take. One way is to add nofail to the options for each drive. This means the system will try to mount all the drives when you boot but will not complain about missing ones. If you subsequently connect a drive, you will need to issue the mount command manually, so best add user to the options to avoid needing root.
To save overloading your fstab, KDE Plasma can automatically mount only those drives it knows about.