I am using Ubuntu on Virtual Box and I have a folder which is shared between the host (Windows) and the VM (Ubuntu). When I open any file in the share folder in Ubuntu, I can not change it as its owner is set to root.
How can I change the ownership to myself?
Here is the output of ls -l
:
-rwxrwxrwx 1 root root 0 2012-10-05 19:17 BuildNotes.txt
The output of df
is:
m@m-Linux:~/Desktop/vbox_shared$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 29640780 10209652 17925440 37% /
none 509032 260 508772 1% /dev
none 513252 168 513084 1% /dev/shm
none 513252 88 513164 1% /var/run
none 513252 0 513252 0% /var/lock
none 513252 0 513252 0% /lib/init/rw
Ubuntu 214153212 31893804 182259408 15% /media/sf_Ubuntu
/dev/sr0 53914 53914 0 100% /media/VBOXADDITIONS_4.2.0_80737
Ubuntu 214153212 31893804 182259408 15% /home/m/Desktop/vbox_shared
The options in VM is automount and the readoly is not checked.
Tried to use /media/sf_Ubuntu
, but getting permission error:
m@m-Linux:/media$ ls -l
total 10
drwxrwx--- 1 root vboxsf 4096 2012-10-23 15:35 sf_Ubuntu
drwxrwx--- 2 root vboxsf 4096 2012-10-21 23:41 sf_vbox_shared
dr-xr-xr-x 6 m m 2048 2012-09-13 07:19 VBOXADDITIONS_4.2.0_80737
m@m-Linux:/media$ cd sf_Ubuntu/
bash: cd: sf_Ubuntu/: Permission denied
m@m-Linux:/media$ cd sf_vbox_shared/
bash: cd: sf_vbox_shared/: Permission denied
Please note that I am in the group vboxsf
:
m@m-Linux:~$ id
uid=1000(m) gid=1000(m) groups=4(adm),20(dialout),24(cdrom),46(plugdev),105(lpadmin),119(admin),122(sambashare),1000(m),1001(vboxsf)
Best Answer
The regular way of getting access to the files now, is to allow VirtualBox to automount the shared folder (which will make it show up under
/media/sf_directory_name
) and then to add your regular Ubuntu user to thevboxsf
group (as root#
).By default, without manual action, the mounts look like this,
so the
vboxsf
group has full access. By adding your user to that group, you gain full access. So you wouldn't worry about changing their permissions (which don't make sense on the Windows host), you just give yourself access.In this specific case, this is the automounted Shared Folder,
and it is that directory that should be used to access to the Shared Folder, by putting the local user into the
vboxsf
group. If you want a 'better' link under your user's home directory, you could always create a symbolic link.You will need to reboot your VM for these changes to take effect
If you manually mount the shared folder, then you need to use the relevant options on the
mount
command to set the folder with the right ownership (i.e. the gid, uid and umask options tomount
). This is because the Host OS doesn't support the same permission system as Linux, so VirtualBox has no way of knowing who should own the files.However, I strongly recommend just configuring the shared folder to be auto-mounted (it's a setting on the Shared Folder configuration in VirtualBox itself).
For the avoidance of doubt, I do not believe you can change permissions normally anyway, on that filesystem if it's mounted in the regular way,