Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
You should read the Ubuntu documentation on mounting and writing to NTFS drives: help.ubuntu.com/community/MountingWindowsPartitions -- it includes the relevant fstab options. –  jasonwryan Nov 2 '11 at 18:59

3 Answers 3

up vote 6 down vote accepted

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.

share|improve this answer
    
What do you mean by "Windows file ownership"? I cannot try just now, but I seem to remember that without uid/gid files are owned by root. –  enzotib Nov 2 '11 at 22:40
    
@enzotib Windows has a notion of file owner, like unix (groups are more complicated). Come to think of it, I'm not sure that ntfs-3g supports mapping the Windows permissions onto unix: the manual says “the defaults are the uid and gid of the current process”, so I guess it doesn't. –  Gilles Nov 2 '11 at 22:59
    
Wonderful. This works very well for me and explained the options that I needed. Thank you very much. –  Zéychin Nov 3 '11 at 18:31
1  
@user13107 If you want to allow non-root users to mount, add the user option (and presumably change auto to noauto to avoid mounting at boot time). –  Gilles May 3 '13 at 10:05
1  
@milkovsky That would change the ownership of all the files on the Windows partition. Windows is unlikely to like this. –  Gilles Oct 16 '13 at 23:05

For those who want to do this with some mouse clicks, you could also just open Disks. Select the partition you want to mount, click on the gears button and then select Edit Mount Options as seen in the screenshot: Screenshot of Disks window

Then change to On the Automatic Mount Option and also check Mount on startup:

Screenshot of "Edit Mount Options" window in the Disks program

That's it.

Disclaimer: this might be Ubuntu specific and I tested on Linux Mint. I know this is unix.stackexchange.com, but the question did mention Ubuntu as distribution.

share|improve this answer

The system should try to mount everything at boot in /etc/fstab unless it's marked noauto (in the fourth column, "options"). Check for that, and if it's there, remove it. Regardless, Ubuntu usually tries to mount drives as soon as the system finds them. Are you getting any warnings when you mount it manually? Also check whether there are any system error messages: dmesg | less, (in less, you can use / to search).

For more information on fstab, go to a console and type man fstab.

share|improve this answer
    
I appreciate this answer. The partition wasn't in fstab and Ubuntu was not automatically mounting it, but Gilles answer helped me insert the proper line into fstab. Still a +1 for the help. –  Zéychin Nov 3 '11 at 18:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.