This seems to be confusing a lot of new users, and although the answers are out there on dozens of threads, I thought it would be worth writing a quick post that pulls everything together in one place.
How can I chmod or chown files on my NTFS/FAT partition?
You can't. chmod
will terminate without error if you try it, but you'll find the permissions and ownership haven't changed (Don't worry, you're not the first to be confused by that and you won't be the last).
When you mount a Windows filesystem, Linux sets the permissions for the entire filesystem at mount-time (if you want different files to have different perms/owners... time to change filesystem). FAT doesn't support Unix-style permissions at all, and while NTFS does, the Linux ntfs-3g
driver doesn't support that feature. You can control the settings by passing options to the mount
command, either at the command line or in /etc/fstab
The options to use are:
- uid: Owner of all files (can be user name or numeric ID)
- gid: Group of all files (can be user name or numeric ID)
- umask: Octal permissions for all files, in the same way as arguments to chmod, except they're inverted for some obscure reason. So 000 is rwxrwxrwx, 111 is rw-rw-rw-, etc.
- dmask: Octal permissions for directories only.
- fmask: Octal permissions for regular files (non-directories) only.
Note that any or all options can be omitted, and they'll just take some default value.
Example: mount an ntfs partition with owner openSauce, group users, permissions rwxrwxr-x for directories and rw-rw-r-- for regular files.
mount -t ntfs -o uid=openSauce,gid=users,dmask=002,fmask=113 /dev/sda6 /mnt/sda6
Remember, no spaces between the mount options!
Example 2: Line in fstab to do the same thing automatically at boot
/dev/sda6 /mnt/sda6 ntfs uid=openSauce,gid=users,dmask=002,fmask=113 0 0
Please note that if you want to be able to write to NTFS, you'll need the ntfs-3g driver
. Most newby-friendly distros should have this installed by default, but if you're using an older or less "automated" one you may have to install it yourself.
Pretty sure I got all that right, but if anyone has corrections or improvements please let me know! Thanks to David the H., theYinYeti, and Mol_Bloom for suggesting improvements.