Mount exFAT file system as user without specifying /dev/sdX1 in /etc/fstab

filesystemsremovable-storagestorageusb

I've "solved" the following problem, but not in a desirable way.

First, mounting exFAT file systems in Linux was truly as simple as this site says.

The catch is, "as long as you are root."

A user would like to plug in his exFAT file system anytime, but attempting to do so results in:

mount.exfat /dev/sdc1 /media/exfat-device
ERROR: failed to open `/dev/sdc1'

This works as root, but I was able to solve this so that a user can mount it by adding the following line to fstab:

/dev/sdc1 /media/exfat-device exfat-fuse defaults 0 0

However, this is not desirable because it hardcodes sdc1 which assumes (incorrectly) that everything detected as sdc1 will always be exFAT. As an example I connected another non-exFAT drive which gives me no problems, and it's identified as sdc. Then I connect my exFAT device, which becomes sdd, making the fstab addition worthless.

What do I need to do, without giving the user any sudo privileges or elevated access whatsoever, so that any user can connect an exFAT device to that particular machine and read/write to it?

Best Answer

Most distributions have a command called by blkid. blkid will give you a unique identifier for each drive attached to you linux box. Fstab can uses this identifier, replace the /dev/sdc1 with UUID=XXXXXXXXXXXXX. This means that regardless of the user-space designation (e.g. sdc1 scb2 et cetera) your OS will mount it correctly.

Related Question