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

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

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)
vboxsf:x:999:openquake,luisa   ##This is the line I add my user


Related Solutions

Joining bash arguments into single string with spaces

[*] I believe that this does what you want. It will put all the arguments in one string, separated by spaces, with single quotes around all: str="'$*'" $* produces all the scripts arguments separated by the first character of $IFS which, by default, is a space....

AddTransient, AddScoped and AddSingleton Services Differences

TL;DR Transient objects are always different; a new instance is provided to every controller and every service. Scoped objects are the same within a request, but different across different requests. Singleton objects are the same for every object and every...

How to download package not install it with apt-get command?

Use --download-only: sudo apt-get install --download-only pppoe This will download pppoe and any dependencies you need, and place them in /var/cache/apt/archives. That way a subsequent apt-get install pppoe will be able to complete without any extra downloads....

What defines the maximum size for a command single argument?

Answers Definitely not a bug. The parameter which defines the maximum size for one argument is MAX_ARG_STRLEN. There is no documentation for this parameter other than the comments in binfmts.h: /* * These are the maximum length and maximum number of strings...

Bulk rename, change prefix

I'd say the simplest it to just use the rename command which is common on many Linux distributions. There are two common versions of this command so check its man page to find which one you have: ## rename from Perl (common in Debian systems -- Ubuntu, Mint,...

Output from ls has newlines but displays on a single line. Why?

When you pipe the output, ls acts differently. This fact is hidden away in the info documentation: If standard output is a terminal, the output is in columns (sorted vertically) and control characters are output as question marks; otherwise, the output is...

mv: Move file only if destination does not exist

mv -vn file1 file2. This command will do what you want. You can skip -v if you want. -v makes it verbose - mv will tell you that it moved file if it moves it(useful, since there is possibility that file will not be moved) -n moves only if file2 does not exist....

Is it possible to store and query JSON in SQLite?

SQLite 3.9 introduced a new extension (JSON1) that allows you to easily work with JSON data . Also, it introduced support for indexes on expressions, which (in my understanding) should allow you to define indexes on your JSON data as well. PostgreSQL has some...

Combining tail && journalctl

You could use: journalctl -u service-name -f -f, --follow Show only the most recent journal entries, and continuously print new entries as they are appended to the journal. Here I've added "service-name" to distinguish this answer from others; you substitute...

how can shellshock be exploited over SSH?

One example where this can be exploited is on servers with an authorized_keys forced command. When adding an entry to ~/.ssh/authorized_keys, you can prefix the line with command="foo" to force foo to be run any time that ssh public key is used. With this...

Why doesn’t the tilde (~) expand inside double quotes?

The reason, because inside double quotes, tilde ~ has no special meaning, it's treated as literal. POSIX defines Double-Quotes as: Enclosing characters in double-quotes ( "" ) shall preserve the literal value of all characters within the double-quotes, with the...

What is GNU Info for?

GNU Info was designed to offer documentation that was comprehensive, hyperlinked, and possible to output to multiple formats. Man pages were available, and they were great at providing printed output. However, they were designed such that each man page had a...

Set systemd service to execute after fstab mount

a CIFS network location is mounted via /etc/fstab to /mnt/ on boot-up. No, it is not. Get this right, and the rest falls into place naturally. The mount is handled by a (generated) systemd mount unit that will be named something like mnt-wibble.mount. You can...

Merge two video clips into one, placing them next to each other

To be honest, using the accepted answer resulted in a lot of dropped frames for me. However, using the hstack filter_complex produced perfectly fluid output: ffmpeg -i left.mp4 -i right.mp4 -filter_complex hstack output.mp4 ffmpeg -i input1.mp4 -i input2.mp4...

How portable are /dev/stdin, /dev/stdout and /dev/stderr?

It's been available on Linux back into its prehistory. It is not POSIX, although many actual shells (including AT&T ksh and bash) will simulate it if it's not present in the OS; note that this simulation only works at the shell level (i.e. redirection or...

How can I increase the number of inodes in an ext4 filesystem?

It seems that you have a lot more files than normal expectation. I don't know whether there is a solution to change the inode table size dynamically. I'm afraid that you need to back-up your data, and create new filesystem, and restore your data. To create new...

Why doesn’t cp have a progress bar like wget?

The tradition in unix tools is to display messages only if something goes wrong. I think this is both for design and practical reasons. The design is intended to make it obvious when something goes wrong: you get an error message, and it's not drowned in...