11 min read

Packt are due to launch a new Open Source brand, into which future VirtualBox titles will be published. For more information on that launch, look here.

In this two-part article by Alfonso V. Romero, author of VirtualBox 3.1: Beginner’s Guide, you shall:

  • Create your first virtual machine in VirtualBox, using Ubuntu Linux
  • Learn about your virtual machine’s basic configuration
  • Download and install Ubuntu Linux on your virtual machine
  • Learn how to start and stop your virtual machine

So let’s get on with it…

Getting started

In this article, you’ll need to download the Ubuntu Linux Desktop Live CD. It’s a pretty big download (700 MB approximately), so I’d recommend you to start downloading it as soon as possible. With a 4 Mbps Internet connection, you’d need approximately 1 hour to download a copy of Ubuntu Linux Desktop.

That’s why I decided to change the order of some sections in this article. After all, action is what we’re looking for, right?

Downloading the Ubuntu Linux Live CD

After finishing the exercise in this section, you can jump straight ahead into the next section while waiting for your Ubuntu Live CD to download. That way, you’ll have to wait for less time, and your virtual machine will be ready for some action!

Time for action – downloading the Ubuntu Desktop Live CD

In the following exercise I’ll show you how to download the Ubuntu Linux Desktop Edition from the official Ubuntu website.

  1. Open your web browser, and type http://www.ubuntu.com in the address bar. The Ubuntu Home Page will appear. Click on the Ubuntu Desktop Download link to continue:

    VirtualBox 3.1: Beginner's Guide

  2. The Download Ubuntu page will show up next. Ubuntu’s most recent version will be selected by default (Ubuntu Desktop 9.10, at the time of this writing). Select a location near you, and click on the Begin download button to continue.

    The Ubuntu Download page lets you download the 32-bit version automatically. If you want the 64-bit version of Ubuntu 9.10, you’ll need to click on the Alternative download options link below the Download locations list box. The exercises in this article use the 32-bit version.

  3. You’ll be taken to the download page. After a few seconds, your download will start automatically. Select the Save File option in your browser, and click on OK to continue.
  4. Now you just have to wait until the download process finishes.

What just happened?

I think the exercise pretty much explains itself, so I just want to add that you can also order a free Ubuntu CD or buy one from Ubuntu’s website. Just click on the Get Ubuntu link at the front page and follow the instructions. I ordered mine when writing this article to see how long it takes to arrive at my front door. I hope it arrives before I finish the book!

Have a go hero – doing more with the thing

You can try downloading other Ubuntu versions, like Ubuntu 8.10 Hardy Heron. Just click on the Alternative download options link below the Download locations list box, and explore the other options available for download.

Creating your Ubuntu Linux VM

Now that you installed VirtualBox, it’s time to learn how to work with it. I’ve used other virtualization products such as VMware besides VirtualBox, and in my humble opinion, the user interface in VirtualBox is a delight to work with.

Time for action – creating a virtual machine

At last you have the chance to use Windows and Linux side by side! This is one of the best features VirtualBox has to offer when you want the best of both worlds!

  1. Open VirtualBox, and click on the New button (or press Ctrl+N) to create a new virtual machine:

    VirtualBox 3.1: Beginner's Guide

  2. The Welcome to the New Virtual Machine Wizard! dialog will show up. Click on Next to continue. Type UbuntuVB in the Name field, select Linux as the Operating System and Ubuntu as the Version in the VM Name and OS Type dialog.
  3. Click on Next to continue. You can leave the default 384 MB value in the Memory dialog box or choose a greater amount of RAM, depending on your hardware resources.
  4. Click on Next to continue. Leave the default values in the Virtual Hard Disk dialog, and click on Next twice to enter the Create New Virtual Disk wizard. Leave the default Dynamically Expanding Storage option in the Hard Disk Storage Type dialog, and click on Next to continue.
  5. Leave the default values chosen by VirtualBox for your Ubuntu Linux machine in the Virtual Disk Location and Size dialog (UbuntuVB and 8.00 GB), and click on Next to continue.
  6. A Summary dialog will appear, showing all the parameters you chose for your new virtual hard disk. Click on Finish to exit the Create New Virtual Hard Disk wizard. Now another Summary dialog will appear to show the parameters you chose for your new virtual machine. Click on Finish to exit the wizard and return to the VirtualBox main window:
    VirtualBox 3.1: Beginner's Guide
  7. Your new UbuntuVB virtual machine will appear on the VirtualBox main screen, showing all its parameters in the Details tab.

What just happened?

Now your Ubuntu Linux virtual machine is ready to run! In this exercise, you created a virtual machine with all the parameters required for a typical Ubuntu Linux distribution. The first parameter to configure was the base memory or RAM. As you saw in step 3, the recommended size for a typical Ubuntu Linux installation is 384 MB.

Exercise caution when selecting the RAM size for your virtual machine. The golden rule of thumb dictates that, if you have less than 1 GB of RAM, you can’t assign more than one half of your physical RAM to a virtual machine because you’ll get into trouble! Your host PC (the one that runs VirtualBox) will start to behave erratically and could crash!

With 2 GB, for example, you can easily assign 1 GB to your virtual machine and 1 GB to your physical PC without any problems. Or you could even have three virtual machines with 512 MB of RAM each and leave 512 MB for your host PC. The best way to find out the best combination of RAM is to do some experimenting yourself and to know the minimum RAM requirements for your host and guest operating systems.

Don’t assume that assigning lots of RAM to your virtual machine will increase its performance. If, for example, you have 2 GB of RAM on your host and you assign 1 GB to an Ubuntu virtual machine, it’s very unlikely there will be a bigger performance increase than if you were assigning only 512 MB to the same Ubuntu virtual machine. On the contrary, your host PC will work better if you only assign 512 MB to the Ubuntu virtual machine because it will use some of the extra RAM for disk caching, instead of recurring to the physical hard disk. However, it all depends on the guest operating system you plan to use and what applications you need to run.

If you look closely at the Base Memory Size setting in the Memory dialog when creating a virtual machine, you’ll notice that there are three memory areas below the slider control: the green-colored area indicates the amount of memory range you can safely choose for your virtual machine; the yellow-colored area indicates a dangerous memory range that you can choose, but nobody knows if your virtual machine and your host will be able to run without any problems; and the red-colored area indicates the memory range that your virtual machine can’t use. It’s wise to stick with the default values when creating a new virtual machine. Later on, if you need to run a memory-intensive application, you can add more RAM through the Settings button, as we’ll see in the following section.

Another setting to consider (besides memory) when creating a virtual machine is the virtual hard drive. Basically, a virtual hard disk is represented as a special file on your host computer’s physical hard disk, and it’s commonly known as a disk image file. This means that your host computer sees it as a ‘large’ file on its system, but your virtual machine sees it as a ‘real’ hard disk connected to it. Since virtual hard drives are completely independent from each other, there is no risk of accidental overwriting, and they can’t be larger than the free space available on your real computer’s physical hard drive. This is the most common way to handle virtual storage in VirtualBox; later on, we’ll see more details about disk image files and the different formats available.

VirtualBox assigns a default value based on the guest operating system you plan to install in your virtual machine. For Ubuntu Linux, the default value is 8 GB. That’s enough space to experiment with Ubuntu and learn to use it, but if you really want to do some serious work —desktop publishing or movie production, for example—you should consider assigning your virtual machine more of your hard disk space.

You can even get two hard drives on your physical machine, and assign one for your host system and the other one for your virtual machine! Or you can also create a new virtual hard disk image and add it as if it were a second hard drive!

Before going to the next section, I’d like to talk about the two virtual hard disk storage types available in VirtualBox: dynamically expanding storage and fixed-size storage. The Hard Disk Storage Type dialog you saw in step 4 of the previous exercise contains a brief description for both types of storage. At first, the dynamically expanding option might seem more attractive because you don’t see the space reduction in your hard drive immediately.

When using dynamically expanding storage, VirtualBox needs to expand the storage size continuously, and that could mean a slight decrease in speed when compared to a fixed-size disk, but most of the time this is unnoticeable. Anyway, when the virtual hard disk is fully expanded, the differences between both types of storage disappear.

Most people agree that a dynamically expanding disk represents a better choice than a fixed one, since it doesn’t take up unnecessary space from your host’s hard disk until needed. Personally, when experimenting with a new virtual machine, I use the dynamically expanding option, but when doing some real work, I like to set apart my virtual machine’s hard disk space from the beginning, so I choose the fixed-size storage option in these cases.

Have a go hero – experimenting with memory and hard disk storage types

When creating a virtual machine, you can specify the amount of RAM to assign to it instead of using the default values suggested by VirtualBox. Create another virtual machine named UbuntuVB2, and try to assign the entire RAM available to it. You won’t be able to continue until you select a lower value because the Next button will be grayed out, which means you’re in the red-colored memory range. Now move back the slider until the Next button is active again; you’ll probably be in the yellow-colored memory range. See if your virtual machine can start with that amount of memory and if you can use both your host PC and your VM without any problems. In case you encounter any difficulties, keep moving back the memory range until all problems disappear.

Once you’re done experimenting with the memory setting, use the UbuntuVB2 virtual machine with the same exact settings as the one you created in the previous exercise, but this time use a fixed-size hard drive. Just take into account that since VirtualBox must prepare all the storage space at once, this process may take a long time depending on the storage size you selected and the performance of your physical hard disk. Now go and try out different storage sizes with both types of disks: dynamically expanding and fixed size.

Configuring basic settings for your Ubuntu Linux VM

All right, you created your Ubuntu virtual machine and downloaded a copy of Ubuntu Desktop Live CD. Can you start installing Ubuntu now? I know you’ll hate me, but nope, you can’t. We need to tell your virtual machine where to boot the Live CD from, as if we were using a real PC. Follow me, and I’ll show you the basic configuration settings for your VM, so you can start the Ubuntu installation ASAP!

Time for action –basic configuration for your VM

In this exercise you’ll learn how to adjust some settings for your virtual machine, so you can install Ubuntu Linux on it.

  1. Open VirtualBox, select your UbuntuVB virtual machine, and click on the Settings button:

    VirtualBox 3.1: Beginner's Guide

  2. The UbuntuVB – Settings dialog will appear, showing all the settings in the General tab.
  3. Click on the Storage category from the list in the left panel. Then select the Empty slot located just below the UbuntuVB.vdi hard disk image, under the IDE Controller element inside the Storage Tree panel, and click on the Invoke Virtual Media Manager button:
    VirtualBox 3.1: Beginner's Guide
  4. The Virtual Media Manager dialog will appear next. Click on the Add button to add the Ubuntu Linux Live CD ISO image:

    VirtualBox 3.1: Beginner's Guide

  5. The Select a CD/DVD-ROM disk image file dialog will show up next. Navigate to the directory where you downloaded the Ubuntu Desktop ISO image, select it, and click on the Open button to continue.
  6. The Ubuntu Desktop ISO image will appear selected in the CD/DVD Images tab from the Virtual Media Manager dialog. Click on the Select button to attach the Ubuntu ISO image to your virtual machine’s CD/DVD drive.
  7. Next, the Ubuntu ISO image file will appear selected on the ISO Image File setting from the UbuntuVB – Settings dialog. Click on OK to continue.
  8. Now you’re ready to start your virtual machine and install Ubuntu!

Subscribe to the weekly Packt Hub newsletter. We'll send you this year's Skill Up Developer Skills Report.

* indicates required

LEAVE A REPLY

Please enter your comment!
Please enter your name here