Testing environment: Setting up VirtualBox for easy VM usage
Tags: linux, testing environment, virtual machine, virtualbox, windows
One of the first things we had to do here at OlinData is set up a testing environment. Many customers have many different OS environments and we want to be able to accomodate all of them. With the setup described here, we will be able to easily set up many different OS’s, regardless of the operating system we use in our every day work and without having to own a gazillion different computers that are hardly ever used.
First things first: Let’s say I’m running Vista (which I am unfortunately
) and I would like to set up a linux server on CentOS 5.2. I could of course install it on a different computer, or set up a multi-boot system. This would require another computer, or messing with my current computer at the risk of destroying it’s configuration. What if I could run CentOS inside Windows Vista in a confined environment?
Enter Virtual Machines (VMs). They do exactly what the word says: they allow you to run a virtual computer with a different operating system (commonly referred to as the guest OS) inside your current operating system (the host OS).
There are a bunch of different programs that you can use for VM’s nowadays. I decided to go with VirtualBox 2 for three reasons: 1) It is free and there’s even an open source edition available 2) It is cross platform, which enables me to only have to learn one program which I can use on multiple operating systems, and 3) I like it
Setting up VirtualBox is very easy: go to the VirtualBox website, download the file for your host OS of preference and install it.
After you install VirtualBox, start it and you should see a screen like this. Time to create our first VM and get it ready to install a guest OS on it! We will assume for now that we want to set up a server running CentOS 5.2.
Click the New button on the toolbar to create a new VM (duh
). In the first screen, choose a name for the VM that will clearly mark the machine. Especially when you have multiple VM’s in the future, that will prove very handy. I tend to name them after the OS and version of what I’m installing, e.g. “CentOS 5.2″. For CentOS, you can choose an “OS Type” of Red Hat. Click Next.
Next, we will have to select how much memory this VM will have available. Depending on how much RAM you have in your machine, choose a decent amount, but not too much. I like 512 or 1024 MB depending on wether you have 2GB or 4GB RAM on the host. Click next to continue to the next screen.
Here we will set up a hard drive for the machine. Click the “New” button to create a new virtual disk we can use as our hard drive. Choose a dynamically expanding image, so even though VirtualBox will report to the guest OS the size you choose, the file on your host OS will only take as much space (well, a little bit more actually) as there is actual data on the guest OS’s hard drive. Next, choose a name and a size for the hard drive. I choose “CentOS 5.2″ and 8GB in our case, more than enough for a test environment. If you want you can place the .VDI file that represents our hard drive in a different location (e.g. on a different partition).
Finish the virtual disk wizard and select the hard drive we just created as a boot hard disk. Click next to view the summary of your choices. In my case it looks like the screenshot you see here. Click Finish to finish the wizard. Our new machine is created and we can see it in it’s powered off state. Just a few more things to configure before we get started!
Select the VM we just created and click the settings button on the toolbar. Adjust the following settings:
- Under General -> Advanced, untick floppy from the boot order as it is not necessary for our use. Adjust the snapshot folder if you wish to change it.
- Under CD/DVD-ROM, mount a cd to the machine. If you have an ISO image of the guest OS you want to install choose the image here, so it will be recognised as a CD player by the guest OS when we boot it in a minute. If you have a physical CD, choose Host CD/DVD drive and adjust teh settings as you wish.
For now, the rest of the settings can stay as they are. We can always adjust them later when needed.
We are ready to go! Your VirtualBox screen should now look something like this screenshot.
In the next blog post, we will talk about setting up CentOS 5.2 on our VM. Stay tuned!



FABIO MOSCA said:
Aug 11, 09 at 14:55How to start a VM via Remote Desktop Connection?
Zoe Ali said:
Jul 27, 10 at 08:12operating systems can either make or break your system that is why it is wise to choose a vey stable one.”`,
LYLE said:
Oct 22, 11 at 17:28just had an awesome time dialing into #teatimeKL with @kurrik to discuss the Twitter API – huge thanks to @nazroll for putting it together!