设为首页 收藏本站
查看: 762|回复: 0

[经验分享] [转]Virtualbox Share Folder的设置

[复制链接]

尚未签到

发表于 2016-1-10 12:25:48 | 显示全部楼层 |阅读模式
  原文链接:http://www.virtuatopia.com/index.php/VirtualBox_Shared_Folders
  
  
  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 asShared 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. In addition, assuming adequate permissions are granted on the shared folder, the 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 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 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 permanent.
  

Creating Shared Folders on a Powered Off Virtual Machine
  VirtualBox Shared Folders on inactive virtual machines are configured through theSettingsdialog. This dialog is accessed by selecting the desired virtual machine from the list and clicking theSettingsbutton in the toolbar. Once the settings dialog is visible, click on theShared Foldersentry 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 theFolder Pathtext box and selectOther...from the drop down menu. Once a suitable folder has been selected, enter a name for the share in theFolder Namefield. If the guest operating system is to be denied write access to the folder, ensure that theRead-onlycheck box is selected before clicking theOKbutton to create the share:
  

  
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 theDevices->Shared Folders..menu of the virtual machine window. Once selected, this will display theShared Foldersdialog as illustrated below:
  

  
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 theFolder Pathtext box and selectOther...from the drop down menu. Once a suitable folder has been selected, enter a name for the share in theFolder Namefield. If the guest operating system is to be denied write access to the folder, ensure that theRead-onlycheck 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 thePermanentcheck box unselected before clicking theOKbutton to create the share.
  

Creating and Removing Shared Folders from the Command Prompt
  VirtualBox shared folders can be created from the command prompt using theVBoxManagecommand-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:
  

VBoxManage sharedfolder add "<virtual machine>" -name "<share name>" -hostpath "<host path>"  
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 makeC:/Tempon the host system a shared folder namedMyShareavailable to a virtual machine namedFedora 10, the following command would need to be executed:

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.

  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:

[!] FAILED calling a->virtualBox->OpenSession(a->session, uuid) at line 4233!
[!] Primary RC  = VBOX_E_INVALID_OBJECT_STATE (0x80BB0007) - Current object stat
e prohibits operation
[!] Full error info present: true , basic error info present: true
[!] Result Code = VBOX_E_INVALID_OBJECT_STATE (0x80BB0007) - Current object stat
e prohibits operation
[!] Text        = A session for the machine 'Fedora 10' is currently open (or be
ing closed)
[!] Component   = Machine, Interface: IMachine, {ea6fb7ea-1993-4642-b113-f29eb39
e0df0}
[!] Callee      = IVirtualBox, {339abca2-f47a-4302-87f5-7bc324e6bbde}

  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:

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.

  

Accessing a Shared Folder from a Windows Guest
  On Windows guests, the shared folder should appear as a standard Windows network share listed underVirtualBox Shared Folders, accessible from theNetworkoption in theStartmenu. 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 <drive>: //vboxsvr/<share name>  
where<drive>:represents the drive letter to be mapped to the shared folder ([博主]注:就是你希望该文件夹在Windows中显示的磁盘符,不应该与虚拟机中已有的Windows磁盘符相冲突。)and<share name>> is the name assigned to the shared folder during the creation process outlined above. For example, to map a shared folder namedTempFilesto the S: drive on the guest operating system:

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

  

Accessing a Shared Folder from a Linux Guest
  Shared Folders are accessed on Linux guests by mounting the folder at a suitable mount point using themountcommand. 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 thesudocommand) is as follows:
  

mount -t vboxsf [-oMOUNT OPTIONS]ShareName MountPoint  
where [-oMOUNT OPTIONS] represents any optional directives to the mount command,ShareNameis the name assigned to shared folder when it was created andMountPointis the path to the directory on the guest where the shared folder is to be mounted. For example, to mount a shared folder namedTempFilesusing/tmp/mntas the mount point:

mkdir /tmp/mnt
mount -t vboxsf TempFiles /tmp/mnt

  Once this command has been executed, the files in the host folder will be accessible in /tmp/mnt.
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-162519-1-1.html 上篇帖子: virtualbox下安装ubuntu11.10 server 下篇帖子: Ubuntu: WinXP + VirtualBox +Ubuntu 建立WinXP嵌入式开发环境
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表