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.