Virtualbox: create shared folder with GNU/Linux OS as guest

It can be very useful to create a shared folder between an host operating system and a virtualized one.

Firstly you need to install the Virtualbox Guest Additions as explained in this post.

Then just follow these simple steps to create the first shared folder:

  1. Start the Virtualbox program, select the virtual machine that needs the shared folder and then select Settings:
  2. virtualbox_6

  3. In the Settings window, select Shared Folders and then add a local folder to share, clicking on the icon with the green cross:
  4. virtualbox_7

  5. Chose the Folder Path (in my case the home folder):
  6. virtualbox_8
    and chose the Folder Name (in my case arch_home) a press OK.

    I recommend it, it is essential to remember the Folder Name!

    virtualbox_9

  7. Now start the Virtual Machine, open a terminal and create an empty folder where you want; we will mount the shared folder there. In my case, I create an empty folder in my home, named shared_folder.
  8. Type the following command in the terminal:
The folder shared from the host OS is now visible inside the guest one. However, this is a temporary solution, because you have to type this command every time you start your virtual machine, to have the shared folder.
  1. To solve this issue, open the fstab config file:
    > [email protected]:~$ sudo nano /etc/fstab

    put the following line at the end of the file:

    arch_home /complete/path/to/shared_folder vboxsf rw,uid=1000,gid=1000 0 2

    and create the virtualbox.conf file in /etc/modules-load.d/virtualbox.conf as follow, in order to load the VirtualBox module at boot time:

    > sudo nano /etc/modules-load.d/virtualbox.conf
    ---------------------------------------------------------
    vboxguest
    vboxsf
    vboxvideo

That's all, see you soon!

About Francesco Serafin

I am a PhD student at the Department of Civil, Environmental and Mechanical Engineering at the University of Trento. My two greatest loves: Computer Science and Water (take three with my Lenovo!:D). As a result, the aim of my life is to make both passions coexist. My gpg public key available at https://pgp.mit.edu

Leave a Reply

Your email address will not be published.

*