2012. Sharing Files between Host and Guest in VirtualBox
VirtualBox, Ubuntu, and macOS


Introduce how to achieve bidirectional file sharing between macOS host and Ubuntu guest.

1. Installing VirtualBox Guest Additions

1) Get VBoxGuestAdditions.iso
In macOS, Finder->Application->VirtualBox->Show Package Content image
Find VBoxGuestAdditions.iso in /Contents/macOS/. image
Copy it to another folder, eg. ~/Downloads/
2) Insert the Image to Ubuntu VM
Ubuntu VM->Devices->Optical Drives->Choose disk image…, locate to ~/Downloads/VBoxGuestAdditions.iso.
image
3) In Ubuntu, select VBoxGuestAdditions.iso, and click ‘Run Software’ to install. image
After Guest Additions are installed, a new user group ‘vboxsf’ has been created.

2. Creating Shared Folder on macOS

In macOS, create a new folder /UbuntuSF/, which is used to share files with Ubuntu. image

3. Adding Shared Folder to VM’s SharedFolders

In VirtualBox, select Ubuntu VM->Settings->SharedFolders, click ‘Add Folder’ at the right side. Set path to /UbuntuSF, check ‘Auto-mount’ and ‘Make Permanent’. image
The shared folder is created for VM now. image

4. Adding User to Group ‘vboxsf’ in Ubuntu

In Ubuntu VM, run the following command in terminal.

$ sudo adduser johnny vboxsf

image
Then, reboot Ubuntu.

5. Checking the Shared Folder in Ubuntu

Go to directory /media/, there should be a new shared folder sf_UbuntuSF. image
Create a new file here. image
You will see it in /UbuntuSF on macOS. image

6. References