Tuesday, June 18, 2013

Sharing folder between Guest and Host OS using VirtualBox

For the Big Data training which we provide, very often the question is `how to share folders and hence the data between the host and the guest OS` in regards to the Big Data Virtual Machine (VM).

The first step is to install the VirtualBox Guest Additions in the guest OS (which has to be done only once) and then share the folders. Below are the instructions for Ubuntu as host/guest OS, the instruction are some what similar to other OS also.

1) Start the VirtualBox, select the VM, click on `Settings`, select `Storage`, select `IDE Controller`, click on plus (+) to `Add CD/DVD Device`.

2) Click on `Choose disk` and point to the `VBoxGuestAdditions.iso` file which is a CD image for installing the VirtualBox Guest Additions. This file is in the `/usr/share/virtualbox` on Ubuntu and in the installation folder of VirtualBox on a Windows machine.

The iso should be added under the `IDE Controller` as shown below.

3) Start the VM and the iso should be mounted as shown below in the /media folder.

4) Install the Linux headers using the below command. Admin privileges are required and the user may be prompted for password.
sudo apt-get install linux-headers-$(uname -r)
5) Install the guest additions using the below command.  Make sure that there are no errors.
sudo ./VBoxLinuxAdditions.run
6) Close the terminal and shutdown the VM.

7) Now it's time to share the folders. Select the VM, click on `Settings`, select `Shared Folders` and add the folder path and folder name as shown below.

8) Restart the VM and make the user is part of the vboxsf group using the below command. Logout and login after running the below command.
sudo usermod -a -G vboxsf <username>
9) The shared folder should appear in the VM folder in the `/media` folder as shown below.

Now the data can be copied between the host and the guest OS using terminal, nautilus or some other tool.

No comments:

Post a Comment