October 5, 2008

Going Virtual with VirtualBox

TechTips - 187

By Scott Nesbitt – Sunday, September 28, 2008

PullQuote187For whatever reason, many computer users think that their desktop computers can only run one operating system at a time. Windows PC only run Windows. Macs only run Mac OS. Linux machines only run Linux. But that's far from the truth.

There are a number of ways in which you can run more than one operating system on a computer. A popular and venerable way is multi-booting. Another is using an application layer like Crossover. But the solution that's gained popularity in recent years is virtualization.

A quick look at virtualization

Virtualization – in the case of this TechTip, operating system level virtualization – is a form of software sleight of hand. The trickery involved enables a computer to run two or more operating systems simultaneously. There are two types of operating system involved. The first is the host operating system, which runs the virtualization software. The second is the guest operating system, which runs inside a space that the virtualization software and the host operating system allocate to the guest.

Using virtualization, you can run guest operating system in isolation from the host but at the same time. The virtualization software enables you to allocate system resources – like hard drive space and memory – to the guest operating systems. And the virtualization software can also simulate the instruction set that a guest operating system requires.

Advantages

Why virtualize? It's often a lot easier and more efficient than multi-booting or using an application layer. With multi-booting, you need to partition your hard drive, and that could lead to problems with the partition table. I've talked to more than a few people who tried multi-booting, but who found that they could only boot into one of the operating systems that they installed. And unlike an application layer, a virtual instance allows you to take advantage of all of the features of an operating system rather than just a subset of them.

The benefits of using virtualization include the ability to consolidate multiple servers on to a single piece of hardware. That cuts down on hardware and power costs, and enables companies (or even individuals) to decommission older, creaky hardware. For the desktop user (someone like you, obviously), using virtualization allows you to work with multiple operating systems without the need for several PCs, and (as mentioned above) without worrying about any weirdness that might occur when you try to partition a hard drive.


Virtualization on your desktop with VirtualBox

There are a growing number of virtualization products out there. VMWare is popular in the data center and on the desktop. Other, well-known ones include Xen, and Microsoft psa and propecia Virtual PC for Windows. Parallels lets Mac users run Windows seamlessly. This TechTip looks at VirtualBox, a popular and flexible virtualization app. It runs on several operating systems and supports a wide array of
guest operating systems.

Note : This TechTip discusses running Windows XP on Linux. The concepts and procedures are similar for most other host operating systems.


Up and running

Obviously, the first thing that you need to do is download and install VirtualBox. There are installers for several flavors of Linux (including Ubuntu, Debian, Red Hat, and openSUSE), as well as for Mac OS, Windows, and Solaris.

The installers are binaries – you just need to download and run them. For my Linux-powered laptop, I downloaded the installer for all distributions, which has the extension. run. To run the installer, open a terminal and navigate to the directory into which you downloaded the installer. Then, type the command sudo./VirtualBox-2.0.0-36011-Linux_x86.run (substitute the name of the installer, if necessary).

If you get an error telling you that the file can't be found, then type the command chmod +x VirtualBox-2.0.0-36011-Linux_x86.run to make the installer executable. Then, run the previous command again.

A graphical wizard will guide you through the process of putting the software on your hard drive. When the process is complete, you'll have a new menu item to launch VirtualBox. In Ubuntu, this is System Tools > Sun xVM VirtualBox.


Installing a guest operating system

Now it’s time to install the guest operating system. In this case, it's Windows XP Pro. There are two steps to this. First, you need to create a new virtual machine. Then you perform the actual installation of the guest operating system.


Creating the virtual machine

In the VirtualBox window, click New to start the Create New Virtual Machine wizard. The wizard will walk you through the process, but here is some of the information that you'll have to supply:

  • The name of the virtual machine, as it will appear in VirtualBox. I chose WinXP; not the most clever name, I admit…

  • The type of guest operating system that you're installing.

  • The amount of memory that you're making available to the virtual machine. The default is 192 MB, but you can specify up to the maximum amount of memory that your computer has. Remember, though, that any memory that you give to the guest operating system is not available to the host.

  • The size of the virtual hard disk for the virtual machine. You can do this in two ways: either a dynamically-expanding disk (which grows as your guest operating system grows), or a fixed-size disk (in which you allocate a fixed amount of space for the guest operating system).

  • A name for the virtual disk.

Once you've done all that, VirtualBox will create the virtual hard disk. This can take several minutes, depending on the size that you specified for the disk. Once that's done, you can install the guest operating system.

Installing the guest operating system

Installing the guest operating system is quite easy. You can do it from an ISO image or from a CD/DVD. In my case, I had a Windows XP Pro CD. Assuming that you're installing from a CD, just pop it into your CR-ROM drive and then start VirtualBox. In the main window, click the name of the virtual machine and then click Start. The virtual machine will read the CD and start the installer.

All you have to do is follow the installation program. It is that easy. Depending on the operating system, the amount of memory your system packs, and the speed of the CPU, this process could take anywhere from a few minutes to half an hour.

Once the process is complete, all you need to do is click Start in the VirtualBox window to start the guest operating system.


Tweaking the settings

Before you start using the guest operating system, you should configure it to your liking. Just click Settings, and you can adjust the various settings for your virtual machine. Some of the things you can do include change the amount of RAM and video memory set aside for the virtual machine, changing the boot order of the disks, and enabling  the guest operating system to access your CD-ROM drive and any USB flash drives that are attached to your machine.

You can also adjust the audio settings, and enable the guest operating system to access one or more folders on the host. For the latter, you'll need to install guest additions. More about those in a moment.

Of course, networking is probably very important to you. To enable the guest operating system to access your network, or the Internet, click the Network option in the Settings window. Select your network adapter from the list, and from the Attached to list choose NAT 9 Network Address Translation. Also, ensure that the Cable Connected option is checked.

If you're using a wireless connection, then do the above. A lot ofdocumentation for VirtualBox discusses creating a network bridge to enable a guest operating system to use the wireless adapter onyour computer. I found that if you have the Cable Connected option checked, wireless works just fine. Your mileage may vary, though.

 

Installing the guest additions

You'll notice, though, that some things aren't quite right about the guest operating system. The screen is small, mouse support is kind of wonky, and you can't share information between the clipboards of the guest and host operating systems. You can fix that by installing guest additions. Guest additions are a set of drivers that help the guest operating system work more seamlessly with the host. The guest additions include:

  • Shared folders and clipboard

  • Better mouse integration

  • The ability to move between guest and host operating system windows seamlessly. Without the guest additions, you need to press a hot key move between them

  • Better video support, including the ability to dynamically resize the guest's window

In the latest version of VirtualBox (2.0.0 at the time of writing), you can install the guest additions by starting the guest operating system and then choosing Devices > Install Guest Additions. A wizard will walk you through the installation process. You might have to restart the guest operating system for the changes to take effect.

 

Using your virtual machine

Everything that's detailed above seems like a lot of work. It isn't and you only have to do it once. After it's done, your virtual machine is ready to use. As I mentioned, I'm primarily a Linux user. But for some of my professional work, I need to use various bits of Windows software. That's where VirtualBox truly comes in handy. I can run all of that software without resorting to using two laptops. In fact, after installing VirtualBox I got rid of my Windows-powered ThinkPad. My desk is a lot less cluttered, and I have one less piece of hardware to worry about.

If you need to run multiple operating systems on a single computer, or just want to test out another operating system before committing to it, you'll find that VirtualBox gets the job done nicely. It's easy to use, and makes a seemingly complex chores like virtualization easy.

Permalink • Print • Comment

Leave a comment

You must be logged in to post a comment.

Made with WordPress and an easy to customize WordPress theme • Sky Gold skin by Denis de Bernardy