Mounting a Windows folder with writing permissions in Ubuntu
Solution 1:
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).
Solution 2:
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.
Solution 3:
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.
Solution 4:
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