Installing Ubuntu in VirtualBox on a Windows 7 Host

It’s Sunday afternoon and Deb is feeling poorly…but not so poorly that she’s not offering considerable editorial input into this post. In between the sniffles and requests for lemsip etc…she’s throwing in various comments relating to various icons from the sci-fi genre. To be fair, I have borrowed her laptop as it’s the only one in the house running Windows 7.
I will attempt to minimize the in-jokes and references but I thought I’d better go on record and report the fact that I am under some duress here. Honestly, some people are soooo geeky !

What I want to do in this post is to go through :

  • setting up VirtualBox and running Ubuntu as a guest os
  • getting the Guest desktop to display in a full screen
  • getting the Number Keypad to work in the VM
  • setting up a directory so that files can be shared between guest and host

The Three Laws

Just a quick note about terminology.
Host – is the Windows 7 OS that we’re going to install all this stuff on
Guest – is the Ubuntu machine that we’re going to be running in the Virtual Machine

To boldly go…

The first steps in our brave new (virtual) world ( don’t worry, she’s got to go to the loo sometime), is to install the Oracle VirtualBox VM. You can get it from here.

Next, we need to get a copy of Ubuntu. Best bet is to use the latest Long-Term Support version ( currently Ubuntu 10.04.2) from here.

Just follow the wizard steps to install VirtualBox.

When you configure the new VM through the wizard, select the appropriate Operating System ( in this case, Linux) and Version (Ubuntu) then accept all of the other defaults for now.

It's just an empty shell...for now

When you actually start the new VM for the first time, you’ll be presented with the First Run Wizard. Moving swiftly on ( before Deb gets in with any Harry Potter references), you’ll get a screen asking you to Select Installation Media.
Just select the Ubuntu iso you downloaded earlier.

A Wizard's Staff has a knob on the end...

Once you get Ubuntu desktop up, then click the install icon on the desktop. Note – at this point, you’re Numeric Keypad will not be working. We’ll fix this a bit later, but for now, you need to use the number keys above the letters on your keyboard.
Once you’ve done this, you need to make sure that the virtual cd/dvd is removed from the virtual cd/dvd drive before you virtually re-start the virtual machine. Hmmm, no response. Somehow I think she may not have seen Tron.
Anyway, the easiest way to do this is to go to the VirtualBox Devices Menu, select CD/DVD Devices / Remove Disk From Virtual Drive
When you reboot, you should now be running the installed version of Ubuntu and not just the live CD image in the VM.

We can rebuild him….

Moving swiftly on from Deb’s musings on the subject of exactly which bits of Steve Austin were bionic, the next step is to install Guest Additions in Ubuntu.
Before doing this it’s a good idea to run Update Manager in the Ubuntu guest ( System / Administration / Update Manager). This is because, if you have a linux kernel update, it does tend to mess up the Guest Additions installation and require a re-install.
With Ubuntu up and running in the VM, go to the VirtualBox Devices Menu and select Install Guest Additions.
This should load a CD into the virtual drive. You then need to navigate to the cd in Nautilus ( Places / Computer/ CD/DVD Drive) and then click When prompted, just click the Run button.

Once the installation is complete, do a shutdown of the virtual machine ( removing the virtual CD/DVD first).

Virtually removing the virtual disk

I canna change the laws o’ physics

However, we can now start to address some of the issues with which we are currently faced.

First up is getting the Ubuntu Guest to display fill-size in fullscreen mode. This is especially useful if you happen to have two monitors at your disposal as you’ll be able to use one for the host and one for the guest.

With Ubuntu shut down, amend the Display settings for the VM in VirtualBox. The Video Memory should be set to 64MB and the Enable 3D Acceleration checked.

amend the display settings

Now, when you go into the Ubuntu System Menu and select Preferences / Monitor, Ubuntu should recognize the monitor type VBX. Additionally, you’ll also be able to increase the resolution to something in-line with what’s running on the host.

Once these changes have been made, switching the VM to fullscreen mode ( VirtualBox Menu, Machine / Fullscreen) should now result in the desktop taking up all of the available real-estate.

The Numeric Keypad can also be enabled by means of settings in the Ubuntu System/Preferences Menu. This time, go to Keyboard.
First of all, in the Mouse Keys tab, uncheck Pointer can be controlled using the keypad.

Secondly, in the Layouts tab, click Options… and under Numeric Keypad Layout Selection check Legacy. The Number pad should now work.

Ubuntu Keyboard settings

Sub-space transmissions

Although the clipboard is set to be bi-directional by default, it would seem that, with the Win7 host / Ubuntu guest combination at least, you can only cut and paste from the Host to the Guest and not the other way around.

You can, however, set one or more host directories to be visible to the guest OS and use this as a means of transferring files between the two.

First, we need to create the shared folder in windows ( I slapped mine on my Windows Desktop). Let’s assume it’s called vShare.
Now we need to set it up in Virtual Box. So, with the Ubuntu VM powered down, go into Settings / Shared Folders. Select the folder you want to use as the share and click OK. Note – you shouldn’t check either the Read-Only or Auto-Mount boxes. Also, avoid underscores in the folder name as these don’t seem to work too well for some reason.

specify the shared folder in Virtual Box

Now, when you start the Ubuntu guest again, you need to mount the share ( note that the mount-point name in the guest needs to be different from the name of the shared folder on the host) :

$ sudo mkdir /mnt/hostShare
$ sudo chmod 777 /mnt/hostShare
$ sudo /sbin/mount.vboxsf –w vShare /mnt/hostShare

Note that if you’ve chosen a different name for your shared folder, use the name of the folder that’s shown in the VirtualBox Devices / Shared Folders dialog box.

To get the share to load everytime you startup the Guest os, you need to edit /etc/rc.local and add the following line :

/sbin/mount.vboxsf -w vShare /mnt/hostShare

To make it easier to get to from within the host, you can put a symbolic link on the desktop :

$ ln –s /mnt/hostShare $HOME/Desktop/host_share

A folder called host_share should now appear ( or materialize, if you prefer, ) on your Ubuntu desktop.

Escaping the Mirror Universe

By now, you will have noticed that, by default, Ubuntu has it’s Window control buttons on the left of the Window title bar rather than the right. If this is starting to get on your nerves…

On the Ubuntu Desktop, hit Alt + F2.
In the Run Application box that appears , type in gconf-editor and hit Run.
In the tree menu in the left-hand pane now navigate to apps/metacity/general
Right-click button_layout in the right-hand pane then click Edit Key.
Change the settings to menu:maximize,minimize,close

The buttons should now magically have switched sides.

The Final Frontier

As I’ve nearly exhausted Deb’s supply of Star Trek references, I’ll leave you with this thought :
Klingon programs do not have parameters, they have arguments…and they ALWAYS WIN THEM !

19 thoughts on “Installing Ubuntu in VirtualBox on a Windows 7 Host

  1. Pingback: Top ORCLearnings of the week « Oracle DB 10g & 11g Tops

  2. I gotta say that was an extremely great instruction on how to get Ubuntu Running perfectly on VBox. Thanks very much! 🙂

    • Gerhard,

      the only way I know of doing this is to put the Ubuntu documents in the directory that it shares with Windows. You should then be able to see them in the Windows host.



  3. Pingback: Anonymous

  4. Pingback: Click Chile » Cómo contar disparos de tu 7D/5D/1D… y muchas más

  5. Pingback: Cómo contar los disparos de mi 7D / 5D / 1D en Canon y otros modelos | NICE Fotografia - Tu imagen, tu recuerdo - Fotógrafo Matrimonios / Bodas

  6. Slight modifications:

    in /etc/rc.local enter:
    sudo mount -t vboxsf vshare /mnt/hostShare
    Note: you also need to sudo vi /etc/rc.local, of course to edit the file.

    Passing clipboard back and forth works for me, I just did for last line..

    To share a host directory:
    sudo mount -t vboxsf vshare /mnt/hostSharev
    Assuming your directory is called vshare in the Shared Folders tab of the Devices VirtualBox menu of your Virtual Machine and your /mnt/hostShared exists in Ubuntu (and is what you want).

    Host: Windows 7 Home Premium, last Microsoft updates
    Guest: Ubuntu 10.04 LTS
    VirtualBox 4.1.8.r75467

    That’s about it, pretty close Deb, good work!

    Incognito Nowhereman

  7. One problem I ran into that wasn’t addressed here, or at least I didn’t see it here. Before installing the Linux operating system on the virtual machine check your bios and make sure you have virtualization enabled. I didn’t and got some kind of funky message saying I got the wrong kind of Linux for my kind of processor. Tried two different versions before finding that fix. Also, if you found this because you are putting steam on your virtual machine. Install wine, winetricks, then open firefox inside your VM. Navigate here, Scroll down to the install link and click on it. This should start the download of steam and open the installer in winetricks. It installs the client and creates a shortcut on the desktop. Don’t bother with anything that says to open the terminal unless you really are looking forward to a headache. Thanks for the very informative tutorial. Can’t believe I didn’t do this sooner. Won’t be long before Windows 7 is my VM 🙂

  8. I have followed the instruction and i t works fine except for the symbolic link to the shared directory. It just fails and say file or catalog does not exist? The thing is that the /mnt/hostShare does exist at this point but ln seems to think it doesn’t?

    • Ok, forget this. I have installed Ubuntu 12.04.2 with the Swedish language selected and the Desktop directory is spelled in swedish to like Skrivbord so with ln -s /mnt/hostShare $HOME/Skrivbord/host_share the symbolic link got created. Sometimes the smallest things can mess it up…

    • Should also say that in my installation of Ubuntu 12.04.2 the keybord settings and the numeric keypad works as they should from the start, so that step wasn’t necessary for me.

  9. Running the current Ubuntu (16.04.2) on VirtBox (5.1.20) I can’t find the box for setting the numpad or numlock window.

    • Doug,
      I can’t find that setting in Ubuntu 16.04 either. Hopefully, this is no longer necessary for using Ubuntu as a Virtualbox Guest OS. Please let me know if that’s not the case.



Leave a Reply to Crockets!! Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.