Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Apparently the answer is here: http://superuser.com/questions/251537/mount-specific-ntfs-directory-on-linux however it is not working as expected.

I have a dual boot system with Windows 7 and Ubuntu 13.04 (upgraded from 12.10), and I want to access my Windows 7 personal folders for both reading and writing. I followed instructions according to the given link and my /etc/fstab file looks like this:

/dev/sda1 /media/windows ntfs ro,umask=0222,defaults 0 0
/media/windows/Users/MyUser/    /home/myuser/Windows    ntfs-3g rbind,user,umask=0222,defaults 0 0
/media/windows/Users/OtherUser/ /home/otheruser/Windows ntfs-3g rbind,user,umask=0222,defaults 0 0

It almost works as expected. My Windows partition is on /media/windows/ with read-only permissions and my Windows personal folder is in ~/Windows. However this personal folder is also read-only.

Note I'm configuring this in a multisession environment, so I need this to work for my session and for other user's sessions. I need that each user can access and be able to write and read their Windows folders from Linux.

share|improve this question
    
Is there any way I can change and test configurations without having to restart the whole system. So far I have tried changing umask (to 0002), adding uid and gid parameters, etc. with no positive results, but each change requires a system shutdown. –  Carlos Eugenio Thompson Pinzón Sep 4 '13 at 16:03
    
I had awarded the 100 bounty to totti for the idea or mounting the partition under /root/ (which is working). My current solution uses the hints provided by falconer, ajThapa, totti and yilmi, none of them is working as expected in the original question (protections are not enough), but it is working (users have rw access to their data). All these mentioned answers were upvoted. –  Carlos Eugenio Thompson Pinzón Dec 23 '13 at 16:29

7 Answers 7

I doubt that the linked superuser answer is a working one. (Though I can't try it.) From man mount:

Note that the filesystem mount options will remain the same as those on the original mount point, and cannot be changed by passing the -o option along with --bind/--rbind. The mount options can be changed by a separate remount command, for example:

mount --bind olddir newdir
mount -o remount,ro newdir

I also doubt that it is possible to --rbind a part of a file system with a different file system driver (ntfs vs ntfs-3g).

When you rbind the mount command ignores every option, so nothing will become read-write. And because the kernel ntfs driver does not support writes, obviously the rw option won't help with that one either. Use the ntfs-3g driver.

Basically what you should do is this (in a terminal):

mount -t ntfs-3g -o ro /dev/sda1 /media/windows
mount --bind /media/windows/Users/MyUser/    /home/myuser/Windows
mount -o remount,rw /home/myuser/Windows

(I think that --rbind is also unnecessary, --bind should be enough.)

And regarding the comment under the question: Of course you don't have to restart the system for testing, just use the mount command as I did above. (And unmount with the umount command.)

After you confirmed that this works as intended, you just modify the mount and add the options you want: uid, gid,umask, etc.

share|improve this answer
    
Well, I can test using mount, however when I find the working configuration, I will want to do it automatically, either by /etc/fstab or by any other means. (With the Ob Question: how do I translate mount commands into fstab parameters?) –  Carlos Eugenio Thompson Pinzón Dec 22 '13 at 16:25
    
@CarlosEugenioThompsonPinzón The fstab is just a file which is parsed sequentially by the mount command on startup. But I think Ubuntu doesn't use mount but mountall at startup, which may not run the commands in fstab sequentially. So yes, putting these command parameters simply to fstab might not work. But you can always put simply the working mount commands into a startup script (e.g /etc/rc.local) or make an upstart job from those. The more important thing in your case is to find out a working mount scheme, making it automount on startup is an easy job. –  falconer Dec 22 '13 at 16:37
    
@CarlosEugenioThompsonPinzón Oops I missed the last question from you comment. So how the mount commands translate to fstab? You can look it up in man mount or here. Short story: first field: device to mount, second field: mount point, third field: fs-type (more precisely fs driver), fourth field: mount options, the other field are less importat now. So form the mount command the string we wrote behind -t goes in the third field, the string we wrote behind -o goes into the fourth field. –  falconer Dec 22 '13 at 17:25

The above linked super user question is for mounting partition and sub directory in read only mode. You need only the sub-directory (personal folder) to be read-write.

First check your system can mount ntfs partition in read-write mode

mount -t ntfs-3g  -o rw /dev/sda1 /media/windows

Now test if the mounted fs is writable. If not stop here and ask another question in this site.

The problem is an RO mounted partition's sub-directory can't be in RW. So the solution is mount the windows partition in RW in a hidden and inaccessible place. So let's mount it on /root/win which is inaccessible by non-root users (without sudo)

As a root user do following
Steps
1. Mount windows partition in RW

mount -t ntfs-3g -o rw /dev/sda1 /root/win  

2. Bind it

mount --bind /root/win/Users/MyUser/  /home/myuser/Windows  

3. Bind a read only instance of windows partition

mount --bind /root/win /media/windows  
mount -o remount,ro /media/windows

Now everything should be OK. Additionally you can unmount the windows partition but I warn you in some system it will make make the binded one (@home) inaccessible. The code is umount /root/win

Alternatively you can mount the windows partition in RW at /media/windows ( instead of /root/win) and immediately bind mount it at the same mount point (/media/windows) so that no one (even root) can write on the partition (but on the user folder).

share|improve this answer
    
Does it work ? What the problem? –  totti Dec 22 '13 at 9:53
    
The first part, mounting rw in /media/windows seems to work although it does not report w permissions I can actually touch and edit files. –  Carlos Eugenio Thompson Pinzón Dec 22 '13 at 16:05
    
When remounting I get the following error: Remounting is not supported at present. You have to umount volume and then mount it once again. –  Carlos Eugenio Thompson Pinzón Dec 22 '13 at 16:56
    
I think its your system's problem. I have this tested successfully in ubuntu 12.10. I never see such error even in ubuntu 10.04. You may try it in a live system(as you seemed to be updated the OS). –  totti Dec 23 '13 at 9:56

See if this helps...

If sda1 is already mounted to /media/windows, you could unmount it with:

sudo umount /media/windows

Next create the directory windows in /media/:

sudo mkdir /media/windows

Edit the /etc/fstab as below:

/dev/sda1  /media/windows ntfs-3g  rw,nodev,noexec,auto,nouser,async,locale=en_US.utf8,uid=1000,gid=1000,umask=0002 0 0

/media/windows/Users/MyUser/  /home/myuser/Windows  ntfs-3g rbind,user,rw,nodev,noexec,auto,async,uid=1000,gid=1000,umask=0002 0 0

/media/windows/Users/OtherUser/  /home/otheruser/Windows  rbind,user,rw,nodev,noexec,auto,async,uid=1001,gid=1001,umask=0002 0 0

(Note: change uid and gid values as for the user. To get the uid and gid of a user you can use the command id -u username and id -g username resp.)

Now you can mount these with the command:

sudo mount -a

Now go to the rebinded directories and see if you can edit the file. And you should be done.

share|improve this answer
    
Okay, I have rw permissions on /media/windows (not reported in ls, but I can edit files) as root, however in the local directories I need to sudo in order to modify the files. –  Carlos Eugenio Thompson Pinzón Dec 22 '13 at 16:16
    
... and now all mounted directories are belonging to me (user 1000), from /media/windows to /home/someotheruser/Windows. –  Carlos Eugenio Thompson Pinzón Dec 22 '13 at 16:41
    
I guess now you and other users can make and save works in the resp. mount-points in the users' $HOME... if the rest of users still aren't able to have RW access, add them to your group (probably with the gid 1000) –  rusty Dec 22 '13 at 17:16
    
Currently I have a group to which all local users are attached, and I'm granting write permissions to that group. This solves the “each user has rw access to their own data” but the whole partition and other user's data is not protected. –  Carlos Eugenio Thompson Pinzón Dec 23 '13 at 16:20

Do all your testing before editing your fstab configuration file.

Well, you probably know that ntfs filesystem is automatically mounted in read-only if filessystem is flagged as dirty. What you have to do first before trying any of the answers is to mount disk in windows and run chkdsk before trying to mount it again.

Also, if mounting in rw still failing, you should try mounting with different mount type options such as sudo mount -t ntfs or sudo mount -t ntfs-3g

Once fs is mounted in rw you can do the following :

mount --bind /media/MOUNTPOINT/TARGETFOLDER /home/SHAREDDIRECTORY/ mount -o remount,ro /home/SHAREDDIRECTORY/

or

sudo gksu nautilus or sudo gksu dolphin to open an explorer with su rights

share|improve this answer
    
Thank you for the chkdsk. There was indeed some corruptions in the NTFS partition, and now I can write to the mounted drive with sudo. –  Carlos Eugenio Thompson Pinzón Dec 22 '13 at 16:19

Why not trying to mount it with read and write attribute : rw ?

/dev/sda1 /media/windows ntfs rw,umask=0222,defaults 0 0

share|improve this answer
    
I will check, however I would rather have the whole partition read-only and only some specific folders as read-write. –  Carlos Eugenio Thompson Pinzón Sep 2 '13 at 20:46
    
Didn't work. Both the partition and the folders are still read-only. The only difference is that chmod and chown do not fail reporting a read-only error: they just don't operate. –  Carlos Eugenio Thompson Pinzón Sep 2 '13 at 20:55

I am not quite sure however, can you try this please. After the drive is mounted, give the following command on the terminal

sudo gksu nautilus

enter your administrative password and in the graphical window that open, you should be able to click the drive and change read/write permissions.

Let me know if this works. There is help available for use of nautilus with graphical interface with root privileges.

share|improve this answer
    
This would allow access to the files and they could be copied off as well, but the read-only permissions might not be changed, as non-unix filesystems are mounted as read only... –  Wilf Dec 17 '13 at 13:12

I would recommend using sudo chmod.666 ~/Windows

https://help.ubuntu.com/community/FilePermissions

share|improve this answer
1  
I can neither change permission or owner (even with sudo). It rejects the command saying that the system is read-only. Not even in /media/windows/ which is the whole partition (and which would not be the expected behavior) –  Carlos Eugenio Thompson Pinzón Sep 2 '13 at 18:50
    
I'm probably wrong, but sometimes sudo doesn't have permissions that root would have. Try running sudo su then chmod –  virtualxtc Dec 16 '13 at 23:52

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.