Hello there. If you're reading this then you're probably trying to get around the fact that NTFS partitions don't support Linux file permissions. This tutorial will, hopefully, show you how to get around this little problem. Fortunately for you, this only involves editing a single file. Easy, eh?
The file in question is located at /etc/fstab. This file contains a list of partitions which you want mounted, one partition per line. Now, if you take a look at this file, you'll see that there are several lines already. DO NOT EDIT THESE LINES. They are important. Editing them, even slightly, may cause your system to stop booting.
If you take a look at this file, you'll see that there are several columns of information. Assuming that you haven't already created one, you'll need to add a new line for your NTFS partition. To know what to put as the information for the partition, we'll need to know a few things about it. Once you have all the information, you can edit fstab by running
gksu gedit /etc/fstab
- Firstly: which partition is it?
In this case, this needs to be a device node identifier. e.g. /dev/sda1, a partition UUID, or a partition label. Running
in a terminal will tell you all the relevant information about your partitions. Hopefully you can determine from this list which one is the correct partition.
sudo blkid -c /dev/null
If you use a UUID or Label, you need to declare it as such. e.g. "LABEL=Windows", "UUID=ABCDEFGHIJKLKLMNOP".
- Next, where should it be mounted?
This part is simple: where do you want the partition to be accessible from? Ubuntu mounts partitions in /media by default, so if you want the partition to be mounted there, say so. e.g. "/media/Windows". You will need to manually create this folder since fstab will complain if it's not there, so make sure that the folder isn't being used already, and run
sudo mkdir /media/Windows
- Next, which filesystem should it be mounted as?
Since we're mounting an ntfs partition, specify "ntfs-3g" for this column. Don't use "ntfs" unless you don't want to be able to write to the partition after it's mounted (by write, I mean making new files, editing files, moving files and folders, etc.; the "ntfs" driver is outdated and only lets you read files.)
- Next, what options should it be mounted with?
This is the most important column in this case, this is where you specify permissions. How you do this isn't immediately obvious, but there's a way, and it's actually rather simple.
This is a comma separated list, so don't use spaces or tabs, or else you'll find that the mount line doesn't work as expected. To specify the permissions, you merely need to declare three things: UID, GID, and umask.
- uid=#### specifies which userid should own the files on the partition. e.g. "uid=1000" means that the user with the id "1000" should own the files. You can find out your UID by opening a terminal and running "echo $UID".
- gid=#### specified which groupid should own the files on the partition. e.g. "gid=1000" means that the group with the id "1000" should own the files. Finding out groupids is slightly more difficult than finding out your userid because you can belong to several groups at the same time. Now, Ubuntu normally creates a group for every user, with the same ID as the UID, so you can probably use your UID as the GID. However, you can get a list of groups by running, in a terminal, "cat /etc/group". This will display a list with upto four colon-separated fields per line. The lines will contain the following items: name, an encrypted password, the GID, and a list of users in the group. Find the group you want to use, and add it's GID to the options.
- umask=UGO is the most important of the three options; it specifies what the permissions will be for the user, the group, and everyone else. The numbers used here need to be between 0 and 7, anything else will probably cause an error. These numbers are actually an inverse of normal permissions, so while "7" means "read, write, and execute" in normal permission setting, in fstab "7" means "no permissions". Setting "umask=000" will give EVERYONE read, write, and execute permissions. For clarification, the U is the permissions for the user, G is for group, and O is for others. See this for more details about umask.
You may also add other things to this list. Generally speaking, it's best to start with the "defaults" option. "auto" makes the partition mount automatically when you boot up. Read more here: http://www.tuxfiles.org/linuxhelp/fstab.html
- The final two columns should be "0" and "0".
These two columns are only used for Linux filesystems, so setting them to 0 stops any complications from arising.
A finished fstab line may look like:
UUID=ABCDEFGHIJKLKLMNOP /media/Windows ntfs-3g defaults,auto,uid=1000,gid=1000,umask=002 0 0
The next time you boot up, or the next time you run "sudo mount -a", the partition should be mounted where you want it, with the permissions you want it to have.
/dev/sdb5 /mnt/Music ntfs-3g defaults,uid=1002,gid=1500,umask=227 0 0