VirtualBox Shared Folders

From Virtuatopia
Revision as of 15:01, 20 March 2009 by Neil (Talk | contribs) (Creating Shared Folders for a Running Virtual Machine)

Jump to: navigation, search

One of the most impressive features of VirtualBox, and virtualization in general, is the ability to run guest operating systems that are completely incompatible with the host operating system. A common requirement in virtualized environments is the sharing of files between the host and guest operating systems. Most virtualization technologies leave this task to the system administrator and, whilst this can be straight forward when the guest virtual machines and host are running the same operating system, it can be become complex when different operating systems are involved. For example, sharing files between a Windows host and a Linux guest involves the installation and configuration of Samba technology and correctly configured network connectivity between the guest and host.

Fortunately, VirtualBox makes the sharing of files between guests and a host system easy through a feature known as Shared Folders.

An Overview of VirtualBox Folder Sharing

VirtualBox Shared Folders allow files residing on the host system to be accessed by guest operating systems running in virtual machines. VirtualBox folder sharing is currently only supported for Windows and Linux guests. Shared folders are not supported on virtual machines running Windows 3.1, Windows 95, Windows Me or Windows 98 guests.

Shared folders can be configured such that are persistent (in other words the share is still configured even if the guest is restarted) or transient such that they a lost after the virtual machine is shutdown or rebooted. Shared folders may also be declared as read-only to prevent the guest operating system from writing to the host folder.

The creation of a shared folder involves selecting the folder on the host system which is to shared, assigning a share name and choosing whether the folder is to be read-only or not.

Creating Shared Folders on a Powered Off Virtual Machine

VirtualBox Shared Folders are configured through the Settings dialog. This dialog is accessed by selecting the desired virtual machine from the list and clicking the Settings button in the toolbar. Once the settings dialog is visible, click on the Shared Folders entry in the right hand pane to display the following screen:

Configuring shared folder settings on a VirtualBox VM

To add a new shared folder, click on the add folder button (the top button containing an icon of a folder with a green plus sign) and select a folder on the host system to be shared with the selected guest. To browse for a specific folder, click the down arrow in the Folder Path text box and select Other... from the drop down menu. Once a suitable folder has been selected, enter a name for the share in the Folder Name field. If the guest operating system is to be denied write access to the folder, ensure that the Read-only check box is selected before clicking the OK button to created the share:

Adding a shared folder to a virtual machine in VirtualBox

Once the shared folder has been configured, start the virtual machine to access the folder. The mechanism for accessing the folder from within the guest will depend on the type of guest operating system running in the virtual machine, details of which are covered later in this chapter.

Creating Shared Folders for a Running Virtual Machine

Shared folders may be configured on a running virtual machine by selecting the Devices->Shared Folders.. menu of the virtual machine window. Once selected, this will display the Shared Folders dialog as illustrated below:

Adding shared folders to a running VirtualBox VM

Accessing a Shared Folder from a Windows Guest

On Windows guests, the shared folder should appear as a standard Windows share listed under VirtualBox Shared Folders, accessible from the Network option in the Start menu. If the shared folder is not visible within the Network window, it may be mapped to a disk drive in a command prompt window by issuing the following command:

net use x: \\vboxsvr\ShareName

where x: represent the drive letter to be mapped to the shared folder, and Sharename is the name assigned to the shared folder during the creation process outlined above. For example, to map a shared folder named TempFiles to the S: drive on the guest operating system and subsequently list the files in the folder:

C:\Users\vbox> net use s: \\vboxsrv\TempFiles
The command completed successfully.

C:\Users\nas>dir s:
 Volume in drive S is VBOX_TempFiles
 Volume Serial Number is 08BA-295C