SEARCH

How-To Geek

How to Access Folders on Your Host Machine from an Ubuntu Virtual Machine in VirtualBox

00_lead_image_shared_folder

VirtualBox is a program that allows you to run multiple operating systems (guests) on one computer (the host computer). You may need to transfer files between the host and the guest. It’s easy to set up in Windows guests, but tricky in Ubuntu guests.

RELATED ARTICLE
Install Guest Additions to Windows and Linux VMs in VirtualBox
VirtualBox from Sun is a great free virtual machine that lets you run multiple operating systems on your PC. Today we take a look at installing the Guest Additions feature which provides enhanced performance of the guest operating system. [Read Article]

We’ll show you how to set up an Ubuntu guest machine so you can access folders on the host machine from within the guest machine. You must enable shared folders to do this, which are available by installing VirtualBox guest additions software (see our article for instructions on how to do this).

Once you’ve installed the guest additions, enable shared folders by adding a folder from your host machine in the settings for the guest machine. To do this, first make sure the guest machine is powered off. Then, select the guest machine in the list on the left of the VirtualBox Manager and click Settings on the toolbar.

01_clicking_settings

On the Settings dialog box, click Shared Folders in the list of options on the left. On the Shared Folders screen, click the folder button with the plus sign to add a folder.

02_clicking_add_folder

On the Add Share dialog box, select Other from the Folder Path drop-down list.

03_selecting_other

The Browse For Folder dialog box displays. Navigate to the folder you want to share between the host and the guest, select it, and click OK.

04_browsing_for_folder

The path to the selected folder is inserted in the Folder Path edit box. The name of the folder automatically becomes the Folder Name, but you can change this name if you want. If you don’t want to be able to change items in this folder in the guest machine, select the Read-only check box. To have the selected folder automatically mounted in the guest machine when you boot it, select the Auto-mount check box. Click OK once you’ve finished choosing your settings for the shared folder.

05_adding_share

The selected folder displays in the Folders List. Click OK to close the dialog box.

06_shared_folder_added

Now, make sure the guest machine is still selected in the VirtualBox Manager and click Start to boot it.

07_clicking_start

Once the guest machine is booted, open Nautilus (File Manager) by clicking the file cabinet on the Unity bar on the left side of the desktop.

07a_opening_file_manager

In the Devices list on the left, click Computer and then double-click the Media folder on the right. You’ll see a folder named similarly to the folder you selected to share on your host machine with “sf_” added to the beginning of the name.

08_shared_folder_in_ubuntu

If you double-click on that folder, the following dialog box displays. This is because there is one more task to perform before you can access the shared folder.

09_could_not_access_message

In addition to users in Ubuntu, there are also groups. When VirtualBox installed the Ubuntu operating system, it added a group called “vboxsf”. Before you can access any shared folders, you must add yourself to the vboxsf group. To do this, press Ctrl + Alt + T to open a Terminal window. Type the following at the prompt, replacing “[username]” with your username, and press Enter.

sudo adduser [username] vboxsf

Type your password when prompted and press Enter again. Messages display as you are being added to the group and “Done.” displays when the process has been successfully completed.

To close the Terminal window, type “exit” (without the quotes) at the prompt and press Enter.

10_adding_user

To verify you are in the vboxsf group, you can type “id [username]” (without the quotes, and replacing “[username]” with your username) at the prompt and press Enter. All the groups of which the specified user is a member display.

10a_verifying_group_for_user

Now, when you access the shared folder in the Media folder as described above, you should see any files in that exist in that folder on the host machine.

11_access_to_shared_folder

You can edit these files directly in this folder if you DID NOT select the “Read-only” option when selecting the folder in the Settings. You can also copy files into and out of this folder. If the folder was set to “Read-only”, you can only copy files from this folder and cannot copy files into it.

Lori Kaufman is a freelance technical writer who likes to write geeky how-to articles to help make people's lives easier through the use of technology. She loves watching and reading mysteries and is an avid Doctor Who fan.

  • Published 04/30/14