How To: Properly automount NTFS and vfat partitions in Linux using fstab

This is more for my own notes than anything else, but to properly mount NTFS or vfat (i.e. FAT16/FAT32) partitions in Linux, first find the UUID of the drive using:

For example:

To mount NTFS or vfat partitions properly, you need to specify dmask (directory mask) and fmask (file mask) values, which as you might expect are the MASKS of the values you want to use (i.e. the octal compliments). Yeah, I’m not sure why it’s done this way either, but to calculate the mask value just subtract the value you want from 7.

As long as you know the following you should be just fine:

  • Read is 4,
  • Write is 2, and
  • Execute is 1.

For example:

  • If you want to mount the drive with 777 permissions (owner, group and other all r+w+x), then the mask of that is 000 – i.e. 7-7 = 0 for read, write and execute
  • If you want to mount the drive with 751 permissions (owner r+w+x, group r+x, other x), then the mask is 026 – i.e. 7 – 7 = 0, 7 – 5 = 2, 7 – 1 = 6)

So once you’ve identified your partition, you can add the following to your /etc/fstab file to have it mount automatically on boot:

So if I want to automatically mount my sdb3 partition at boot (which I know is formatted as ntfs) at /media/DATA with 755 permissions (owner r, group r+X, other r+x, i.e. 022 mask), I could use:

For the user ID (uid) or group ID (gid) values, you can use the numerical or actual values, i.e. uid=r3dux,gid=r3dux is fine, as is uid=1000,gid=1000 etc.

The first user account and group ID for any user on a Linux system are generally 1000.

If you’re not sure of your uid or gid values, just enter id in a terminal and it’ll tell you:

Happy NTFS & vfat automouting ;-)

Leave a Reply

Your email address will not be published.