So let's get on with it...
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.
- 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:
- 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.
- 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.
- 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!
- Open VirtualBox, and click on the New button (or press Ctrl+N) to create a new virtual machine:
- 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.
- 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.
- 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.
- 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.
- 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:
- 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.
- Open VirtualBox, select your UbuntuVB virtual machine, and click on the Settings button:
- The UbuntuVB – Settings dialog will appear, showing all the settings in the General tab.
- 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:
- The Virtual Media Manager dialog will appear next. Click on the Add button to add the Ubuntu Linux Live CD ISO image:
- 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.
- 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.
- 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.
- Now you're ready to start your virtual machine and install Ubuntu!
What just happened?
As you can see from the previous exercise, your virtual machine is just like a real PC. You need to 'insert' a bootable CD so that the VM can boot and start installing Ubuntu. In this case, we used an ISO image of Ubuntu Desktop instead of having to insert a real bootable CD. That's one of the benefits of VirtualBox: you can forget about having to burn a CD to test the new Ubuntu version or any other operating system! You just need to download the ISO image and configure your virtual machine to act as if there was a real CD inserted in the CDROM drive!
You can also go the traditional way, in case you have a DVD or CD ready to install your Ubuntu Desktop system. Just insert your DVD/CD, click on your virtual machine's Settings button, go to the CD/DVD-ROM category, and select the Host CD/DVD drive option instead of ISO Image File.
Whichever option you choose, your virtual machine will start to boot like a real physical PC! In the following section you'll get to see it with your own eyes...
Installing Ubuntu Linux on your VM
Now everything's ready to start installing Ubuntu! At last you're about to see this wonderful piece of software in action...
Time for action – installing Ubuntu Desktop on your VM
Ok, it's time to try out our new toy! Get ready for the ride of your life...
- Click on the Start button to start your virtual machine:
- An Information dialog will appear to tell you that the Auto capture keyboard option is turned on. Enable the Do not show this message again option, and click on OK to continue.
- Another Information dialog will show up to tell you about the color depth of your virtual machine. Enable the Do not show this message again option, and click on OK to continue.
- The Ubuntu menu screen will show up, along with a pop-up menu where you can select the language of installation. Click anywhere inside the virtual machine screen, and the following information dialog will pop up:
- Enable the Do not show this message again, and click on Capture to continue. The mouse pointer will disappear, and you will be able to move along the language menu. Select the English option, and press Enter to continue.
- Now select the Install Ubuntu option on the Ubuntu start-up menu, and press Enter:
- Ubuntu will start to boot and, depending on your hardware, it will take some time to boot up completely. A red bar below the Ubuntu logo will appear to show the progress of the booting process (the bar should turn completely yellow when it's finished).
- At the end of the Ubuntu booting process, the Welcome screen will appear, as shown below:
- Select the language you want to use for the installation process (in this exercise, we'll stick with English). Click on Forward to continue. Select your Region and City in the Where are you? screen, and click on Forward to continue.
- The Keyboard layout screen will appear next. You can leave the default option if you're using a typical QWERTY keyboard or choose an appropriate layout for your keyboard. To be sure the layout you chose works with your keyboard, type something into the test box. Click on Forward when you're ready to continue the installation process.
- The Prepare disk space Use the entire disk) to let Ubuntu prepare the disk for you. Click on Forward to continue.
- On the next screen (Who are you?), you need to fill in your name, username, password, and your computer's name. You can also choose to login automatically or require a password to login. Use the following screenshot as a guide, but remember to replace my personal info with yours! Click on Forward when you're ready to continue:
- The Ready to Install screen will show up next with a summary of all the settings you chose for the Ubuntu installation. Click on Install when you're ready to begin the installation process.
- Ubuntu will start to install in your virtual machine. An Installing System dialog will show you the installation progress:
- After some time (depending on your hardware speed), the Installation Complete dialog will appear. Click on Restart Now to exit the installer.
- Eventually, the Ubuntu logo will show up. In a real PC, you would have to remove the installation disc and press Enter. In this case, you need to shutdown the virtual machine and change the CD-DVD Rom drive setting. Hit the Right-Ctrl key to uncapture the mouse so you can move it to select the Machine | Close option from the VirtualBox main menu:
- The Close Virtual Machine dialog will appear next. Select the Power off the machine option, and click on OK to continue.
- VirtualBox will shutdown the virtual machine, and you'll return to the main screen. Now click on the Settings button to open the UbuntuVB – Settings dialog, go to the Storage category, select the ubuntu-9.10-desktop-i386. iso image in the Storage Tree panel; then click on the CD/DVD Device list box, and select the Empty option to remove the Ubuntu ISO image:
Remember you can press Right-Ctrl, the default host key, at any time to uncapture the keyboard and mouse so you can move your mouse pointer out of the virtual machine screen.
Remember you're using a virtual hard disk and not the physical hard drive of your real PC; it's perfectly ok to use the entire virtual hard disk for your Ubuntu guest operating system; the rest of the files in your real hard drive won't be affected.
Click on OK to close the UbuntuVB – Settings dialog. Your virtual machine is now ready to start Ubuntu Linux for the first time!
What just happened?
Ok, you mixed up all the ingredients, baked the mix, and now the cake is ready to eat! Sorry about the analogy, but I was hungry at the time I wrote this!
Personally, I think this is one of the coolest things I've seen in the last few years... Installing a completely standalone guest operating system inside a host operating system with just a few clicks... Whew! Now we'll really start to squeeze all the juice out of our hardware! But before jumping to the next exercise, there are a few things I want to talk about.
Every time you start a virtual machine in VirtualBox, it has to share the keyboard and the mouse with your real PC. The Auto capture keyboard feature lets your virtual machine 'capture' all the keyboard action automatically every time you activate its window, and it's enabled by default on every new virtual machine. As you saw in step 2, an information dialog shows up when starting a virtual machine for the first time to tell you about this feature.
Also, if you click with your mouse inside the virtual machine's window, it will 'capture' all your mouse movements, as the information dialog in step 4 indicates. And how can we 'uncapture' the keyboard and the mouse to use it outside the virtual machine again? VirtualBox uses a special key, called the Host Key, for this purpose. By default, the host key is Right Ctrl.
To redefine the host key, you need to go to the VirtualBox main screen and select File | Preferences in the main menu:
Then you need to select the Input category in the VirtualBox – Settings dialog, click on the Host Key field, and then hit the key you want to use as the new host key. Finally, you just need to click on the OK button to apply the changes.
Once you define the key you want to use as the host key, you can use it to 'capture' and 'uncapture' the keyboard and the mouse in your virtual machine. Every VM shows the actual state of the host key at the bottom-right part of its main window:
In short, to use your virtual machine, you need to move your mouse inside its main window and click on it. You can also select the virtual machine's window and hit the host key to 'capture' the keyboard and the mouse. Then, if you want to exit your virtual machine and use something on your host PC, you just hit the host key, and you can move your mouse out of the virtual machine's window, along with your keyboard. Simple enough, right?
The last thing I want to mention is the color depth of your virtual machine's screen. In step 3 of the previous exercise, an information dialog appeared on your virtual machine to tell you about this. Now let's just try out your new Ubuntu virtual machine!
If you have read this article you may be interested to view :