Installing Ubuntu Desktop on VirtualBox

In the article Installing Oracle VirtualBox on Windows I showed how to download and install Oracle VirtualBox. In this article, we’ll use that VirtualBox installation to create a virtual machine into which we’ll install Ubuntu Desktop 13.04. Ubuntu is one of the most popular GNU/Linux distributions and the Desktop version makes a very useful software development platform. There is also a Server version that is more suitable for production use as a LAMP server, however, you can install all of the same server components on the Desktop version as well.

Oh, Ubuntu, you are my favorite Linux-based operating system.

—Dr. Sheldon Cooper, Big Bang Theory

Download the Ubuntu Distribution ISO

The first step to install Ubuntu is to get the media. There are several books and magazines that include Ubuntu in a CD/DVD insert. If you have one of those handy you can use it to install Ubuntu. But if you have some time to spare you can always download the latest and greatest version from ubuntu.com. That’s the route I’ll take in this article.

When you get to the Ubuntu web page select Download from the menu as shown below.

ubuntu.com

You can always download the latest and greatest version of Ubuntu from the web site.

On the Downloads page select Ubuntu Desktop.

Ubuntu Desktop download

We’ll install the Desktop version of Ubuntu in this article. There’s a server version as well.

On the Download Ubuntu Desktop page, I’ll select the latest and greatest version 13.04 (at the time of writing) and select the delicious 64-bit flavor. If you have a 32-bit machine, you should choose that instead. Click the Ubuntu 13.04 button.

Ubuntu 13.04 64-bit

I’ll grab the latest version (13.04 at the time of this writing). There is a version for 32-bit and 64-bit hardware.

You can show your appreciation with a contribution to the cause.

Contribution screen

Contribute at least once–it’s worth every penny!

You will then be prompted to save the massive 785MB download file. I recommend storing it on an external drive or flash drive in case you want to install it on another machine as well, however, anywhere on your hard disk is fine. The 64-bit version of the file is called ubuntu-13.04-desktop-amd64.iso. This is an ISO file, which is an image of a bootable optical disk. You can burn this file to a DVD if you would like, but it’s not necessary. VirtualBox is able to boot directly from the ISO file.

Configure VirtualBox

Since we’ll be installing Ubuntu in a VM using VirtualBox, we first need to create and configure the VM. We’ll then boot the Ubuntu ISO image downloaded in the previous section. From there we can proceed through the installation as if we were installing Ubuntu on raw hardware. Launch VirtualBox from the Start menu as you would any Windows application (it should be in a program group called Oracle VM VirtualBox). You should see the VirtualBox Manager main window. If you haven’t created any VMs yet, the left pane of the window will be empty.

Before creating a new VM you should give a little thought to where you want to store it. By default, VMs are stored within a folder in your home directory called VirtualBox VMs. In Windows 7, this will be something like c:\Users\[username]\VirtualBox VMs. VirtualBox will create a separate sub-folder within this folder for each of your VMs. Within the VM folder VirtualBox stores an XML file containing the VM’s settings, virtual disk drive container files, a folder for logs, and a folder for snapshots. This arrangement keeps all of your VM’s files nicely organized.

If you would like to store your VMs in another location you can change the default from the File→Preferences menu. As shown below, I’m changing my default VM storage location to a folder on an external drive.

General Settings dialog

You can change the default location where VirtualBox saves its VMs in the General Settings dialog.

Once you have set your default VM folder location you can create a new VM. Click the blue New button in the toolbar.

VirtualBox Manager

The VirtualBox Manager screen allows you to manage all of your VMs.

You should now see the first step of the Create Virtual Machine wizard where you will assign the VM a name, type, and version. The name can be anything you like but must be a valid filename as it will be used to create a folder on your hard disk in which to store the VM’s files. The name of the VM should describe the guest operating system you intend to install and, perhaps, the purpose of the VM. Over time you may have many VMs listed in the VirtualBox manager and you’ll need to tell them apart.

For this article, I’ll name the VM Ubuntu Desktop 13.04. From the Type drop-down select Linux, if it isn’t already selected. From the Version drop-down, select the machine architecture that corresponds to the version of Ubuntu that you downloaded (32-bit or 64-bit). Click Next.

Enter VM name, type, and version

Enter the name of your VM, its type, and its version. Here, we choose to install the 64-bit version of Ubuntu Desktop.

In the Memory size step of the wizard you tell VirtualBox how much main memory you want to allocate to the VM. The amount of memory will depend on the total amount of memory installed on your machine, the memory requirements of both the host and guest operating systems, and the number of VMs that you will want to run simultaneously. For this installation my total physical memory is 8GB and I will allocate half of that to the VM. This will leave plenty of memory for both Windows and Ubuntu. You should allocate at least 512MB as that is the minumum recommended for Ubuntu. The value can be adjusted after creating the VM if necessary. You can use either the slider control or type the value directly into the text box provided. Click Next when done.

Enter memory size for the VM

Enter the amount of memory to be allocated to your VM. Here we enter 4GB for the VM out of the 8GB available on the machine.

On the next dialog you begin the process of creating the first hard disk to be mounted by your VM. The VM’s hard disk will be implemented with a container file on your host’s hard disk. You have the option of skipping this step so that you can add the disk later or using an existing disk if you have one. In our case, we want to create it now so leave the default option of Create a virtual hard drive now selected and click the Create button.

Create virtual hard drive

We’ll add our main virtual hard drive during the VM creation process.

VirtualBox supports several file formats for the container file that will implement your virtual hard disk. The primary consideration here is whether you need to support other VM managers such as VMWare, Parallels, or Microsoft. For the purposes of this article, we’ll use the default VirtualBox format, VDI. Click Next.

Hard drive file type

You can select from several formats for the virtual hard drive container file. Here we select the default VirtualBox Disk Image (VDI) format.

In the Storage on physical hard drive step of the wizard, you specify whether the container file should be pre-allocated to its maximum size or grow dynamically as needed. I usually use the default Dynamically allocated option. This will initially result in a small file that will grow as the virtual disk sectors are first written. The actual maximum size of the disk is specified in the next step. Click Next.

Dynamic vs fixed size selection

We elect to have our hard drive container file expand as needed rather than pre-allocated to its maximum size.

In this step, you choose the location and size of your virtual disk. By default, the virtual disk’s container file will be placed in the VM’s directory with the name shown. I will typically change the name to represent the purpose or mount point of the disk. Since this first disk will be used for the root filesystem, I’ll rename it root. You may later want additional disks for applications, user home directories, and so forth. You can also change the location of the container file if you would like but it’s handy to keep them all in the same folder if you have the space there.

I’ll set the size of the disk to 20.00 GB. Since we chose the dynamic allocation method in the last step, the container file will start off small and then grow to maximum size of 20GB as needed. You can either use the slider control or type the value into the text box. Click Create.

File location and size

Enter the virtual disk file name and size.

You will next be returned to VirtualBox Manager and your new VM will be shown in the left pane. The VM’s settings are shown in the right pane. As indicated in the figure below the VM is currently powered off. To startup the VM click the Start button.

Start the VM

The VM’s settings are displayed in the right pane. You can start up the new VM by clicking the Start icon.

Install Ubuntu Desktop

When the VM starts it will attempt to boot an operating system. As no operating system has been installed yet, you will see the dialog below requesting that you supply a startup disk. If you have a CD or DVD with a resident boot image, you can load it and select the drive location. However, VirtualBox can also boot directly from an ISO image. Click the folder icon next to the text box, navigate to the Ubuntu ISO you downloaded earlier, and then click Start.

Select start-up disk

Here we select the Ubuntu ISO boot image that we downloaded earlier. The ISO image represents an optical disk.

Ubuntu will boot from the ISO image and begin its installation script. The first step is to select your language and click the Install Ubuntu button as shown below.

Installer Welcome screen

Select your language on the left and click the “Install Ubuntu” button to begin the installation process.

The Ubuntu installer will do some system checks and advise you of the status. You can install the OS without being connected to the internet, but if you are connected, you have the option of installing updates and additional third-party software. Check the associated boxes and click Continue.

Preparing to install Ubuntu

This screen shows that we’ve met all the criteria for installation. Although you can install Ubuntu while disconnected, an internet connection allows the installer to download updates and additional software. We chose to allow this for our install.

Next, you select the installation type. Because we are installing Ubuntu in a VM, we want the installer to erase the disk. The “disk” in this case is the virtual disk you created earlier and not your actual hard disk. For this development installation, we don’t need encryption or logical volumes. Click Install Now.

Installation type

Selecting the “Erase disk” option here is fine since it will just be erasing our virtual disk and not the actual host disk. If you are installing directly on a real machine, you might want to reformat drives, resize partitions, create a dual-boot machine, etc. In those cases, you would select “Something else” and proceed from there.

You next indicate your timezone by clicking your approximate location on the displayed world map. Click Continue.

Where are you?

Select your time zone by clicking your location on the map.

In the next step you select your keyboard layout and click Continue.

Keyboard layout

Select your keyboard layout.

In the Who Are You? step, you provide some identifying information including your name, the name you would like to call your virtual Ubuntu computer, your username, and password. Using the inforation provided, the installer will create a user account with Administrator privileges. Click Continue.

Who are you?

Enter your actual name and choose a name for your computer. Also choose a username and password for your account. This will be an administrator account.

The installation will begin and Ubuntu will display a slide of show of features that you can view while it copies files to your virtual hard disk. You can click the arrows to move backward and forward through the slides manually.

Welcome to Ubuntu

As the installation progresses you can view some slides about Ubuntu features.

When the installation is complete, click Restart Now as shown below.

Restart prompt

You are prompted to restart your system at the end of the installation.

Unfortunately, at this point VirtualBox will likely crash. While it can normally restart the operating system just fine, it seems to have a problem doing so from the installer. If you see the dialog below, click Close the program. We will restart the program manually in the next step.

VirtualBox crash

VirtualBox tends to crash at this point. Since the installation completed, we can just restart the aborted VM.

If VirtualBox crashed when the installer attempted to restart the operating system, re-start VirtualBox from the Windows menu. The status of the VM will be Aborted but the OS is installed. Click the Start button to restart it.

Restart the VM manually

Since the VM crashed when trying to restart, the current status is “Aborted.” Highlight the VM in the left pane (if you have more than one) and click Start.

If you see the Select start-up disk dialog again, click Cancel. If the installer begins to run again, click Cancel and confirm the cancellation. If all goes well, VirtualBox will restart and you will see the Unify desktop.

Cancel start-up disk dialog

This time around, cancel the “Select a start-up disk” dialog so the VM will boot from its disk image.

Install VirtualBox Guest Additions

VirtualBox Guest Additions is a set of packages that are installed within the VM to provide better integration between the host operating system and the guest operating system. Some of the features provided include:

  • Mouse pointer integration. This feature provides seamless integration between the host and guest mouse pointers. Rather than having a “shadow” mouse pointer in the guest that lags the host mouse pointer, this Guest Addition provides for a single mouse pointer that is shared between the host and guest. The Addition also eliminates the need for the guest to “capture and free” the pointer with the Host key.
  • Shared folders. This is a very useful Guest Addition that provides access to host shared folders within the guest. Once a host folder is “shared” it can be mounted as a network share within the guest. This allows you to easily move files between the host and guest operating systems and provides read/write access to shared folders and files.
  • Better video support. Besides offering full-resolution graphics and 2D/3D acceleration to the guest operating system, the most useful aspect of this Guest Addition is window resizing. This allows you to resize the VirtualBox window, which automatically adjusts the resolution of guest display to match.
  • Seamless windows. This feature puts guest windows directly onto the host’s desktop, making it appear as if a guest application is running directly on the host.
  • Generic host/guest communication channels. This feature provides a mechanism for sharing string data between the host and guest and for launching guest applications directly from the host.
  • Time synchronization. This service keeps the host and guest clocks synchronized.
  • Shared clipboard. Allows cut/copy/paste between host and guest applications.
  • Automated logons (credentials passing). This feature provides for guest authentication by the host on supported platform combinations.

To install Guest Additions, click the Devices menu and select Install Guest Additions… as shown in the figure below.

Install Guest Additions

We now install the VirtualBox Guest Additions in order to get some nice integration features with the host. While you could do this manually, VirtualBox provides a menu option that mounts the ISO image and installs the necessary packages.

The ISO image for the Guest Additions will be mounted and you will see the dialog below. Click Run.

Run the Guest Additions installer

A sort of “auto-play” for Ubuntu. Run the Guest Additions installer by clicking Run.

Enter your password in the subsequent dialog and click the Authenticate button.

Enter your password

Most software installations require you to authenticate with your administrator account password.

While the Guest Additions install, you will see some progress messages in a terminal window as shown below. Press the Return key when prompted to do so.

Guest additions installer log

While the installer runs it provides feedback of its operation. Press return if there are no errors.

We now need to restart Ubuntu. Click on the small icon in the top right corner of the screen. On the drop-down menu, click Shutdown…

Restart the guest OS

We’ll restart the guest OS.

On the shutdown dialog click the Shutdown button as shown below.

Click Shut Down

Click the Shut Down button to shutdown the OS. You could instead click Restart if you like.

On the VirtualBox Manager screen you should now see that the VM is in the Powered Off state. Note that the VBoxGuestAdditions.iso image is still mounted as a CD/DVD. This is because we didn’t unmount it before shutting down the VM. When we restart the VM it will be automatically remounted. Let’s restart the VM by clicking the Start button as before.

VM is powered off

The status of the VM shows that the Guest Additions ISO is still mounted. We’ll unmount it when we restart.

The logon screen is displayed. Enter your password and press Enter or Return. Now that the Guest Additions are operational you should be able to resize the VM window and have the Ubuntu desktop automatically fill the window. You will also notice that a single mouse pointer serves both the host operating system and the guest.

Login screen

Enter your password to log in.

Now, let’s go ahead and unmount the Guest Additions CD. In the Launch Bar on the left side of the screen, right-click the CD icon near the bottom. A fly-out menu will appear. Click Eject.

Eject Guest Additions

Here we eject the Guest Additions virtual CD.

You will see a message window confirming that the virtual CD was ejected.

Eject successful

Confirmation that the virtual CD was ejected successfully.

Let’s now check for any additional software updates that need to be applied. For this we’ll use the Software Updater. Click the Search button in the Launch Bar and type Software Updater into the search box as shown below. When the Software Updater icon appears, click it.

Software Updater

We run the Software Updated to check for outdated software to be installed.

Enter your password and click Authenticate when prompted to do so.

Authenticate with password

Enter your password again so the Software Updater can check your system.

The Software Updater searches its configured repositories looking for any updates to installed applications that should be applied.

Software updated checking archives

The Software Updater checks its archives and downloads needed updates.

If there are updates to be installed you will see the dialog box below. You can click the Details of updates item to see a list of packages that need to be updated.

Check details of update

Check the details of the updates to be applied.

You can review the list of applications to be updated on the resulting screen. Click Install Now if there is software to be installed.

Review updates

After browsing the update list, click Install Now to begin the update process.

Again, authenticate with your password.

Authenticate again before installing updates

Authenticate again before installing updates.

Click Restart if prompted to do so.

Another restart

Another restart…

Shut down Ubuntu as you did before.

Shutdown the system again

Shutdown the system again.

And again click the Shudown button.

Click the big shutdown button

Click the big shutdown button. Or you can do a restart with the other button.

Take a Snapshot

Now that we have a functioning Ubuntu Desktop installation with Guest Additions and updates on board, it would be an excellent time to take a snapshot of the VM. The snapshot saves the state of the VM at the time you take it. This allows you to return the VM to this state in the future should it be desired.

With the Ubuntu Desktop VM selected in the left pane, click the Snapshots button in the top right corner of the VirtualBox Manager. Finally, click the small camera icon as shown below.

Create a snapshot

Click the Snapshots button to manage your snapshots. We don’t currently have any snapshots so we just see Current State. Click the camera icon to create a snapshot.

Enter a name for the snapshot and a description of the current state of the VM as shown below. Click OK.

Give your snapshot a name and description

Give your snapshot a name and description.

You are then returned to the Snapshots screen with your first snapshot displayed.

Snapshot screen with snapshot showing

Now the Snapshots screen shows the first snapshot.

In this article we created a new VM and installed Ubuntu Desktop 13.04 on it. We then installed Guest Additions within the VM to take advantage of better integration between the host and guest operating system. We launched the Software Updater to check for updates to installed applications. We then took a snapshot of the VM in the event we need to roll its state back to the fresh install.

In the next couple of articles we will layer on an AMP stack (Apache, MySQL, PHP) and install some development tools in our new VM.

Speak Your Mind

*