第二步:在虛擬機設置界面,點擊共享文件夾(Shared folders),使用自動掛載方式添加共享文件夾
第三部:安裝VirtualBox自帶的增強功能,運行虛擬機後,在設備–安裝增強功能
第四步:重啟虛擬機,在/media目錄中出現sf_Share目錄,此目錄中為共享文件夾
第二步可能出現如下錯誤
翻閱網絡和VirtualBox幫助文檔中發現, 安裝增強功能前需要加載VBoxGuestAdditions.iso,默認安裝完ubuntu時,ubuntu的安裝程序加載在光驅中,導致VBoxGuestAdditions.iso無法加載。
解決方案:卸載掉ubuntu的安裝程序包,重新點擊安裝增強功能既可以實現加載及安裝。
第四部可能出現如下錯誤
查閱資料發現,VirtualBox自動掛載,此文件夾的用戶組別為vboxsf,增加當前用戶到vboxsf用戶組中;重啟虛擬機,當前用戶可以正常訪問共享文件夾。
VirtualBox幫助文檔介紹(版本:5.0.12.r104815)
3.11. Shared folders Shared folders allow you to easily exchange data between a virtual machine and your host. This feature requires that the VirtualBox Guest Additions be installed in a virtual machine and is described in detail in Section 4.3, “Shared folders”.
4.1. Introduction ....... The VirtualBox Guest Additions for all supported guest operating systems are provided as a single CD-ROM image file which is called VBoxGuestAdditions.iso. This image file is located in the installation directory of VirtualBox. To install the Guest Additions for a particular VM, you mount this ISO file in your VM as a virtual CD-ROM and install from there.(使用光盤加載方式加載VBoxGuestAdditions.iso) The Guest Additions offer the following features: ...... Shared folders(共享目錄) These provide an easy way to exchange files between the host and the guest. Much like ordinary Windows network shares, you can tell VirtualBox to treat a certain host directory as a shared folder, and VirtualBox will make it available to the guest operating system as a network share, irrespective of whether guest actually has a network. For details, please refer to Section 4.3, “Shared folders”. ......
`4.3.2. Automatic mounting
Starting with version 4.0, VirtualBox can mount shared folders automatically, at your option. If automatic mounting is enabled for a specific shared folder, the Guest Additions will automatically mount that folder as soon as a user logs into the guest OS. The details depend on the guest OS type:
With Windows guests, any auto-mounted shared folder will receive its own drive letter (e.g. E:) depending on the free drive letters remaining in the guest.
If there no free drive letters left, auto-mounting will fail; as a result, the number of auto-mounted shared folders is typically limited to 22 or less with Windows guests.
With Linux guests, auto-mounted shared folders are mounted into the /media directory, along with the prefix sf_. For example, the shared folder myfiles would be mounted to /media/sf_myfiles on Linux (linux系統中自動掛載在/media目錄中,在共享目錄前加上sf_前綴,如共享目錄為myfiles,則在linux中掛載的目錄為/media/sf_myfiles)and /mnt/sf_myfiles on Solaris.
The guest property /VirtualBox/GuestAdd/SharedFolders/MountPrefix determines the prefix that is used. Change that guest property to a value other than “sf” to change that prefix; see Section 4.7, “Guest properties” for details.
Note
Access to auto-mounted shared folders is only granted to the user group vboxsf, which is created by the VirtualBox Guest Additions installer. Hence guest users have to be member of that group to have read/write access or to have read-only access in case the folder is not mapped writable.
To change the mount directory to something other than /media, you can set the guest property /VirtualBox/GuestAdd/SharedFolders/MountDir.
Solaris guests behave like Linux guests except that /mnt is used as the default mount directory instead of /media.`