Sadly, not as simple as dragging and dropping
VirtualBox is one of the best (and free!) virtual machine applications out there, but it’s even more useful if your virtual computer can integrate more tightly with the host computer.
While you can network the host and guest computer together pretty easily, most people probably just want a simple way to share folders between the host and guest OS in VirtualBox. The good news is that this is quite easy to do!
Clearing Up The Terminology
It’s important that we quickly clear up a few key terms that will be used in this article:
- A virtual machine is a simulated computer that runs on another computer.
- The “host” computer is the physical computer in front of you.
- The “guest” computer is a virtual machine that runs thanks to VirtualBox.
- “Bare metal” means to run 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 actually just software.
Operating System Compatibility
In order to use the shared folder function built into VirtualBox, you need to install something called “Guest Additions” on the guest computer. At the time of writing there are additions for:
- Windows
- Linux
- Solaris
For most people the guest machine will probably run Windows or Linux. If you’re running something more exotic (or trying to run macOS) then this method won’t work.
Installing Guest Additions
Before you can make shared folders work, you need to install guest additions on the virtual machine in question. This works by putting a virtual CD into the virtual machines imaginary CD drive. We’re using Ubuntu Linux here, but VirtualBox will automatically detect which additions are right for the Guest operating system.
All you have to do is run your virtual machine and then click Devices and then Insert Guest Additions CD Image…
In our case the “CD” auto-played and the additions installed without issue. We restarted our virtual machine just in case, but it isn’t strictly needed. With guest additions installed, you’re ready to add a shared folder to your virtual machine.
Creating a Shared Folder On The Host Machine
VirtualBox presents a shared folder on the host computer as a shared network drive or as a special extension of the file system to the guest computer’s operating system. So you’ll want to designate that folder on the bare metal computer for it to use.
You can assign different shared folders to each virtual machine guest. It can be a folder that already exists or it can be one you’ve created especially for this purpose. In either case, once you’ve decided which folder you want to share with the virtual machine, we have to select and mount it.
We’ve created a folder with a test text file inside for demonstration purposes.
Enable File Sharing On The Guest Machine
You can add the shared folder to your virtual machine with it running or stopped. We’re going to mount the shared folder with our Ubuntu machine 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 folder path dropdown and choose other. Choose the folder you want to share and click Select Folder.
- Select auto-mount and then click OK. Then click OK again.
The shared folder appeared on our Ubuntu desktop, but you may have to look for it in your operating system’s network drive 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, simply go back to the same window you added it in the first place and remove it from the list. While the folder is shared, you can basically use it as any other mounted disk or drive.
Alternative Ways To Share Folders Between Host & Guest
Using the official method of sharing files between host and guest isn’t the only way you can move files between your bare metal computer and the virtual machine.
One easy way to transfer files is by using a USB flash drive. VirtualBox lets you give control of a USB device to the virtual machine. Simply copy all of 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 such as Dropbox on both systems, assuming there’s a version available for the guest operating system. Although this does mean that files will sync over your internet connection, which could be slow and eat your data cap, if you have one.
If all you want to do is copy something that will fit in the clipboard (such as a password) then you’re better off enabling the shared clipboard in VirtualBox, which is also a part of guest additions.
Virtually Flawless File Sharing?
Virtual machines are an incredible feat of technology, but it’s still the computer equivalent of duct-tape and cardboard as far as elegance goes. Ultimately any solution to share files between a host and guest system will be some degree of kludge.
That being said, we didn’t have any trouble getting it to work between our Windows host and Ubuntu guest. Plenty of users are going to run into some rough spots thanks to how much variation there can be between host and guest operating system types, but luckily the VirtualBox community has seen it all.
So if you do run into an issue you can’t resolve, we recommend first giving the forums a search and then posting a question if the answer isn’t already there. However, most people who follow the instructions above are going to be just fine.