This brief tutorial shows students and new users how to share folders from VirtualBox host computer to Ubuntu 20.04 | 18.04 guest machines.
When using VirtualBox you can share folders from the host computer to guest machines. Guest machines can be Windows, Linux or MacOS.
This is made possible by VirtualBox host folder sharing feature. Folder sharing exposes the host computer files and folders to the virtual machines.
In order for this to work, you must by running the latest version of VirtualBox virtualization software with the current version of guest additions tools. You’ll have to enable bidirectional sharing from the host software, and the steps below show you how to do that.
To get started with sharing folders from VirtualBox host to guest machines, follow the steps below:
Step 1: Install VirtualBox Guest Additions
VirtualBox comes with guest machines tool called guest additions. Whenever you create a new guest machine, you must install the guest additions tool.
The tool provides tight integration between the host and virtual machine operating systems, improvement to the VM graphics performance, shared folder between the host and guest machines, copying and pasting of text, images and files between the host and guest machine as well as mouse improvement.
To install the tool in Ubuntu, follow the steps below. First run the commands below update Ubuntu guest machine.
sudo apt update && sudo apt dist-upgrade && sudo apt autoremove
When you’re done, run the commands below to install the latest kernel header and dkms package to support VirtualBox.
sudo apt install virtualbox-guest-dkms build-essential linux-headers-virtual
After installing the packages above, restart your machine and continue below.
To install VirtualBox Guest Additions software on Ubuntu virtual machine operating systems, select the Devices from VirtualBox host application menu and click Insert Guest Additions CD image…
This should mount a virtual CD/DVD drive inside the Ubuntu guest machine. When that happens, you should get a prompt to run the software. Click Run to begin the installation.
You will have to type your password to install the software. If your account is not an administrative account, the installation will fail.
The Guest Additions suite of utilities is the official tools for VirtualBox virtual guest machines.
Restart the guest machine and you’re set.
To enable copying and pasting between the guest machine and the host, go to the guest machines settings page (General –> Advanced) and enable it as shown below
Step 2: Share the Host Folders
Now that the guest tool is installed in step 1, run the commands below to enable your account to access the host folder in Ubuntu.
The command to do that is below:
sudo usermod -G vboxsf -a $USER
After running the command above from Ubuntu guest, to Ubuntu guest machine settings from the host software and share the folder from the host machine.
Select the guest machine you want to share with and go to the Settings tab and pick the Shared Folders from the list. From there, click the Plus ( + ) at the top to add a folder you want to share.
Browse to the folder on the host machine and select it. If you want the folder to automatically mount everytime the guest machine starts, choose that option.
Click OK to save your changes and close out.
Turn on the guest machine or reboot if you’re already logged in. The next time you login, the shared folder on the host should be mounted.
If you don’t see it mounted, go to the /media/sf_FOLDERNAME
This post showed you how to share VirtualBox host folders with guest machines, including Ubuntu. If you find any error above, please use the comment form below to report.