File permission issues with shared folders under Virtual Box (Ubuntu Guest, Windows Host)

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 the vboxsf group (as root #).

# usermod -aG vboxsf <youruser>

By default, without manual action, the mounts look like this,

drwxrwx--- 1 root vboxsf 40960 Oct 23 10:42 sf_<name>

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,

Ubuntu               214153212  31893804 182259408  15% /media/sf_Ubuntu

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.

ln -s /media/sf_Ubuntu /home/m/Desktop/vbox_shared

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 to mount). 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,

tony@jabba:/media/sf_name$ ls -l tst.txt
-rwxrwx--- 1 root vboxsf 2283 Apr  4  2012 tst.txt
tony@jabba:/media/sf_name$ sudo chown tony tst.txt
[sudo] password for tony: 
tony@jabba:/media/sf_name$ ls -l tst.txt
-rwxrwx--- 1 root vboxsf 2283 Apr  4  2012 tst.txt
tony@jabba:/media/sf_name$ 

Enable full read,write access to a shared folder on a Windows host from an Ubuntu guest for a non-root Linux user

This step will enable you to access a certain directory on your Windows host machine from the Linux guest terminal. In this example the name of the share from the OVB perspective will be vshare ( which is the default ) , the full directory path to the Windows OS ( the host OS ) will be "C:\var\", and the full file path to access it from the guest vm will be "/vagrant". Finally, the name of the user to enable the full read/write access will be "you".

 # how-to add a shared folder on the host
 VBoxManage sharedfolder add "host-name" -name "vshare" -hostpath "C:\var" -automount

1. Install the Guest Additions prerequisites

Install the Guest Additions prerequisites by issuing the following command:

 sudo apt-get install -y build-essential make gcc  linux-headers-$(uname -r) 
 linux-headers-generic make linux-source  linux-generic linux-signed-generic

2. Install the Guest Additions

Do not use the .iso file to download and run the installer from there - it will simply not work !!!

sudo apt-get install virtualbox-guest-dkms 

3. Automount the Share on Boot

Configure the share directory to be automounted on vm boot by adding the following lines to the end of your /etc/fstab file ( note the "vshare" conf , and the uid=10001 ):

/media/sf_vshare /vagrant vboxsf bind,uid=10001,rw,umask=0000 0 0
# eof file: /etc/fstab 

4. Add yourself to the vboxsf group

# mount
sudo mount -a

sudo usermod -G vboxsf -a you 

5. Reboot and verify

Reboot the vm and login via ssh to verify the file sharing.

# ssh to the vm
ssh you@host-name

# check as yourself that you have access
find /vagrant

I just have had the same problem with my Win-Ubuntu shared folder, and the way I solved it was adding my user into the vboxsf group, editing the /etc/group file. Hope this works for you. Down here you can find a short scheme of how I edited the file

(edit /etc/group)
...
...
...
pulse:x:119:
pulse-access:x:120:
utempter:x:121:
rtkit:x:122:
saned:x:123:
openquake:x:1000:
sambashare:x:124:openquake,luisa
vboxsf:x:999:openquake,luisa   ##This is the line I add my user
postgres:x:125:
rabbitmq:x:126:
celery:x:500:
luisa:x:1001:

Luisa.