Tuesday, April 28, 2009

~Install the share folder for Sun VirtualBox

Sometimes, we need to share files between the host and guest OS in the virtual machine. However, how can we achieve it? The followings are steps using the window host and ubuntu guest running in Sun VirtualBox as an example.

(A) Install the Linux Guest additions in the virtual box first.

(a.1) sudo apt-get install dkms
(a.2) mount VBoxGuestAdditions.iso as Linux guest's virtual CD
(a.3) cd /media/cdrom0
(a.4) sudo sh ./VBoxLinuxAdditions-x86.run

(B) Set the share folder of the host by GUI.
select “Shared folders” from the “Devices” menu, or click on the folder icon on the status bar in the bottom right corner of the virtual machine window.


or
(C) Set the share folder of the host by command line.
(c.1) sudo apt-get install virtualbox-ose
(c.2) VBoxManage sharedfolder add "VM name" --name "sharename" --hostpath "C:\temp"
(c.3) For transient VM shares, add the --transient option to the above command line

(D) Mount the host folder to the guest OS.
(d.1) sudo modprobe vboxvfs
(d.2) In a Linux guest, use the following command: sudo mount -t vboxsf sharename mountpoint

Replace sharename (use lowercase) with the share name specified with VBoxManage or the GUI, and mountpoint with the path where you want the share to be mounted on the guest (e.g. /mnt/share). The usual mount rules apply, that is, create this directory first if it does not exist yet.

(E) Your share folder is supposed to work now. :-)

How to clone a virtual machine?

you can simply copy the .vdi file, paste it into a target directory, and then run "VBoxManage internalcommands sethduuid target_vdi" command or "VBoxManage clonehd /path/src_vdi /path/target_vdi -format VDI".

How to enable Clipboard?
VBoxManage --clipboard bidirectional.

 
Delicious Bookmark this on Delicious