This section describes how to mount the host folder in Linux in VirtualBox to share files between virtual machines and hosts.
Environment: Oracle VM Virtualbox 4.0.10 + CentOS 6.0
1. Install VirtualBox Guest Addition in CentOS
On the current virtual machine interface, click "device"-"Assign Optical Drive"-"Choose a virtual CS/DVD ..."
Open the installation folder of VirtualBox, which defaults to "C: \ Program Files \ Oracle \ VirtualBox", and select "VBoxGuestAdditions. iso" for mounting.
Open the CentOS Super Terminal and run the following command to install VirtualBox Guest Addition.
[Root @ Slyar ~] # Mount/dev/cdrom/mnt
Mount: block device/dev/sr0 is write-protected, mounting read-only
[Root @ Slyar ~] #/Mnt/VBoxLinuxAdditions. run
The first is to mount the disc to/mnt, and the second is to install the disc. Wait until the installation is complete. (If you do not have X desktops like me, the last one may be Failed without any impact)
2. Configure the Data Space
On the current virtual machine interface, click "device"-"allocate data space". In the pop-up interface, add a temporary allocation (fixed allocation is also acceptable, not called)
"Data space location" is your shared folder. Remember the data space name. Do not select "Read-Only allocation" or "Auto-mount ".
3. Restart the Operating System
[Root @ Slyar ~] # Reboot
4. Mount the shared data space
After starting the system, you can use the following command to mount the data space (assuming the data space name is slyar) to/mnt, where "-w" is writable. to read-only, you can change it to "-r"
[Root @ Slyar ~] # Mount. vboxsf-w slyar/mnt
5. unexpected circumstances
If the disk cannot be mounted due to an accident, you can directly access the following directory to use the shared space.
[Root @ Slyar ~] # Cd/media
[Root @ Slyar media] # ls-l
Total usage 0
Drwxrwx --- 1 root vboxsf 0 July 15 15:13 sf_SLYAR
"Sf_SLYAR" is the shared data space folder.
PS. You can try to re-mount the vboxsf module:
[Root @ Slyar ~] # Modprobe vboxvsf