Content-Type: text/plain

Have you ever mounted an external disk with the exact mount attributes that you need, then realised now you have to translate them from command line flags into the /etc/fstab equivalents?

Unfortunately you can't reconstruct the minimal effective option set directly the command you typed, because the kernel normalises it into canonical form.

However, you can do it using genfstab from the arch-install-scripts package1.

This is a shell script designed for use when installing Arch Linux. It's supposed to be used to generate the entire contents of /etc/fstab based on your fresh installation running within a chroot, but it can still be useful for generating partial fstab lines.

Using it is simple: after your disk is mounted the way you like, just run genfstab -U. Copy the line that corresponds to your disk and put it in your actual /etc/fstab.

The -U flag tells it to use UUIDs, which is almost certainly what you want. The default is to use device paths like /dev/sda1 which have no stability guarantees and will come back to bite you one day.

For more information see the Arch Linux Wiki entry for genfstab or the man page.


  1. If you don't use Arch Linux (why not?), there's also a standalone fork