r3dux.org

A number-pimping side project from the valleys in *NEW* upside-down flavour.

  • Home
  • ABOUT
  • OLD SITE
  • SEARCH
  • FEEDBACK

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

r3dux | July 21, 2012

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:

ls -l /dev/disk/by-uuid

For example:

r3dux@r3d-laptop:~$ ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 10 Jul 14 08:40 3f55aec7-b4be-4b51-bce7-ce32ec661eba -> ../../sda2
lrwxrwxrwx 1 root root 10 Jul 14 09:46 669A58CD9A589B7F -> ../../sdb3
lrwxrwxrwx 1 root root 10 Jul 14 08:40 bb15a473-2531-441a-a9d9-a6bbef705a57 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jul 14 08:40 C2B2D3AEB2D3A567 -> ../../sdb2
lrwxrwxrwx 1 root root 10 Jul 14 08:40 c5364a36-80ee-495f-9379-982a2c0397ea -> ../../sda3
lrwxrwxrwx 1 root root 10 Jul 14 08:40 EA26C54026C50E8F -> ../../sdb1

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:

UUID=<YOUR-UUID-HERE>    <DIRECTORY-TO-MOUNT-AT>    ntfs    uid=<YOUR-UID>,gid=<YOUR-GID>,dmask=<YOUR-DMASK>,fmask=<YOUR-FMASK>    0    0

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:

UUID=669A58CD9A589B7F    /media/DATA    ntfs    uid=r3dux,gid=r3dux,dmask=022,fmask=022    0    0

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:

r3dux@r3d-laptop:~$ id
uid=1000(r3dux) gid=1000(r3dux) groups=1000(r3dux),4(adm),20(dialout),24(cdrom),25(floppy),26(tape),27(sudo),29(audio),30(dip),44(video),46(plugdev),108(netdev),111(fuse),113(lpadmin),116(powerdev),117(scanner),125(vboxusers)

Happy NTFS & vfat automouting ;-)

Related posts:

  1. How To: Mount a NAS in Linux (via Samba)
  2. How To: Mount a NAS in Linux (via CIFS)
  3. How to: Create an ISO image of directories in Linux
  4. How To: Fix Greyed Out USB Options in VirtualBox with a Linux Host
  5. How to: workaround .gvfs transport endpoint is not connected errors
Categories
How-To, Linux
Tags
automount, fstab, gid, Linux, Mask, mount, ntfs, octal, permissions, uid, vfat
Comments rss
Comments rss
Trackback
Trackback
Print This Post Print This Post

« Retrogaming on Android We are on the fucking moon »

Leave a Reply

Click here to cancel reply.

Translate

Categories

Archives

Tags

3D ActionScript ActionScript 3.0 Adobe AI Ballarat Bash C++ Class Cover CS4 Effect Error Film Flash FPS GLFW Glitch GLSL Hack How-To install Java Kinect Linux Live Mash-Up Microsoft Motion mount OpenGL Particle Problem PS3 Remix Retro script Slides Sound Ubuntu Video VirtualBox Wii Windows XBox

Gamercard

OpenR3dux

Misc.

Flattr this

RSS Feed

r3dux twitter feed



“A lie can go round the world before the truth has got its boots on.”

 - Terry Pratchett

rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox