VirtualBox – Sharing a Host Folder With a Linux Guest

Sometimes you want to share a folder from your VirtualBox host machine to your guest OS. Perhaps for an installer, or to have access to specific files. There are pros and cons and safety concerns for this, however this is how you do it.

For this example I will be sharing a Windows host folder with an Xubuntu guest.

Setting Up The Folder

If you noticed while configuring your VM there is a section for Shared Folders and adding a new share won’t work by only setting these values (at least with specific Linux VM’s). Once this section is properly configured you will want to ensure that the Guest Additions are installed and continue to the VM configuration section below.


If you don’t want to track the folder down to mount it, I suggest checking that auto-mount box.

When setting up the share you are given a few options. Path and folder name are easy to figure out. Path is for which host folder you want to share and name is for what it will be called when mounted in your VM. The other two options have a little more importance though.


This will restrict the VM to read only access. A good thing if you know you don’t have to save files externally. Viruses could be spread through shared folders! So be aware of the risks!


This will automatically make the device show up as available. For Linux, this means you don’t have to track it down and mount it manually. Highly recommended for those who don’t want to manually mount file systems.

VM Configuration

If you boot your VM now you will be disappointed without additional set up as your user account doesn’t have access to the group needed to access the folder. You will see an error similar to the one below when the user is not configured to be in the group with access to this folder.


To get access this we must first install the guest additions. You can learn how to do that in my previous article here.

Ok, are your guest additions installed? Good because we will need a new user group that is created as part of that installation to give you access to your shared folder.

Single Command

To grant access you only need to run this command:

sudo usermod -G vboxsf -a [yourusername]

This command calls usermod to modify a user account. The -G specified to modify groups it belongs to. The following ‘vboxsf’ is the usergroup VirtualBox creates to share folders (I believe vboxsf stands for VirtualBoxSharedFolders). -a is to append, and this expects a username, so [yourusernamehere] should be the name of your user in the VM you want to give access to. Once this command is run, no output (as shown below) means it was successful.


If you did not install the guest additions, you will receive the error shown below:

‘vboxsf’ does not exist. If you get this error, please be sure that the Guest Additions are properly installed.

That’s it!

Security Concerns:

When sharing folders you are creating a link between the guest and host. This can be potentially dangerous if one or the other operates in a dangerous environment (such as one prone to pick up viruses) or if one environment has sensitive data that should be restricted. To prevent virus or malware transmission you can treat the folder as a virtual flash drive. Essentially any file in the folder is available to both machines. That means if you download malware (not just to that folder) it would be a possible link to let it transmit itself between physical/virtual machines.

So in summary:

  1. Install Guest Additions
  2. Add Shared Folder to VM configuration
  3. Add user to the vboxsf group with command ‘sudo usermod -G vboxsf -a [yourusername]’
  4. Reboot (or log out and back in) to have access.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.