Your best source of information and news about microsoft, software and BIOS on the internet

Vista ARTICLES TOP 50 Spyware Virus Vista SOFT Vista HELP

KVM in Ubuntu - Setup and Virtual Machine Creation Guide



As I posted last night, I paved over my Vista install, and gave into my Linux bug. I’m just a Linux guy at heart, and always will be, I guess :-)

I really did want to play around with KVM though. I never could before, because my last system had a Intel Core2Duo E4600, which while it was a decent chip, the E4xxx series chips and below lack hardware virtualization. This wouldn’t be a big deal for an average user, but there isn’t anything average about me when it comes to computer use (as any of my friends will tell you), and virtualization was one of the reasons for building my new machine.

So, let me start out by giving a brief run-down on what KVM is, and how it works. Actually, I’m not - I’d just be copying and pasting really, so head on over to the KVM home page where you can read all about it. … It’s ok, you can go now, I’ll wait on you!

So, now that you are back, you should be armed with the knowledge that KVM is a virutalization solution for Linux that works in conjunction with QEMU, and provides hardware acceleration via a  Kernel module.

What makes KVM awesome is that it is part of the OS and is not dependent upon a 3rd party vendor to make the magic happen. Also, it’s very easy to maintain as you update your system, and load new kernel revisions, as the module will not break (requiring a re-build unless running DKMS) like VirtualBox and VMware solutions would. Also, it’s far less hassle to manage than Xen, which is entirely unsuitable for a desktop system, as you are in effect running your system in a Virtual on the bare-metal hypervisor. I do still like Xen (in the form of Citrix XenServer) as my preferred Server Virtualization solution.

Although I’m using it in a desktop environment, KVM really is more of a direct competitor to Xen than to a workstation solution like VirtualBox or VMware workstation, and has some very powerful features, I will never tap into here on my home system. By design however, it’s far less intrusive on a standard Linux desktop than Xen. So here is a quick guide on how to turn your Ubuntu install into a nice VM host workstation.

This guide was created using Ubuntu 9.04 (Beta) fully updated as of 04.13.09.

Now, let’s get started. First, we have to install KVM, and the tools we will need. Although there are a few GUI based package managers, I’ll deal with Command-line commands, as they are easier to post here for you to copy and paste, so before we get started, go to ‘Applications’ -> ‘Accessories’ and open up a Terminal window.

First things first, we need to verify that your CPU will support hardware virtualization. To do this, execute the following command in your Terminal:

Intel CPU:

grep vmx /proc/cpuinfo

AMD CPU:

grep svm /proc/cpuinfo

If the above command gives you output, you are good, if you get taken straight back to the $ prompt your CPU does not have hardware virtualization, and I recommend the excellent VirtualBox OSE.

Now that we have verified hardware support on the CPU, let’s install the required packages to get us started. Head back over to your Terminal window, and execute the following command:

sudo apt-get install virt-manager libvirt-bin kvm

This will pull down the required packages, along with any dependencies you may require (depending on your installation). After the packages are installed, we need to make sure that your user account has the appropriate permissions to load the KVM module. To do this, execute this command:

sudo adduser $USER kvm

Now, I need you to bookmark this page, and log out and back in for me, so that we can continue.

Back? Great! now let’s try running the kvm command in a terminal and see what we get! So bring back up a Terminal and execute:

kvm

If you get the following output at the very next line below the command, you are golden:

$ kvm
QEMU PC emulator version 0.9.1 (kvm-62), Copyright (c) 2003-2008 Fabrice Bellard
usage: qemu [options] [disk_image]


(there will be more output, but I truncated here to save space)

On the other hand, if perhaps you skipped my first step, and your CPU does not, in fact support Hardware virutalization, you will get output such as the following:

$ kvm
Could not initialize KVM, will disable KVM support
Ubuntu does not support running KVM without hardware acceleration. Sorry.

Now that we have everything installed, and have verified that our kernel module is loading appropriately, let’s get down to the business of creating a Virtual Machine. I’ll use Windows XP as an example, since that is a popular OS to virtualize on a Linux desktop.

First, verify that you have either a CD-ROM of Windows XP handy, or preferably an .iso file created from a CD (you will find .iso’s much easier to handle in a virtual environment than physical CD’s).

Now, let’s launch the Virtual Machine Manager. Head up to your ‘Applications’ menu and go to the ‘System Tools’ submenu and click on ‘Virtual Machine Manager’

launch_vmm_edit

This should launch the following window:

vmm_edit

Next, right-click ‘localhost (User)’ and click ‘Connect’:

connect_edit

If you already have an Virtual Machines created, they will now show up in tree fashion underneath the main connection. Now to create a Virtual Machine, simply right-click ‘localhost (User)’ again, and choose ‘New’:

new_edit

We are now presented with the New Virtual Machine creation wizard (go ahead and click ‘Forward’):

canvm_edit

On this next screen, you can give your new Virtual Machine a name. Type a name for your VM in the text box and click on ‘Forward’:

name_vm_edit

On the next screen, choose the archetecture of your Virtual Machine, and ensure that KVM is selected for the Hypervisor, and click ‘Forward’ once again:

choose_arch_edit

On this next screen, we will specify what Operating System the guest will be running and what install media we will be using:

os_edit

Next, we will click ‘Browse’ and navigate to the location of our .iso file we will use for our install media:

browse_edit

On this next screen, we will tell the Virtual Machine Manager where we want to create our Virtual Hard Drive image, choose to have an ‘expanding’ file, or choose a physical block device to use as the Hard Drive for our Virtual Machine. As you can see, I have chosen to create a ~14GB fixed size image named WinXP2.img:

virt_hdd_edit

I do reccomend a “fully allocated” HDD image as it will provide better performance.

If you have chosen (as I did) to fully allocate the entire virtual disk now, you will now need to wait on the file to be created. This time can vary depending on the size you specified, and the speed of your Hard Disk (more on HDD setup in a minute).

Next we can specify the number of Virtual CPU’s as well as the amount of memory (RAM) we would like to dedicate to this virtual machine. As you can see, I have selected 1 CPU, and 512MB for RAM.

cpu_mem_edit

Finally, click on ‘Finish’:

finish_edit

Next, our Virtual Machine should boot, and Windows Setup should start:

booting1_edit

And, there you have it - installing, KVM and creating an Windows XP Guest on an Ubuntu host.

A few paragraphs up, I mentioned the HDD setup of the host. I wanted to touch bases on this for just a minute. If you are “really” serious about virtualization, I highly recommend having at least two physical HDD’s in your machine - one for your / and /home mounts, and one for a /virtuals mount-point. I personally have three. My main drive is a 10,000RPM drive that has / , /home and swap my second drive is a 7,200RPM drive that is 320GB and holds my Virtual Machines and is mounted as /virtuals . I also have a 1TB 7,200RPM drive that is mounted as /data and basically holds all of my personal data, including my ISO files. This really helps spread the I/O load of the system, and having at least a separate hard drive to hold your virtual images will help a lot!

Good luck, and I hope this gets you started!

Popularity: 1%


Written by jaysonrowe. Read more great feeds at is source WEBSITE
no comments.
Read more articles on otherSoftware and Computing.

Related articles

No comments

There are still no comments on this article.

Leave your comment...

If you want to leave your comment on this article, simply fill out the next form:




You can use these XHTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> .