How to Share Folders Between an Ubuntu Guest and Host Machine in VirtualBox

Tutorial Dec 1, 2020

A simple guide on how to share folders between an Ubuntu VirtualBox VM and its host.

If you didn't know what VirtualBox is, it's a free, feature-rich program for x86 hardware virtualization. It's useful for running multiple guest Operating Systems on a single host machine.

Ingredients required:

  • Virtualbox VM running Ubuntu

Note: VirtualBox version 6.1 was used while writing this guide. But these instructions should work on past versions of Virtualbox just fine.

SHARING FOLDERS

The first thing to do, is to install the "guest additions" on your Ubuntu VM if you didn't do it already. After that, power down the guest machine and go to its settings.

In the settings window, navigate yourself to the "Shared Folders" section and proceed to adding the folder which you wish to share with the guest machine.

After that's done, we can start up the virtual machine.

The folder which you added to the "Shared Folders" list in the VM settings a while back will be available in the /media/ directory of Ubuntu. It will have an sf_ prefix. the "sf" stands for "sharedfolder". Let's make sure it's there with the ls command,

ls /media/
penguin sf_shared

Note: If for some reason the ls command doesn't show you anything, it could mean that the "guest additions" are not installed.

Like many other things in the world of Linux, by default the current user will not have the proper permissions to access this sf_shared folder. for that we need to add the current user to the "vboxsf" group.

sudo adduser penguin vboxsf
[sudo] password for penguin:
Adding user 'penguin' to group 'vboxsf' ...
Adding user penguin to group vboxsf
Done.

Then, reboot the virtual machine.

sudo reboot

Once you're back on to the Ubuntu desktop. We can make a symbolic link to the /media/sf_shared folder on our home directory, for convenience.

ln -s /media/sf_shared/ ~/shared

And ofcourse, make sure you can access the files and folders,

cd
ls shared
fish.sh igloo.jpg snow.jpg

And that is all!

Tags

Lime

Simple, like quantum physics.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.