Saturday, December 3, 2011

Ubuntu installation in VirtualBox and set up Shared folder with host

Helping LA has made me realize that I need to document this procedure for archival purposes. I will try to make this as detailed as possible. Hopefully, I don't miss any steps. If I do, anybody can send an email to me.

Host OS: Windows 7 Home Premium  64-bit (HP laptop), CPU-i7 quad core @  2GHz, 8GB RAM
VM: Oracle's Virtualbox (VB)
Guest OS: Ubuntu

Installation of Ubuntu:
1) Download ubuntu .iso file. I downloaded the 64-bit (amd64).
2) Download VirtualBox. After installation, got through the wizard to install Virtualbox. En route, you will see these prompts:
a) OS Type: OS=Linux, Version=Ubuntu
b) Memory: Depending on how extensive you are going to use VB, I put about a quarter of my RAM. You can adjust it later anyway, so don't dawdle here.
c)  Create new hard disk -> with Dynamically expanding storage -> give it a name and half size for me (~4GB).

3) These should bring you to the end of the installation. Now, you need to additionally customize your VM environment. Open VB, right-click on your Ubuntu, click 'Settings'.
a) System > Processor: 1 CPU for now. We will increase it later. KIV.
b) System > Acceleration: ensure that Hardware virtualization options are checked in both 'Enable VT-x/AMD-V' and 'Nested Paging'.
c) Storage > Storage Controller > Empty > Right panel: click 'browse' and find the Ubuntu ISO you downloaded in (1).

4) Double click on ISO to initiate VM. Install Ubuntu (not 'try'). Follow wizard.

**Watch this video on Jane Talks Tech for a more visual and detailed demonstration of a 32-bit Ubuntu installation.

Everything else should be kept default. Until this point, this is the normal procedure for all installations (32- and 64-bit).


1) You need to restart the computer and enter the BIOS. To enter BIOS, reboot the computer, press 'Delete' button.

2) After you enter the BIOS, find Advanced BIOS settings > Virtualization > Enabled. Remember to 'Save and exit'. Most new processors should be capable of this function, make use of it.

3) After you log into host, restart VB. Go Settings > System > Processor. I set to 4 out of my 16 CPUs.


Set this up to allow access of host files from the guest system.
1) Create a folder, name of your choice. For illustration purpose, the path of my folder is "C:\Shared".
2) Open VB, go Settings > Shared Folders. Click on the 'Add folder' icon, key in the path, and the folder name. Checking 'read-only' means you will not be able to change anything from the guest machine - guest can only 'download'. A good picture, refer to this website:

3) Open a terminal. Type in command:
sudo apt-get install build-essential linux-headers-'uname -r'
This installs some software not installed by default.

4) Start VM and login. Select Devices > CD/DVD Devices > VBoxGuestAdditions.iso
This ISO contains an image of a DVD that contains essential files. Mount this image (something like putting in a virtual CD/DVD into a virtual drive). Run the image using:
sudo /cdrom/
5) You might need to restart the VM.
6) Finally, mount the Shared folder. Open a terminal, type command:
sudo mount -t vboxsf Shared ~/my-shared-foldername-on-guest-OS

7) Check that you have that on your home directory. Put something in that folder on the host and see if you can transfer it to your guest.

8) IMPT: Do not close the terminal. FYI, the above has to be mounted every time you log into Ubuntu, much like an external harddrive. To do this automatically, open this file:
sudo vi /etc/init.d/rc.local
Edit this by adding the "sudo ..." line to the second last line, just before "exit 0;".
Then save and exit (:wq).

9) Close and reopen the terminal. You should see the folder still there.

No comments: