Table of Contents


Herein some tips on using Oractle's VirtualBox, a tool for running system virtual machines. I use it for running Windows, Linux and Android virtually. If you have never used VirtualBox before, you might want to visit the virtualization page in the Cloud section of this site:

Other Elvenware pages about VirtualBox:

Why VirtualBox

We work in VirtualBox in Linux because the tools we use change so often. The technology is more settled than it was two or even one year ago, but it is still subject to unexpected change. Cloud development is new and changing rapidly. We are chasing Proteus, a shape-shifter. The moment we try to pin it down, it morphs again. That's why we can't tell IT: "here, install this on Windows." Even a well written list would be out of date in a month. It feels sometimes like the act of observing a electron, the very act of observing forces it to change! (How? Go out on the web to check to see if you are still using the best tools: almost certainly while checking your list, you will find it needs to be updated.)

The goal here is to learn how to use these tools, to become master of the tools themselves. We should become experts with our configuration tools, which are primarily, but not exclusively, .bashrc, apt-get, git and npm. A tool I use frequently is npm outdated (Links to an external site.). "What libraries that I depend on have changed since I put together this particular package.json file?"

Still, we want to do the best we can to get a stable list, and to learn to adopt to change as it occurs. To help out, I provide:

Pristine Lubuntu, which is 90% of what we need to get our work done. A series of scripts in JsObjects/Utilities (Links to an external site.). For instance, this one (Links to an external site.), which I recently updated (Links to an external site.) to include mocha. There are files on Elvenware such as ConfigureLinux (Links to an external site.) and this on configuring and installing node (Links to an external site.). There is a recent video about configuring Cloud Nine which provides lots of important information. Cloud Nine Video (Links to an external site.)

Another recent video shows changes in the install of Android X86 since I last put such a video together in 2012:

http://youtu.be/qmUcJ2Jxp6g (Links to an external site.)

These videos help to drive the point home: You might want to get set up on Lubuntu, Ubuntu, Cloud Nine, Android, Amazon EC2, Windows, or some other platform. The platform and tools you are expected to use might change at any time. You need to know how to handle these challenges. Demonstrating that you know how to install, and what to install, is a significant part of your grade. If during finals, a good student says: "How do I install mocha?" then I have to wonder whether they have really absorbed the core lessons of this course.

And finally: this is not the Microsoft Windows of yesterday, where every year or two or five a team rolls out a new release. Most of the tools we use ship every two to three months. Important new libraries appear every month or two. Whole new categories of technologies such as server side JavaScript with NodeJs, MVC on the client with AngularJs, fast graphics in the browser with ASM.js and canvas, have all appeared with in the last 2-5 years. The only way to keep up is to stay flexible, and to know how to find, install, and use tools as they become important. That is what this course teaches.

Of course, we also aim to become proficient in JavaScript and building mobile applications. But our ability to know that depends on our knowing how to use the tools that make that kind of development possible.

Install Linux in VirtualBox

Virtual Box Videos you might find useful:

As mentioned earlier, Linux is less resource instensive than Windows. I can boot to the logon screen of the latest Ubuntu desktop (11.10) in about 16 seconds, and can be up and running in a responsive desktop in about 25 seconds. The install takes up about 2.8 GB of disk space. If I install a more minimal command line server edition, I'm at the Ubuntu server command line login prompt in 11 or 12 seconds. The server install required 631 MB of harddrive space. Unless your machine is very underspowered, I would still go with the desktop, at least at first. If you have real performance issues, you can try the server install, outlined below. But remember, the default command line interface for the server is much harder to use than the desktop GUI interface.

Linux in VirtualBox

Figure 08: VirtualBox hosting Ubuntu 11.10 desktop on Windows 7.

I'm going to ask you to do this two times:

Download Ubuntu desktop from their site. Alternatively, download Lubuntu, which works better on underpowered machines. Run the install, much as you did with Android x86. Here is how to proceed:


Pay special attention to the care and feeding of your Windows host machine when you are using it to host a Linux guest. In particular, be sure you have enough resources on your Windows machine to comfortably host Linux in VirtualBox. To check this, use the Task Manager and Resource Monitor:


Here we can see that, even though Lubuntu is running in a VirtualBox VM:

Here we are few minutes later, while running the system updater for Lubuntu:

More work
More work

As you can see, the system is busier:

This is putting more of a strain on the system, but it is not brutalizing it.

Try to run your VMs on machines that can handle the load. If you don't have that option, take special care not to overburden your machine:

The Minimal Server Install for Underpowered Machines

NOTE: I have recently taken a second set of screen shots for the install of Ubuntu Server 12.10. Look at the next section to see these screen shots.

Most users should install the Ubuntu desktop, as it is quite fast. But if you have a very underpowered machine, or if you want a small image for quick cloning and updating, or if you just prefer the server, then here is how to install it.

Note: If you are using Ubuntu on EC2, then you are probably already familiar with the server version. The main distinction to note, of course, is that the Desktop version has a GUI front end, while the server version is, at least by default, command line only. This is done primarily for security reasons: the command line is simply much harder to hack than the GUI. However, if you are open up a terminal Window in the Desktop version, then you are, for all practical purposes, at the server command line. The desktop version is simply the server with a GUI front end. There are no fundamental differences in the architecture of the two releases. To put it another way, everything that you can do at the server command prompt you can also do at the desktop command prompt, and vice versa.

Download the Server cd from the Ubuntu site. Set everything up as you did with Android, except choose 512MB for your memory and make the virtual hard drive 2 GB, or 1 GB if you really want to save space.

When you get to the first log in screen press escape to make the prompt for English go away. Then press F4 and choose Install a Minimal System. (The option to install a minimal virtual system worked for me with the Server 10.04 LTS, but not with the most recent build. We should probably use the latest bits, so choose Install a Minimal System.)

Server Install Small

Figure 9: Choose Install minimal system, and don't select minimal virtual machine. On my system, minimal virtual machine caused errors though ymmv.

You will then be taken through a series of prompts about the keyboard. Just keep choosing USA. You will be prompted for a server name, which is pretty much up to you. I named mine Tiny.

You will then be asked about your time zone. If you are on the network, which you should be by this time in the install, then it should properly guess your location.

Small Time Check

Figure 10: Confirm the time.

When you come to the screen about Partitioning disks, choose Guided - use entire disk.

Guided install

Choose Partition disks.

Make sure you are working with you XX GB ATA VBOX HARDDISK and choose Guided partitioning. Just keep accepting the default values. When it asks if you want to write changes to disk, choose yes.

You will reach a screen called Installing the base system.That process will take a few minutes, and then you will be asked to enter your full name, then a user name, then a password.

I did not choose to encrypt my home directory, and I needed no proxy information.

The next step is called Configure apt, which is a Linux installer and configuration tool that works from the command line. I choose not to accept automatic updates. At the software selection page, I choose to install nothing more, since I want this to be an absolutely minimal install. You need not make such a spartan selection. If you are an expert at the Linux install, then you can choose Manualpackage selection. I just tabbed down to the Continue button.

Small Packaged Selection

Because you have apt installed, you will be able to install more software later, so this is not quite as drastic a step as it might at first seem. (Also, it is possible that the "Basic Ubuntu Server" option is a bug, and should not be visible on the screen.)

I choose to install GRUB. Then they asked me to reboot. The ISO file was removed automatically, and a few seconds later I was at the command prompt, signing in.

Ubuntu Server 12.10 Install

Ubuntu Server Install Step 01
Ubuntu Server Install Step 01
Ubuntu Server Install Step 02
Ubuntu Server Install Step 02
Ubuntu Server Install Step 03
Ubuntu Server Install Step 03
Ubuntu Server Install Step 04
Ubuntu Server Install Step 04

Figure 0X: If the install can't set up your DHCP server, then you have a serious problem. Stop everything, and go back and think about DHCP.

Ubuntu Server Install Step 05
Ubuntu Server Install Step 05

Figure 0X: Pick a name for your server. Since you will possibly be installing multiple VirtualBox hosted server VMs, it is often a good idea to pick a name you like, then number each VM instance, 01, 02, etc. Since this is first server VM installed on this physical machine, I'm numbering it 01. If I install a second VM with Ubuntu Server, I'll number it 02, etc.

Ubuntu Server Install Step 06
Ubuntu Server Install Step 06

Figure 0X: You should, of course, enter your own name. This is not where you are picking your user name. This is where you enter your full name, if you want to do that. In the next step, my first name is used by default as my user name.

Ubuntu Server Install Step 07
Ubuntu Server Install Step 07

Figure 0X: Using LVM can be a mistake when installing to a physical drive. Perhaps in this case it is not quite so dire, but I am playing it safe and skipping the LVM. If you are interested, there is a good deal of documentation of LVMs on the web. It is a nice feature, but not needed here.

Ubuntu Server Install Step 08
Ubuntu Server Install Step 08

Figure 0X: In the screen before this one, you had a chance to pick only one partition, which is called VBOXxxxx. Really, nothing can go wrong on this step, but I'm showing you this screen shot just to reassure you.

Ubuntu Server Install Step 09
Ubuntu Server Install Step 09
Ubuntu Server Install Step 10
Ubuntu Server Install Step 10

Ubuntu Mini Install

The Ubuntu Mini distributions just gives you a small, core set of files. This means your download size is very small, about 1/10 the size of the regular download. It then allows you to decide what flavor of installation you want. Do you want server? Do you desktop? How about Lubuntu? And so on. It is up to you. Of course, the rest of the files will then be downloaded during the install, but on balance, this ends up being faster. This is particularly true for corporate or educational desktops that put you through a rigorous scanning process whenever you download anything.

Here is the download site:


The install is the same as for the server, which is shown above. The only difference is in the software selection screen, which is shown below.

Ubuntu Mini Software Selection Screen View 01
Ubuntu Mini Software Selection Screen View 01

Figure 0X: Ubuntu Mini Software Selection Screen View First Half

Ubuntu Mini Software Selection Screen View Continued
Ubuntu Mini Software Selection Screen View Continued

Figure 0X: Ubuntu Mini Software Selection Screen View Continued

Notice that you are given a wide range of selection, including Kubuntu, Edubuntu KDE, Lubuntu minimal, etc.

Install Guest Additions

The Guest Additions provide better integration between your host OS (usually Windows) and your Guest VM (usually Linux). For instance, they help support:

As of VirtualBox 4.1.14, the below may not be necessary. It seems as if we now only need to select Install Guest Editions from the menu and they should be installed automatically, though a reboot is still necessary after the installation completes.

There are several ways to install the guest additions. Here is one:

  1. From the VirtualBox menu at the top of your VM, choose Devices | Insert Guest Additions CD image.
  2. Navigate to your /media/$USERNAME/VBOXADDITIONS_XXX folder. This folder should have been created during the previous step.
  3. For instance: /media/charlie/VBOXADDITIONS_4.3.6_91406
  4. Execute this file: VBoxLinuxAdditions.run. Like this sudo ./VBoxLinuxAdditions.run.
  5. After the program completes, it is probably a good idea to reboot, though that is not always necessary.

Here is another solution that works in Lubuntu:

  1. Open Software Updater.
  2. Click the Additional Drivers tab in Software & Updates.
  3. Select "Using x86 virtualization solution - guest addition module source for dkms from virtualbox-guest-dkms (proprietary)".
  4. Click Apply Changes.

Nevertheless, I will keep the steps outlined below in this document in case someone finds them helpful, perhaps because they are working with an older version of VirtualBox.

If you are running Ubuntu or Lubuntu desktop inside VirtualBox, one of the first things you want to do is install the Guest Addtions.

When you are done, reboot. Now when you can go into full screen mode the Linux desktop should fill your entire screen, as if you had booted directly into Linux. (Switch to full screen mode by pressing Right-Ctrl-F.) If you are not in full screen mode, and you resize your Linux window, now your VM desktop should stretch to fit the window. If this fails, see the instructions below for installing on the server. It should work on any platform.

The VirtualBox Additions on Ubuntu Server

I have used these instructions not only on server, but the lubuntu desktop. So they might work if some of the more manual installs don't work. First this long, but easy to use command:

sudo apt-get install virtualbox-ose-guest-utils virtualbox-ose-guest-x11 virtualbox-ose-guest-dkms

If that doesn't work, then try this longer process:

apt-get install dkms build-essential linux-headers-generic

You may also need to run this:

sudo apt-get install linux-headers-2.6.32-33-server

Then I used the Device menu to insert the VBox additions. Next I did this:

mount /dev/scd0 /media/cdrom

And finally, I was able to run VBox additions install

sudo sh VBoxLinuxAdditions-x86.run

Or run the amd64 additions if that is appropriate.

You may have to reboot, but at this stage, you should be able to run OpenBox, press Ctrl-F, and enter Full Screen mode.

Share Clipboard

If you have Linux installed in a VirtualBox VM you can can share the clipboard between Windows and Linux. This means you can cut and paste between Windows and Linux.

In the VirtualBox Manager, choose Settings for your Linux VM. Go to the General | Advanced page. See the Shared Clipboard to Bidirectional. Press OK. Now you can cut and paste between Windows and Linux.

(You may need to install the Guest Additions before this will work?)

Set up shared clipboard
Set up shared clipboard

Dual Screen Mode

If you have multiple monitors on your system, you will probably want to take advantage of them both. With Ubuntu Desktop and VirtualBox, this is easy.

Now you should have a main desktop, and a second desktop in the second window. You can go into full screen, and choose Host + Home to confiure the two monitors.

Dual Screen

Figure 00: The displays window with two mirrored displays. You can tell the Guest Additions are installed because of the label VBox.

Port Forwarding

By default, VirtualBox sets up a Nat confiruation for your Linux installation. If you set up Port Forwarding, then your Linux Box appears as simply an extension of your host machine. Suppose you have a Windows host machine, and Linux set up in VirtualBox. Then with Port Forwarding, things like the Linux Web Server or SSH server appear to be part of your Windows host machine, but running on a different port. For instance, you would browse to the Web Server on your Linux box by typing something like:


Here is how to set up Port Forwarding. It is not necessary to close your Linux VirtualBox VM when doing this. Choose Machine | Settings from the VirtualBox menu. Setlect the Network page. Click the Port Forwading button. Enter the following:

Port Forwarding
Port Forwarding

Now you are all set. Just launch your browser in your Windows Box and type http://localhost:8000

You did the right thing, it is probably best to use Bridged Adapter when you can.


Bridged Adapter:

Port Forwarding and ADT

To connect from ADT Cordova/PhoneGap in situations where network is funky:

Now save and run the VM. Now you can connect via:

adb connect localhost:5555

This works, as I say, even when Bridged Adaptor will not work for one reason or another.

Resize a VDI Virtual Disk

Sometimes you might find that you did not plan ahead for all contingencies, and suddenly you find your are out of hard drive space. Fortunately, this is an easy problem to resolve if you have been following the usual steps outlined in these pages.

VirtualBox comes with some very handy utilities that perform many important tasks. One of the most useful tools is VBoxManage. One of its many useful features is the ability to resize a hard drive.

Here is what it looks like when you issue the command

J:\>"c:\Program Files\Oracle\VBox\VBoxManage.exe" modifyhd UbuntuSmallest.vdi --resize 10240

Here are the options you can pass to modifyhd:

VBoxManage modifyhd <uuid> | <filename>
[--type normal | writethrough | immutable | shareable | readonly|multiattach]
[--autoreset on|off]
[--resize <megabytes> | --resizebyte <bytes>]

You can specify the new size in either megabytes or bytes. In the example shown above we are passing 10,240 MB, which is the same as 10 GB. This means the new drive will be 10 GB in size.

After doing this, you will still need to resize the partition. There may be a simpler way, but I ended up:

  1. Shutting down the server
  2. Using VirtualBox to load the settings for VM,
  3. Turning to the Storage page, and inserting an ISO image for Ubuntu Desktop.
  4. I restarted the machine. This time Ubuntu booted up into the Live CD image. There was an option to "Try Ubuntu" and I selected that option. I was then automatically booted into Ubuntu Live CD image.
  5. In the live image I went to a terminal window and loaded gparted: sudo gparted.
  6. I then turned off swap and deleted it.
  7. I unmounted the main drive, and repartitioned the system. In my case, I temporarily deleted Swap, then resized my main drive, then created swap again on an extended partition.

modifyhd: Step one is prepare to launch the Ubuntu Live CD

Figure01: Prepare to launch the Ubuntu Live CD. Click to enlarge.


Figure 02: Running the Live CD with GParted in the foreground, the terminal window in the background.

Modify image

Figure 2.5: Here we have the original partition resized to take up all the new space, and we have completed deleted the swap partition.

After resizing the disk

Figure 03: After the rain the drive is resized and the swap file recreated.

Don't forget to reboot your system and remove the LiveCD from the Settings | Storage window. Actually the DVD should have been removed automatically, but check just to make sure. Then relaunch your image and you should find that you now have free drive space.

Here is a link to an alternate solution:


Sometimes SwapOn is not turned on. Open this file:

sudo nano /etc/fstab

Read about blkid and make sure the long numbers match up. After fixing them up, you will need to reboot.

A System Panel (TaskBar)

I'm currently experimenting with tint2.

sudo apt-get install tint2

After the install, I ran tint2, and the taskbar appeared at the bottom of my screen.

Sharing Folders Between Windows a Virtual Linux Machine

To share a Windows folder with Linux Virtual Machine, and to copy files back and forth, do the following:

Shared Folders Linux VM in Windows Host

Figure 04: Shared Folders Linux VM in Windows Host. (Click to enlarge)

Now make yourself a member of the vboxsf group.

sudo usermod -a -G vboxsf charlie

Before things will work, you will probably have to reboot your VM.

Creating a Shared Folder
Creating a Shared Folder

If you are not a member of voboxsf, you will have to go to a terminal window, and to use sudo cp commands to move files in and out of the shared folder. After copying a file from the folder into your Linux home directory, use chmod 777 myfile.txt to get ownership of the file. Here I copy a file from my shared folder into the media directory, take control of it, edit it, and copy it back:

sudo cp sf_TempMS/log.txt .
chmod 777 log.txt 
gedit log.txt
sudo cp log.txt sf_TempMS/log01.txt 

Remember that one way to start Nautilus (the Linux File Explorer) in super user mode looks like this:

sudo nautilus

Bit rather than worry about sudo permissions and super user mode, just become a member of vboxsf.


Snapshots allow you to mark the state of a VM so that you can return to that state later. This does not make a copy of you VM, it just provides a spot to which you can return.

If you make a snapshot while you are logged on, then you will be returned to that location when you open the snapshot. This means that you won't be prompted for a user name and password. This can be either a good thing or a bad thing, depending on your security concerns.

Clone VM

You can clone VM, thereby creating an exact copy of a new VM. When cloning, be sure to reset the MAC address.

Copy a VDI

Right click on the VDI, then copy it to a new location, now run the VBoxmanager internalcommands sethduuid command against your copy of the VDEI:

VBoxManage internalcommands sethduuid [MY VDI FILE].vdi

In practice, it might look like this:

+>"C:\Program Files\Oracle\VirtualBox\VBoxManage" internalcommands sethduuid Lubuntu.vdi
UUID changed to: 241ffc40-9874-4137-86e2-cbed936ee4fd

Now create a new VM. This time, instead of create a new VDI, use the one you have copied.