How to create a shared folder on Virtualbox

Endrit Qerreti

Endrit Qerreti

Sharing folder option allows you to share files from the host system to the virtual machine, and from the virtual machine to the host system.

It's basically a folder that you can access from host and virtual machine. This feature is useful when you need to transfer files between the host system and the guest OS. Instead of using a third party service to do this, you can easily setup a sharing folder and use it locally.

In this tutorial, you will learn how to create a shared folder on Virtualbox.

Create a sharing folder on Virtualbox

We are going to create a sharing folder using Linux mint as the host system, and Ubuntu 23.04 as the Virtual machine.

So basically we want to be able to share files between Linux Mint 21.2 and Ubuntu 23.04.

To create the sharing folder, first you need to launch Virtualbox on the host system.

Next, select the virtual machine that you want to create the shared folder

Now right click over the selected virtual machine and go to Settings

Once you are in the settings window, go to 'Shared Folders' setting

Now you need to create the shared folder. To do this, simply click to the + button at the top right, and select the folder path by clicking the down arrow icon, and check the 'Auto-mount' option, then click the 'Ok' button to save changes.

The Add Share window, should look like this after you have imported the folder

Next, start the virtual machine

Now, you need to install virtualbox-guest-utils package. This package is required in order for the shared folder to show up on the virtual machine.

Launch terminal on the vm, and run the command below

sudo apt install virtualbox-guest-utils

Now the shared folder should appear on the virtual machine.

However, if you try to access it, you will get the following error. This is normal because it simply means that the user that you are using it's not in the vboxsf group, and you can't access this folder because of missing permissions.

To fix this error, you need to add your vm user to the vboxsf group. To do this, run the command below

sudo adduser $USER vboxsf

Once you have installed the required package, and added your user to the vboxsf group, you need to reboot the virtual machine for the changes to take effect.

To reboot

1) Click to panel

2)Click to 'Turn off button

3) Choose Restart

Now you should be able to access the shared folder on virtual machine, and share files.

As you can see, we shared one image which is accessible from both operating systems.

Linux Mint 21.2 (left) | Ubuntu 23.04 (right)

Conclusion

In this tutorial, you learned how to create a shared folder on Virtualbox, so that you can use to share files between two machines.