LOGO

Access Host Folders in Ubuntu VirtualBox - A Guide

April 30, 2014
Access Host Folders in Ubuntu VirtualBox - A Guide

Sharing Folders Between VirtualBox Host and Ubuntu Guest

VirtualBox facilitates the operation of multiple operating systems – known as guests – within a single host computer. A common requirement is the transfer of files between these environments. While straightforward in Windows guest machines, establishing file sharing in Ubuntu guests requires a specific configuration process.

Enabling Shared Folders in Ubuntu

To enable access to host machine folders from within your Ubuntu virtual machine, shared folders must be activated. This functionality is achieved through the installation of the VirtualBox guest additions software. Detailed instructions for this installation can be found in a related article.

Once the guest additions are installed, the process of enabling shared folders involves adding a folder from your host system within the guest machine’s settings. Begin by ensuring the guest machine is completely powered off.

Select the desired guest machine from the list displayed in the VirtualBox Manager. Then, click the "Settings" button located on the toolbar.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-1.jpg

Within the Settings dialog, navigate to the "Shared Folders" section in the options list on the left. On the Shared Folders screen, initiate the addition of a new folder by clicking the folder icon with the plus sign.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-2.jpg

The "Add Share" dialog box will appear. From the "Folder Path" drop-down menu, choose "Other."

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-3.jpg

A "Browse For Folder" dialog will then be displayed. Locate and select the folder you wish to share between the host and guest systems, and click "OK."

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-4.jpg

The selected folder’s path will be populated in the "Folder Path" field. The "Folder Name" will be automatically assigned, though this can be modified as needed. If you wish to prevent modifications within the guest machine, check the "Read-only" box. Selecting the "Auto-mount" checkbox will ensure the folder is automatically mounted upon guest machine startup. Click "OK" to finalize your settings.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-5.jpg

The chosen folder will now appear in the "Folders List." Click "OK" to close the dialog box.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-6.jpg

Accessing the Shared Folder in Ubuntu

Ensure the guest machine remains selected in the VirtualBox Manager. Click "Start" to boot the virtual machine.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-7.jpg

Once the guest machine has started, launch Nautilus (the File Manager) by clicking the file cabinet icon on the Unity bar.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-8.jpg

In the left-hand "Devices" list, click "Computer," then double-click the "Media" folder on the right. A folder with a name prefixed with "sf_" and resembling your selected shared folder will be visible.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-9.jpg

Double-clicking this folder may prompt a dialog box. This indicates a final step is required to gain access to the shared folder.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-10.jpg

Ubuntu utilizes both users and groups. During the installation of the Ubuntu operating system within VirtualBox, a group named "vboxsf" was created. To access shared folders, you must add your user account to this group. Open a Terminal window by pressing Ctrl + Alt + T and enter the following command, replacing "[username]" with your actual username, then press Enter:

sudo adduser [username] vboxsf

You will be prompted for your password; enter it and press Enter again. Confirmation messages will appear as you are added to the group, culminating in a "Done" message.

To close the Terminal window, type "exit" and press Enter.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-11.jpg

To verify your membership in the "vboxsf" group, type "id [username]" (replacing "[username]" with your username) in the Terminal and press Enter. This will display all the groups to which your user account belongs.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-12.jpg

Returning to the "Media" folder, you should now be able to view the files contained within the shared folder on your host machine.

how-to-access-folders-on-your-host-machine-from-an-ubuntu-virtual-machine-in-virtualbox-13.jpg

If the "Read-only" option was not selected during setup, you can directly edit files within this folder. Files can also be copied both to and from the shared folder. If the folder was configured as "Read-only," copying files *from* the folder is permitted, but copying files *into* it is not.

#VirtualBox#Ubuntu#virtual machine#shared folders#host machine#access files