Hi, and welcome to this book about VirtualBox, the best virtualization software I've ever used! Instead of boring you with a chapter full of theory to explain all the "knicks and knacks" about VirtualBox, I'm going to give you a tiny introduction to virtualization and then jump straight ahead into the installation process, ok?
In this chapter you will:
Learn about virtualization and how you can take advantage of this technology
Learn to install VirtualBox on Windows XP
Learn to install VirtualBox on Ubuntu Linux
And now, let the show begin...
The first time I heard about VirtualBox was when I was looking for something to help me make tutorials for Windows users trying to learn to use Linux. I needed something to help me run Ubuntu Linux inside my main Windows XP PC to write my tutorials in MS Word, capture all the Linux screenshots, and paste them directly into the MS Word document. I've worked with this excellent and powerful virtualization software since version 2.0, and I definitely give two thumbs up to the guys in the development team because version 3 has come a really long way, as we'll see throughout the exercises in this book, especially in areas related to the 3D Acceleration and USB support features.
For those of you new to virtualization, let me put it this way: With VirtualBox, you can use a Windows, Linux, Mac OS X, or Solaris PC to run one or more 'virtual' PCs inside it. Each virtual machine is called a guest, and your main PC is called a host. The bottom line is that you can run one 'host' operating system and several 'guest' operating systems inside that 'host'!
For example, if you have a Windows PC with 4 GB of RAM and a 320 GB hard disk, you can use VirtualBox to run three virtual machines side by side on the same computer running Windows. The following table shows how you can distribute your physical resources among the three virtual machines and your Windows PC:
Windows XP (host)
RAM: 1 GB
Hard Disk: 80 GB
This is your physical machine.
Linux Virtual Machine (guest 1)
RAM: 1 GB
Hard Disk: 80 GB
This is the first virtual machine. You can use practically any Linux distro available!
Open Solaris Virtual Machine (guest 2)
RAM: 1 GB
Hard Disk: 80 GB
This is the free, open source version of the Solaris operating system.
Windows 7 Virtual Machine (guest 3)
RAM: 1 GB
This is a new Windows release.
Naturally, you don't need to use all your VMs at the same time! Most of the time, you'll end up having a lot of virtual machines on your host PC and running only one or two of them in parallel. And don't worry about your computer's resources. Having an 80 GB virtual hard disk doesn't mean that your virtual machine is going to take up all that storage space immediately. Thanks to VirtualBox, you can have dynamically expanding storage, which means the initial size of your virtual machine's hard disk will be very small, and it will increase its size to take up more space as needed.
That means you can have more than four virtual machines with 80 GB hard drives on the Windows XP host computer, in the above example, because their virtual hard drives won't take up their full size immediately. However, it's better to keep in mind your physical hard disk space limitations when creating your virtual machines in order to avoid the typical problems that arise when your hard disk is full!
But that's enough chatter for now! You'll learn more about virtualization and VirtualBox with all the exercises I've prepared throughout the book, so let's get going!
Now let's get our hands dirty with the first exercise in this chapter! If you're going to install VirtualBox on Linux, feel free to skip this section. I'm going to use Windows XP in this exercise because it's currently the most widely used version of Windows. But the procedure is similar in Windows Vista or Windows 7, so you can use whichever one suits your needs the best.
Open your Web browser, and type http://www.virtualbox.org in the address bar. The VirtualBox main page will appear:
Click on the Downloads link located in the left sidebar. The Download VirtualBox page will show up:
Now click on the x86/amd64 link at the right of the VirtualBox 3.1.X for Windows hosts line. A dialog box will pop up, asking if you want to open or save the VirtualBox installation file. Click on Save to start downloading this file.
Once the downloading process ends, double-click on the downloaded file (it should be something like VirtualBox-3.X.X-X-Win.exe), and wait for the Do you want to open this file? warning dialog box to appear. Click on Run, and the Sun xVM VirtualBox Setup dialog will appear:
Click on the Next button to start installing VirtualBox on your PC. The next dialog will ask you to read the VirtualBox Personal Use and Evaluation License (PUEL). If you agree with it, select the I accept the terms in the License Agreement radio button, and click on Next to continue.
The next dialog, Custom Setup, will show you the VirtualBox features that will be installed as well as the installation directory. Leave the default options, and click on Next to continue:
On the next dialog, you need to choose if you want to create a shortcut to run VirtualBox from the desktop and/or from the Quick Task Bar. You can leave both options selected, and click on Next to continue.
The next dialog will warn you about temporarily disconnecting you from the local area network because the setup program will install the Sun xVM VirtualBox Networking feature:
Once the installation process finishes, you'll see the following dialog:
Click on Finish to exit the setup wizard and open the VirtualBox main window. The VirtualBox Registration Dialog will appear next:
If you already have a Sun account, just fill in your email and password, and click on the Register button to register your copy of VirtualBox. If this is the first time you're using a Sun product, select the I would like to register creating a new Sun Online account radio button, and fill in the required fields. Then click on Register. Once you register with Sun, you'll see the following success dialog:
You can close VirtualBox now.
See how easy it was to download and install VirtualBox on Windows? And wait until you start using it! You'll start wondering why someone didn't come up with VirtualBox ten years ago! Seriously speaking, however, you can use VirtualBox on the following Windows platforms:
Windows XP, all service packs (32-bit)
Windows Server 2003 (32-bit)
Windows Vista (32-bit and 64-bit).
Windows Server 2008 (32-bit and 64-bit)
Windows 7 (32-bit and 64-bit)
And the installation process is very similar, if not identical, on most Windows versions. Just be sure to have enough RAM for your physical 'host' PC and one or more 'guest' virtual machines. Oh, and you have to be careful with hard disk space also! But you don't need to worry about that right now; we'll cover all those things throughout the exercises in this book.
If you have the ability to do so, it would be a great idea to try VirtualBox on other Windows versions, especially on Windows 7, the most recent Windows release. You can also start browsing around VirtualBox's user interface and see if you can create a virtual machine by yourself!
Before installing VirtualBox, you'll need to install two additional packages on your Ubuntu system. Open a terminal window (Applications | Accessories | Terminal), and type
update, followed by Enter. If Ubuntu asks for your administrative password, type it, and hit Enter to continue.
Once the package list is updated, type
dkms, and hit Enter; then type
Yand hit Enter to install the DKMS package.
The other package needed before you can install VirtualBox is
build-essential. This package contains all the compiling tools VirtualBox needs to build the kernel module. Type
build-essential,and hit Enter. Then type
Y,and hit Enter again to continue. Wait for the
$prompt to show up again, type
exit,and hit Enter to close the terminal window. Now you can proceed to install VirtualBox.
Open the Synaptic Package Manager (System | Administration | Synaptic Package Manager), and select the Settings | Repositories option in the menu bar (if Ubuntu asks for your administrative password, type it, and press Enter to continue):
The Software Sources dialog will appear. Click on the Other (on earlier Ubuntu versions the name of this tab is Third-Party Software)and then on the Add+ button:
If you're not using Ubuntu 9.10 Karmic Koala, then you'll need to change the APT line in the previous step. For example, if you're using Ubuntu 9.04 Jaunty Jackalope, replace the
jaunty. On the http://www.virtualbox.org/wiki/Linux_Downloads webpage, you'll find more information about installing VirtualBox on several Linux distributions and the APT line required for each Ubuntu distribution available.
The third-party software source for VirtualBox will now show up on the list:
Now open a terminal window (Applications | Accessories | Terminal), and type
wget -q http://download.virtualbox.org/virtualbox/debian/sun_vbox.ascto download the Sun public key:
Go back to the Synaptic Manager, select the Authentication tab, and click on the Import Key File button:
The Import Key dialog will appear next. Select the
sun_vbox.ascfile you just downloaded, and click on the OK button to continue:
The Sun public key for VirtualBox should now appear on the list:
You can now delete the Sun public key file you downloaded earlier. Click on the Close button to return to the Synaptic Package Manager. If the Repositories Changed dialog shows up, select the Never show this message again checkbox, and click on Close to continue.
Now click on the Synaptic Package Manager's Reload button to update your package sources with the most recent VirtualBox version:
Once the Synaptic Package Manager finishes updating the package sources list, click on the Origin button located at the lower-left part of the window and select the
download.virtualbox.org/non-freerepository from the window above this button:
Click on the most recent
virtualbox-3.Xpackage checkbox in the right window, and select the Mark for Installation option:
The Mark additional required changes? dialog box will appear next. Click on the Mark button to mark all the additional packages required to install VirtualBox:
The Apply the following changes? dialog box will appear next. Make sure the Download package files only option is deselected, and click on the Apply button to start installing the required packages, along with VirtualBox:
The Synaptic Package Manager will start downloading the required packages and, when finished, it will install them along with VirtualBox.
Click on Forward to continue configuring VirtualBox. The configuration wizard will ask if you want to compile the
vboxdrvkernel module. Make sure that option is selected, and click on Forward to continue:
Wait until Debconf compiles the kernel module and finishes all the configuration procedure for VirtualBox. After that, the following dialog will appear:
Open a terminal window, type
sudo usermod -a -G vboxusers yourusername, and hit Enter to add your username to the
vboxusersgroup. Don't forget to replace yourusername with your own username. Then type
exit, and hit Enter again to close the terminal window.
Logout from Ubuntu, and then log back in. Now you can access VirtualBox through the Ubuntu menu bar (Applications | System Tools | Sun VirtualBox):
After opening VirtualBox for the first time, you'll see the VirtualBox License dialog. Scroll down to the end of the agreement, and then click on the I Agree button to continue.
Next you'll see the VirtualBox Registration Dialog:
If you already have a Sun account, just fill in your email and password, and click on the Register button to register your copy of VirtualBox. If this is the first time you're using a Sun product, select the I would like to register creating a new Sun Online account radio button, and fill in the required fields. Then click on Register. Once you register with Sun, you'll see a success dialog:
Now click on the OK button to go to the VirtualBox main screen:
You can close VirtualBox now.
Ok, ok… Installing VirtualBox on Linux is a little more elaborated process, but hey, I was behind you all the time, right? On Linux there are some additional things to consider when you're installing a software application like VirtualBox. I decided to show you how to use the Synaptic Package Manager because this wonderful piece of open source software takes care of all the complicated things that always come up when installing something in Linux.
On the first three steps of the previous exercise, you upgraded the Ubuntu packages list and then installed a couple of packages required by VirtualBox on a Linux installation. These packages prepare your system for building the external modules VirtualBox needs to operate virtual machines. The
DKMS (Dynamic Kernel Module Support) package allows your system to build these modules dynamically, so you don't have to worry in case you upgrade your Ubuntu system. The
build-essential package contains the
gcc compiler and some other tools required to compile and build the kernel modules. The Synaptic Package Manager uses repositories scattered throughout Internet. To install VirtualBox, we had to add a specific repository called
download.virtualbox.org/main because the standard Ubuntu installation only includes the
virtualbox-ose package, the OSE (Open Source) version of VirtualBox. In this book we're going to work with the PUEL (Personal Use and Evaluation License) version of VirtualBox because it's free for personal/academic use or for product evaluation.
Finally, we also have to add the Sun public key because Synaptic won't be able to access the VirtualBox PUEL repository otherwise. After that, you just need to select the desired VirtualBox version, and Synaptic will take care of the rest for you.
Once you've installed VirtualBox on Linux, the process for creating and using virtual machines will be the same on any platform.
If you have the ability and resources, would be a great idea to try VirtualBox on other Linux distros, but you need to make an extra effort because not every distribution uses the Synaptic Package Manager. But the VirtualBox website has some basic information on how to install VirtualBox on several Linux distros such as Debian, Fedora, Red Hat, or SuSE. The website provides several specific packages for some of the most popular Linux distributions and one general package for the rest of the Linux distros available. And remember you can always send me an email in case you get stuck!
Oh, and you can also start to browse around VirtualBox's user interface. Go on and experiment all you can and try to create a virtual machine by yourself!
In this next exercise, you'll download Damn Small Linux, one of the smallest Linux distros currently available, and then I'll show you how to create a quick virtual machine on your brand new VirtualBox software in order to test it!
Open your web browser, and type http://www.damnsmalllinux.org. The What is DSL? page will show up:
Scroll down the page until you locate the Download link, or go to the http://www.damnsmalllinux.org/download.html page directly, and scroll down to the Current Full Mirror List section:
Click on an HTTP link (in this case, I chose the second link, http://ibiblio.org/pub/Linux/distributions/damnsmall/) and then on the current link of the next page:
On the next page, scroll down until you locate the dsl-4.4.10.iso, and click on it to start downloading the DSL ISO file:
A dialog box will pop up, asking if you want to open or save the DSL ISO file. Click on Save to start downloading this file:
Once the downloading process ends, open VirtualBox, and click on the New button to create a new virtual machine:
The Welcome to the New Virtual Machine Wizard dialog will show up. Click on Next to continue:
The VM Name and OS Type dialog will appear next. Type
DSLTestin the Name field, select
Linuxas the Operating System and
Debianas the Version, then click on Next to continue:
Leave the default
MBvalue as the Base Memory Size in the Memory dialog, and click on Next to continue:
Now the Welcome to the Create New Virtual Disk Wizard! dialog box will appear. Click on Next to continue, and leave the Dynamically expanding storage option selected as the Storage Type in the Hard Disk Storage Type dialog:
In the next dialog (Virtual Disk Location and Size), leave the
GBdefault options for Location and Size, respectively, and click on Next to continue:
Now the wizard will show you a Summary of all the parameters for the virtual disk of your virtual machine. Click on Finish to continue:
The last dialog will show you a Summary of all the parameters selected for your new virtual machine. Click on Finish to continue:
After creating the virtual machine, it will show up in VirtualBox's main screen:
Now click on the Settings button to open the DSLTest - Settings dialog box. Select the CD/DVD-ROM category from the list on the left side, click on the Mount CD/DVD Drive checkbox, and then select the ISO Image File option:
Next, click on the Invoke Virtual Media Manager button:
The Virtual Media Manager dialog will appear. Click on the Add button to continue:
Now the DSL ISO image will appear in the CD/DVD Images list of the Virtual Media Manager:
Click on the Start button to start your virtual machine. The VirtualBox – Information dialog box will show up to inform you that you need to use the Right-Ctrl key to alternate between using the keyboard in your virtual machine and your host PC. Select the Do not show this message again checkbox, and click on OK to continue:
The DSL virtual machine will start to boot. Wait until a VirtualBox – Information dialog box appears to tell you that the virtual machine is using 16 bit color instead of 32 bit. Select the Do not show this message again checkbox, and click on OK to continue.
Click inside the virtual machine's screen with your mouse, and another VirtualBox – Information dialog will show up to inform you that you need to use the Right-Ctrl key to alternate between using the mouse in your virtual machine and your host PC. Select the Do not show this message again checkbox, and click on Capture to continue.
Wait for a few minutes for DSL to start booting up. When it is finished, the following screen will show up:
Now you have created your first virtual machine!
Whew! I must admit that this was a lengthy exercise! Thanks to VirtualBox's user-friendly interface, you've just learned how to create this test virtual machine with one of Linux's smallest distros available: Damn Small Linux (DSL for short). In fact, it's so small, it doesn't even need a hard disk to work properly! I hope you had fun with this exercise, and don't worry about all the settings involved in creating a virtual machine; we'll have enough exercises to deal with them throughout the rest of the book!
For now, just concentrate on the virtual machine creation process as a whole: Click on the New button, select the operating system you want to use, assign a chunk of memory and hard disk space to your new virtual machine, and tell it where to boot an ISO image with the operating system of your choice, as if it were just another ordinary PC in your desk!
Now that you've created a test virtual machine, go on and download other Linux distributions, and try to create other virtual machines; experiment with different settings for RAM and hard disk space.
We'll talk more about this later. For now, just keep experimenting with all the VirtualBox features you can! And if you have any questions, feel free to email the Packt team at
What would be the best definition of a virtual machine?
A physical PC connected to a LAN.
A 'guest' machine running inside another 'host' machine.
A computer with lots of RAM and hard disk space.
You need to use MS Word to write a document, but the only available PC at the moment is running Linux. The best thing you can do is:
Cry and pull your hair out in despair.
Install VirtualBox on your Linux PC, create a Windows XP virtual machine, and install MS Word.
Go out and buy a new Windows Vista PC with MS Word installed.
Sharing one physical PC between two or more virtual machines to maximize resource usage.
To surf the web looking for new applications.
Running two or more operating systems in one PC.
This chapter was a hands-on introduction to VirtualBox, the best virtualization software out there!
Specifically, we covered:
What virtualization is, and how we can use VirtualBox to run several virtual machines inside a physical host
How to install VirtualBox on Windows environments
How to install VirtualBox on Linux environments
How to create, configure, and run a test virtual machine
Now that you have VirtualBox installed and running, you're ready to delve into the VirtualBox world! In the following chapter, I'll show you how to create, configure, and run your own Ubuntu Linux virtual machine in any host operating system supported by VirtualBox!