Changes

Jump to: navigation, search

VirtualBox Shared Folders

4,481 bytes added, 15:53, 20 March 2009
Accessing a Shared Folder from a Linux Guest
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 In addition, assuming adequate permissions are not supported granted on virtual machines running Windows 3.1the shared folder, Windows 95, Windows Me or Windows 98 gueststhe guest is also able to transfer files onto the host by copying them into the shared folder.
VirtualBox folder sharing is currently only supported for Windows and Linux 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 not supported on virtual machine is shutdown machines running Windows 3.1, Windows 95, Windows Me or rebooted. Shared folders may also be declared as read-only to prevent the guest operating system from writing to the host folderWindows 98 guests.
Shared folders can be configured such that they 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 be to shared, assigning a share name and choosing whether the folder is to be read-only and transient or notpermanent.
== Creating Shared Folders on a Powered Off Virtual Machine ==
VirtualBox Shared Folders on inactive virtual machines 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:
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 create the share:
== Creating Shared Folders for a Running Virtual Machine ==
Shared folders may be configured into on a running virtual machine via by selecting the ''Devices->Shared Folders..'' menu of the virtual machine window.Once selected, this will display the ''Shared Folders'' dialog as illustrated below:  [[Image:virtualbox_shared_folders_running_vm.jpg|Adding shared folders to a running 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.  If the share is to be transient (in other words it will not be restored when the virtual machine is restarted) leave the ''Permanent'' check box unselected before clicking the ''OK'' button to create the share. == Creating and Removing Shared Folders from the Command Prompt == VirtualBox shared folders can be created from the command prompt using the ''VBoxManage'' command-line tool on the host. VBoxManage is installed by default on Windows hosts in C:\Program Files\Sun\xVM VirtualBox and in /opt/VirtualBox on Linux. The syntax to create a shared folder using VBoxManage is as follows:  :<tt>VBoxManage sharedfolder add "<virtual machine>" -name "<share name>" -hostpath "<host path>"</tt>  where ''<virtual machine>'' is the name of the virtual machine to which the shared folder is to made available, ''<share name>'' is the name to be assigned to the share and ''<host path>'' is the path to the folder on the host file system. For example to make ''C:\Temp'' on the host system a shared folder named ''MyShare'' available to a virtual machine named ''Fedora 10'', the following command would need to be executed: <pre>vboxmanage sharedfolder add "Fedora 10" -name "MyShare" -hostpath "C:\Temp" VirtualBox Command Line Management Interface Version 2.1.4(C) 2005-2009 Sun Microsystems, Inc.All rights reserved.</pre> Note that the target virtual machine must be power off before the command is executed. Failure to meet this requirement will result in output similar to the following: <pre>[!] FAILED calling a->virtualBox->OpenSession(a->session, uuid) at line 4233![!] Primary RC = VBOX_E_INVALID_OBJECT_STATE (0x80BB0007) - Current object state prohibits operation[!] Full error info present: true , basic error info present: true[!] Result Code = VBOX_E_INVALID_OBJECT_STATE (0x80BB0007) - Current object state prohibits operation[!] Text = A session for the machine 'Fedora 10' is currently open (or being closed)[!] Component = Machine, Interface: IMachine, {ea6fb7ea-1993-4642-b113-f29eb39e0df0}[!] Callee = IVirtualBox, {339abca2-f47a-4302-87f5-7bc324e6bbde}</pre> To resolve this problem, power off the virtual machine and repeat the command. The previously created shared folder may be removed using the VBoxManage tool as follows: <pre>C:\Program Files\Sun\xVM VirtualBox>vboxmanage sharedfolder remove "Fedora 10" -name "MyShare" VirtualBox Command Line Management Interface Version 2.1.4(C) 2005-2009 Sun Microsystems, Inc.All rights reserved.</pre>
== Accessing a Shared Folder from a Windows Guest ==
On Windows guests, the shared folder should appear as a standard Windows network 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(as can sometime be the case), it may be mapped to a disk drive in a command prompt window by issuing the following command:
net use ''x:'' \\vboxsvr\''ShareName''
:<tt>net use <drive>: \\vboxsvr\<share name></tt>  where ''x<drive>:'' represent represents the drive letter to be mapped to the shared folder, and ''Sharename'' <share name>> 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:
<pre>
C:\Users\vbox> net use s: \\vboxsrv\TempFiles
The command completed successfully.
</pre>
== Accessing a Shared Folder from a Linux Guest ==
CShared Folders are accessed on Linux guests by mounting the folder at a suitable mount point using the ''mount'' command. This can either be an existing directory, or a new directory may be created specifically for this purpose. The syntax to perform the mount (which must be performed as super-user or using the ''sudo'' command) is as follows:\Users\nas>dir s  :<tt>mount -t vboxsf [-o ''MOUNT OPTIONS''] ''ShareName MountPoint''</tt> Volume in drive S is VBOX_TempFiles Volume Serial Number where [-o ''MOUNT OPTIONS''] represents any optional directives to the mount command, ''ShareName'' is 08BAthe name assigned to shared folder when it was created and ''MountPoint'' is the path to the directory on the guest where the shared folder is to be mounted. For example, to mount a shared folder named ''TempFiles'' using ''/tmp/mnt'' as the mount point: <pre>mkdir /tmp/mntmount -295Ct vboxsf TempFiles /tmp/mnt
</pre>
 
Once this command has been executed, the files in the host folder will be accessible in /tmp/mnt.
1,798
edits

Navigation menu