Share folders between host and guest OS in VirtualBox

VirtualBox is one of the best (and free!) virtual machine applications out there, but it’s even more useful if your virtual computer can be more closely integrated with the host computer.

While you can network the host and guest computer quite easily, most people probably just want an easy way to share folders between the host and guest OS in VirtualBox. The good news is that this is quite easy to do!

Cleaning up the terminology

It is important that we quickly clarify a few key terms that will be used in this article:

  • A virtual machine is a simulated computer running on another computer.
  • The “host” computer is the physical computer for you.
  • The “guest” computer is a virtual machine that runs thanks to VirtualBox.
  • “Bare metal” means running directly on the physical computer.

If you’ve ever seen the movie the matrix then you can think of the virtual machine as a computer living in a simulated world. It thinks it’s a real computer, but it’s really just software.

Operating System Compatibility

To use VirtualBox’s built-in shared folder feature, you need to install something called “Guest Additions” on the guest computer. At the time of writing there are additions for:

For most people, the guest machine will probably run Windows or Linux. If you’re using something more exotic (or trying to run macOS), this method won’t work.

Install guest additions

Before you can make shared folders work, you must first install guest additions on that virtual machine. This works by placing a virtual CD in the virtual machine’s imaginary CD drive. We’re using Ubuntu Linux here, but VirtualBox will automatically detect which additions are appropriate for the guest OS.

All you need to do is run your virtual machine and then click . click Devices and then Insert Guest Additions CD Image…

In our case, the “CD” played automatically and the additions were installed without any problems. We rebooted our virtual machine just in case, but it’s not strictly necessary. With guest additions installed, you are ready to add a shared folder to your virtual machine.

Create a shared folder on the host machine

VirtualBox presents a shared folder on the host computer as a network shared drive or as a special file system extension on the host computer’s operating system. So you want to point that folder on the bare metal computer to use it.

You can assign different shared folders to each guest of the virtual machine. It could be a folder that already exists or it could be a folder you created especially for this purpose. In either case, once you’ve decided which folder to share with the virtual machine, we need to select it and mount it.

We have created a folder containing a test text file for demonstration purposes.

Enable file sharing on the guest computer

You can add the shared folder to your virtual machine while it is running or stopped. We are going to mount the shared folder while our Ubuntu machine is running.

  • Click on the Devices menu and then Shared Folders>Shared Folder Settings
  • In this settings menu, click the blue icon to add a new shared folder.
  • Select the drop-down list with the folder path and choose other† Choose the folder you want to share and click Select folder
  • Select auto mount and then click OKAY. Then click Okay again.

The shared folder appeared on our Ubuntu desktop, but you may need to look for it in your operating system’s network drives list or in the file system explorer. In Ubuntu we had to enter the administrator password when opening the folder.

To remove the shared folder, just go back to the same window where you added it first and remove it from the list. Although the folder is shared, you can basically use it like any other mounted drive or drive.

Alternative ways to share folders between host and guest

Using the official host/guest file sharing method isn’t the only way you can move files between your bare metal computer and the virtual machine.

An easy way to transfer files is to use a USB flash drive. VirtualBox allows you to give control of a USB device to the virtual machine. Simply copy all the files you want to transfer to a flash drive and then switch control to the virtual machine using the VirtualBox menu.

Since your virtual machine also has internet access, you can install a cloud storage package like Dropbox on either system, assuming there is a version available for the guest OS. Although this does mean that files are synced over your internet connection, which can be slow and eat up your data limit, if you have one.

If you only want to copy something that fits in the clipboard (like a password), you might want to enable the shared clipboard in VirtualBox, which is also part of guest additions.

Virtually error-free file sharing?

Virtual machines are an incredible piece of technology, but they’re still the computer equivalent of duct tape and cardboard in terms of elegance. Ultimately, any solution to share files between a host and a guest system will be a mess to some degree.

That said, we had no problems getting it to work between our Windows host and Ubuntu guest. Many users will encounter some tough spots due to the wide variation that can exist between host and guest operating system types, but luckily the VirtualBox Community has seen it all.

So if you come across a problem that you can’t solve, we recommend that you search the forums first and then ask a question if the answer isn’t already there. However, most people who follow the instructions above will be fine.

Leave a Reply

Your email address will not be published.