Using Virtual Machines

Note: This entire guide in its entirety was kanged from user Redflea who gave his permission to a previous editor.
I apologise if this wrong Original link guide.

Follow the instructions below to install VirtualBox and install Ubuntu in a VirtualBox Virtual Machine (VM) on your PC if you do not want to install Ubuntu in a dual boot setup, or standalone on a PC.

If you are installing Ubuntu along-side Windows in dual boot or standalone, you should not use these instructions.
Follow the Set Up Your Build Environment guide on the left to install dual boot or standalone.

Using a VM to do your builds is like creating a second Linux compatible “PC” on your Windows computer that runs Ubuntu in a window.
Doing builds in Ubuntu running in a VM can be much slower than setting up Linux as dual boot on your PC – my build times went from many hours in a VM on an i5 4GB RAM laptop, to 1 hour on an i7 4GB RAM laptop.
The second laptop is faster, but getting out of a VM was the biggest improvement for me.
However, others have gotten faster build times in a VM, so YMMV.

Creating a VM requires disc space, and you don’t want to use up all available space on your hard drive, so assuming you’re going to dedicate approximately 100GB to this activity, make sure you have that amount + more available (assuming you will want to keep using/adding content to your HD when using Windows).

Install VirtualBox

Run the VirtualBox setup, launch it, and configure per below.

  • Name – whatever you want to call the virtual PC…for example, Ubuntu-10.04.3 since that was the version of Ubuntu being installed.
  • Operating system – Linux
  • Version – Ubuntu

Next window:

- Memory: At least 4GB, recommended 8GB; more on a system with more memory.

The more memory you have on your PC the more you can allocate to the virtual PC before you’ll get a warning from VirtualBox that you are taking too much memory away from your Windows side.

Next window:

  • Select “Start-up disk” and “Create new hard disk:

Next window:

Select VMDK – Virtual Machine Disk (improves compatibility with other tools/SW)

Next window:

Select “Fixed size”

Next window:

Location and size – don’t change location.
Set size to at least 100GB, more if you can spare it.
You can change the size later if you want to, but don’t scrimp on space.
Building can take a lot of room, and VirtualBox will allocate space up to what it needs within the limit you set.

Select create to create the disk and go away for 20 to 30 minutes to allow the program to create the virtual PC.
You’ve created your virtual PC onto which you will install and run Ubuntu. Cool.  :)

But first, before starting your new virtual PC, you have to make a change to a couple settings and then install Ubuntu.
Continue below…

Click on the yellow Settings button (shaped like a gear) and select the Network option.
Select the “Attached to” option and choose Bridged.

Now click on the “Storage” option on the right, and then click on the “Choose a virtual CD/DVD disk file”.

Browse to the Ubuntu ISO file you downloaded way back at the beginning of all this and select it.
This tells VirtualBox to mount the Ubuntu install CD image into the virtual CD drive of the “PC” you just created.
So when you launch your virtual PC the Ubuntu install will run and allow you to install Ubuntu to your virtual PC.

Optional: If you want to be able to access files on your Windows PC from the Virtual PC, now select “Shared Folders” and right-click on Machine Folders and select Add.
Browse to the folder you want to be able to access on your computer from the virtual PC you’re creating, select it, and then select auto-mount so it’s available automatically.
Not so sure about “Permanent” setting…

Select OK to save your changes and then either double-click on your new VM, or click on it and click on the green “Start” button.

Ubuntu in VirtualBox

The VM will launch and after a minute or two (or three) you’ll see the Ubuntu install process begin.

Complete the install (it is much like a Windows install, only shorter/easier, and at the end you’ll restart your PC, referring to, of course, not your “real” PC, but the virtual one on which you’ve just installed Ubuntu.

Ubuntu will boot up and look like this – it will appear in a window in your screen, rather than full screen.
A couple changes to make it available full screen below.

Install Guest Additions to display the VM full-screen

To display the Ubuntu window full screen, you need to install VirtualBox Guest Additions.
Do the following:

At the top of the Ubuntu window, select Devices>Install Guest Additions.

After a few moments a CD icon will appear on your desktop and a dialog box will open (basically, selecting the option on Devices mounted the guest additions install as a virtual CD-ROM).
Select OK to allow the install to complete.

When you’re done, reboot Ubuntu.
Otherwise the changes won’t take effect.
Click on the power button icon in the top right of the window, and your Ubuntu window will display full-screen when you maximize the window.
After you rebooted, right-click on the Guest Additions CD icon and select Eject to remove it from the virtual CD ROM drive.

Now, you have either:

  • Installed VirtualBox, created your VM, and installed Ubuntu in the VM
  • Used the “Set Up Android Build Environment” guide to install Ubuntu in dual boot configuration using an Ubuntu CD you burned from an ISO download.

Next you will setup the Android SDK, install java build tools, create your source code repository and build Android.
Time for the fun stuff… :)

Go to the “Setup Android Build Environment” on the left and start with Step 4.
Download and extract the Android SDK

Content of this page is based on informations from wiki.cyanogenmod.org, under CC BY-SA 3.0 licence.