With Windows 7 coming out soon it's an excellent reminder that, when new releases of operating systems come out, it's always nice to have the ability to test them. This makes perfect sense if you are considering rolling out that operating system, or you need to train your staff. In some situations you can just throw that operating system at some hardware and be done with it. But what if you either don't have the spare hardware around or you want more than one user to be able to test that operating system
A virtual environment, created by a piece of software, such as VirtualBox, is an encapsulated environment in which the operating system thinks it is being installed natively. The major benefit is that the operating system reacts as if it is installed natively, so you get full function from your operating system and the subsequent applications you will install.
I'll show you how to install VirtualBox on an Ubuntu 9.04 host followed by a Windows 7 guest installation. Once the Windows 7 installation is complete, I'll go over some configuration tweaks that will make Windows 7 run in a proper resolution and allow you to run the virtual machine remotely.
I am going to walk you through installing the closed source edition of VirtualBox. There is an open source edition (OSE), but it does not have a few of the features that might be a necessity for business environments such as VRDB (for remote connections) and USB support.
To install VirtualBox on Ubuntu you will first have to add the proper repositories for apt. To do this, open up a terminal window and enter the following command:
sudo nano /etc/apt/sources.list
After you enter your sudo password your sources.list file will be open and you will need to add the following line at the bottom of the file:
deb http://download.virtualbox.org/virtualbox/debian jaunty non-freeSave the file with the [Ctrl]X combination. Before you can update apt you have to add the VirtualBox repository key. First download the key from the VirtualBox site. Save this key to your ~/ directory. Now it's time to add the key with the command:
sudo apt-key add ~/sun_vbox.asc
Once you get the OK from the apt-key command it is time to update apt with the command:
sudo apt-get update
Depending upon the speed of your connection, downloading the headers for the repository shouldn't take too long. Once this has completed, you are ready to issue the command to install VirtualBox. Since the goal is to install the closed source version of VirtualBox, the command to install will be:
sudo apt-get install virtualbox-2.2During this installation you will have to OK the installation of the kernel module for your current running kernel. If you do not do this, VirtualBox will not run. Once the installation is complete you will need to then add your user to the vboxusers group. To do this, issue the command:
sudo gpasswd -a USERNAME vboxusers
Where USERNAME is the actual name of the user you want to add.
Before you fire up VirtualBox, you will need to take care of one more configuration. In order to enable USB support you have to add the ID of the vboxusers group to a new line in the /etc/fstab file. The first step for this is to find out the ID number of vboxusers, which is done with the following command:
grep vboxusers /etc/group
The above command will report something like:
Where XXX is the ID of your vboxusers group. Now you need to add a new line to the /etc/fstab file. This line will look like:
none /proc/bus/usb usbfs devgid=XXX,devmode=664 0 0
Where XXX is the ID number of your vboxusers group.Because you installed a new kernel module, as well as added a line to /etc/fstab you may as well, for simplicity's sake, reboot your machine. NOTE: You can have your /etc/fstab take effect without a reboot by issuing the command:
sudo mount -a
But because the kernel module was added, go ahead and reboot. After the reboot is complete, you are ready to fire up VirtualBox.
Running VirtualBoxYou will find this version of VirtualBox in GNOME's System Tools submenu of the Application menu. When you first open VirtualBox you will not have any virtual machines listed (as you see in Figure A below). So the first thing you have to do is create a Virtual Machine.
Not only can you create new Virtual Machines from this window, you can gather all details and change the settings of your virtual machines.To create a new Virtual Machine click on the New button to start the Virtual Machine Wizard. From the greeting screen, click Next. The first screen which will require any action is the "VM Name and OS Type" screen (see Figure B). For Windows 7 you are going to fill out the following information:
- Name: Give this a name indicating the OS version you are using.
- Operating System: Microsoft Windows
- Version: Windows 7
The icon will be selected automatically, based on the operating system.Once you have filled out this information click the Next button. In the next step (Figure C) you must configure the base memory that will allocated to this virtual machine. Now since we are going to install Windows 7 for this VM, it will require at least 1 GB of RAM to function properly. This will require that your host machine have enough RAM to also function well. Figure C
Even though VirtualBox recommends 512 MB of memory, it will not be enough for Windows 7.Configure your RAM and click Next. In this new window (Figure D), a hard disk will have to be created. If you have not yet created a hard disk, the hard disk wizard will automatically pop up. If you have an existing hard disk created, you will have to either select "Create new hard disk" (recommended) or "Use existing hard disk." If you choose the latter, you will erase whatever is on your VM hard disk.
Make sure Boot Hard Disk is selected.
Click Next and the Create New Virtual Disk Wizard will open. After the Welcome screen, the next window only asks if you want a Dyamic or a Fixed-sized disk. Select Dynamic. A Dynamic disk will expand as needed. So if you create a 10 GB dynamic disk, it will not start out as 10 GB, but will expand to 10 GB as needed. If you create a Fixed-sized disk it will start out and remain as 10 GB. Click Next to continue.In the next screen (Figure E) you have to configure the location and size of the disk. Most likely the location will already be chosen for you (it should be the name of your Virtual Machine). The size is configured by sliding the the slider to the right or the left depending upon how large or small you want your disk. Select the size and click Next.
As you can see, there are two instances of Windows 7 here. This can be helpful for testing releases or just different setups.
Installing Windows 7
The beauty of installing Windows 7 within a Virtual Machine is that the installation will be identical to a standard installation. At this point you just insert the CD into your CD/DVD drive, select your new Virtual Machine, and click the Start button on the VirtualBox main window. The installation will go on as you would expect it to.The only hitch you will notice will be in the end when you find the Virtual Machine unable to set the proper resolution for the installation. You must install the Guest Additions for VirtualBox. This is simple. While the Virtual Machine is running, go to the Devices menu and select Install Guest Additions (Figure G).
The Virtual Machine must be running to install Guest Additions.
Now, you will be warned that the Guest Additions CD can not be found. At the same time, the installation will ask if you want to download the Guest Additions image. Click Yes to okay this, and then Download to download the file. When the download is complete you will have to confirm the mounting of the Guest Additions image. Do this and the installation of Guest Additions will begin. The installation of this tool will be a typical Windows application installation. Once the install is complete, you will need to reboot the Virtual Machine (do this by rebooting Windows 7). When Windows 7 has rebooted you will now enjoy:
- Better resolution.
- No need to grab the mouse or release it by clicking the right Ctrl button.
- Running Windows in seamless mode (not inside of an isolated window).
- Copying and pasting between guest and host.
Set up Windows 7 to run remotely
A very nice feature of VirtualBox is the ability to run the Virtual Machine remotely. Normally, all that needs to be done is to set the Virtual Machine for remote access within VirtualBox itself. Windows 7 (and Vista as well) is a different case. You also have to set up the operating system to allow remote access. But first let's configure the VirtualBox options.You first have to close the Virtual Machine. Do not just save the VM state because you will not be able to make any configuration changes. Instead close the VM down. When the VM is powered down, go to the VirtualBox main window, select your Virtual Machine, and click the Settings button. Within the settings window, click on the Remote Display tab and then click the checkbox for "Enable the VRDP Server" (Figure H).
If you have need, you can change the port number for the VRDP server.
Click OK and then power your Windows 7 VM back on. You now have to configure Windows 7 to allow remote connections.When Windows 7 is up and running, click the Start Menu and enter "remote" in the search field. A number of entries will appear (Figure I).
Click OK and you are ready to run your Virtual Machine remotely using the tool you prefer to access remote desktops.Final thoughts
VirtualBox is an amazing tool that will allow you to stretch your budget farther, test your software more securely, train your users more safely, and more. The benefits of employing Virtual Machines are seamingly limitless and VirtualBox makes this not only possible, but simple.
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.