Ubuntu – Mount NTFS Partition on Startup in Ubuntu

mountntfsUbuntu

I have a 10 gigabyte partition which I use for files which I share between my Windows installation and my Oneiric Ocelet (Ubuntu) installation.

My Eclipse workspaces exist on this partition. Eclipse loads up fine in Windows. In Ubuntu, however, if I have not mounted the partition manually, I receive an error about being unable to open the workspace.

I know that that partition mounts to /media/A476FC2E76FC033A, is formatted as NTFS, and is the /dev/sda4 partition.

I know that I can change Ubuntu's filesystem table via modifying fstab, but I do not understand all of the options involved in doing so and would like to do this correctly.

I appreciate any assistance any of you may be able to give to me.

Best Answer

The line in /etc/fstab in your case would be something like:

/dev/sda4  /media/A476FC2E76FC033A  ntfs-3g  uid=1000,gid=1000,umask=077,fmask=177

You may want to change some of these:

  • You can replace /dev/sda4 by the UUID of the filesystem. Using a UUID has the advantage that if you ever plug in another disk which causes your current disk to appear as /dev/sdb, the fstab entry would still work.
  • You can replace the mount point (second column) by a more meaningful name. Pick any empty directory. Note that the directory must exist.
  • Replace uid=1000,gid=1000 by your user ID and group ID (you can see them with the commands id -u and id -g). These options cause all files to be owned by you, ignoring Windows file ownership (I don't think you can retain Windows file ownership with ntfs-3g).
  • umask=077 causes files to be accessible only to you, not other users. umask=007 would cause files to be accessible only to you and other users in the group specified by gid. umask=0 (the default) allows anyone to read and write all files. umask=022 allows anyone to read but only you to write.
  • fmask=177 makes files non-executable even to you.
  • You may want to add other options.
  • You can add two more columns 0 0 at the end, but they're optional. I only mention them because you might find them in some examples.

See the fstab man page for more information on the /etc/fstab file.

Once you've written the line in /etc/fstab, test it by running

sudo mount /media/A476FC2E76FC033A

The next time you reboot, the filesystem will be mounted automatically.

Related Question