Generating fstab entries automatically on boot (not auto mount)

Hi everyone,
Long time listener, first time caller, thanks in advance to this awesome group of people.

I use Manjaro and Parted Magic for data recovery and retrieval on testbench machines so I am constantly plugging in new drives into them.
I have noticed that Parted Magic’s fstab gets automatically updated/populated on boot with detected devices and mount points in /media.
e.g.
/dev/sda1 /media/sda1 auto defaults 0 0
/dev/sdb1 /media/sdb1 auto defaults 0 0

This happens on every new boot which means when it is time to mount I can just run “mount <device>” instead of messing with mount points and options each time. Is there a way to do this with Manjaro?

I cannot seem to find the service/script or whatever it is that does this in Parted Magic in order to recreate it on my Manjaro machine. I have checked .xinitrc / systemd and can’t find anything but that’s why I’m in the newbie corner.
I have considered manually making entries sda1, sda2 etc. to cover all bases but it would be nice to have it dynamic/automatic for drives that might have a lot of partitions.

Sorry if there is already a topic on this but I could not find it with keywords amongst a lot of related fstab topics/questions.

Thanks again!

Hello @archunicorn and welcome :wink:

I would say just use udisks2. It is the most comfortable method when you need to switch between many drives.

That would be:

udisksctl mount --block-device /dev/sda1
udisksctl mount --block-device /dev/sda2

Mountpoint is fixed on /run/media/$USER/VolumeName, since it is a user mount. If you need it shared (global) on /media/VolumeName then take a look here: udisks - ArchWiki

Also possible is this:

find -L /dev/disk/by-uuid/ -type b -exec udisksctl mount --block-device "{}" \;

It searches for every known UUID and tries to mount every block device.

udisksctl is the same thing what every file manager uses to mount flash drives for example.


Beside all of that I don’t understand why one would like to mess with fstab. I understand that a live sessions can detect all connected drives and update fstab, but that very unusual for for real installations, because fstab resets on every boot on a live session unlike on a real installation.

1 Like

Thank you very much for pointing me in the right direction @megavolt, I will do some reading and testing to see what works best, much, much appreciated. Parted magic is non persistent using root by default so that makes sense as to why /media is the mountpoint too!

I would only be messing with fstab if there wasn’t a better way to do it, I just assumed altering fstab was the way to do it but that’s why I thought I would ask and hopefully get given a better answer like you gave. These are just test benches in an IT lab so although it is a real installation, it’s only purpose is to temporarily handle data recovery, not as a main OS for every day computing. A “throwaway” install if you will.