Wednesday, July 28, 2010

Windows 7 Activation Woes

Since getting KVM and QEMU up and running and installing Windows 7 on a virtual disk (a necessary evil if I'm going to use this laptop for work), I ran into some activation woes, with Windows 7 unable to activate the volume media
Windows could not be activated.
Key management services (KMS) host could not be located in domain name system (DNS), please have your system adminstrator verify that a KMS is published correctly in DNS.
Error: 0x80092328
Description:
DNS name does not exist

Unlike the days of my youth and with the help of an MSDN subscription, my media and key is actually legitimate. After a bit of searching, I found KB929826, which outlined how to fix the problem- a simple one line command to be run as administrator:

slmgr -ipk XXXX-XXXX-XXXX-XXXX-XXXX

and all issues were solved:



Tuesday, July 27, 2010

Automounting NTFS drives

As I cited in an earlier post, RHEL 5 still doesn't have native NTFS support. After installing the NTFS support in RHEL 5, I would still have to manually mount my drive every time I plugged it in, after receving the below error:



Not a mission critical problem, more just an annoyance. After a bit of Googling, I found this simple fix to automount the drive:

ln -s /sbin/mount.ntfs-3g /sbin/mount.ntfs

And voila- no errors and it automounts like it should in the first place.

Sunday, July 25, 2010

Flip the switch from 'Broken' to 'Fixed'

The key to using KVM: ENABLE VIRTUALIZATION IN THE BIOS

In the words of the famous Homer Simpson- "Doh!"
After doing a bit more research and piecing together why I could boot into Windows, but then everything would come to grinding halt, it occured to me to check the BIOS to ensure that virtualization is enabled, as I was continuously getting an error when starting a VM: "Could not initialize KVM, will disable KVM support".

Seeing as my intel processor supports virtualization (egrep vmx --color=always /proc/cpuinfo), why wouldn't KVM start correctly? Furthermore, modprobe kvm-intel wouldn't load correctly.

After a couple of audible, "huh."s it occured to me to check the BIOS on the HP laptop to ensure CPU virtualization was enabled. SURPRISE! It wasn't. After enabling it in the BIOS and booting, and with a little more confidence, I ran into the same problem, "Could not initialize KVM, will disable KVM support." After a bit of Googling, I found that for whatever reason, a full shutdown and cold boot were necessary for the BIOS setting to take effect. Sure enough, after a reboot and starting my VM:


And with the -CDROM option pointing to my Windows 7 ISO, I made it past the infinite "setup is starting" page, and was able to install Windows 7:



As is usually the case, the issues experienced with KVM were due to user error rather than shoddy development.


So some tasks to complete to ensure that my work laptop will actually facilitate work:
  • Ensure I can share files between my RHEL host and KVM guests
  • Ensure that USB devices can be used on KVM guests
  • Provide my work Windows 7 guest with enough disk space to accomodate all of my work documents
After a bit of consideration, I think my best approach will be to keep my guest OS on a different virtual disk image than my documents. That way I can keep a separate non-OS partition with all of my documents on it and boot my virtual disks with the -hdb option, thus allowing me to easily switch from Windows 7 to Windows XP guests.

Some links I found useful or potentially useful:
How to resize a libvirt image
QEMU Monitor Commands
QEMU USB Handling

Thursday, July 8, 2010

RHEL 5 and KVM for Enterprise Notebook

So after finally successfully downloading and burning RHEL 5 Client x86_64 and obtaining a new hard drive for my notebook, I'm ready to install RHEL and test KVM.

The RHEL install was relatively painless, as Anaconda is an amazingly simple installation utility. Unfortunately, the first road bump I ran into was that the RHEL Client installation disk does not come with any virtualization package options (Xen, KVM, etc). No worries though, I was sure I could simply find the packages on the RedHat Network and push them down that way.

Small problem: RHEL didn't recognize my wireless card. After a quick lspci and some grepping:

lspci | grep wireless

I found my card and a nice step-by-step guide to install the necessary firmware to get it working.

After getting wireless up and running, I found that after registering my RH system, it did not appear in my RedHat systems on RHN, therefore I couldn't target packages to be automatically pushed to my laptop. After a bit of research on the RedHat Knowledgebase, I determined that this was because of the way my enterprise evaluation account was set up- my systems would be assigned to the Organization Administrator. Being the impatient person I am, I decided to just pull down the necessary packages manually instead of waiting for a response from my company's RHEL partner contact.

It was a bit of a tedious process, as I had to not only pull down the necessary RPMs, but also their dependencies. Anyone who's had experience working with RedHat, SuSE, or any other RPM-based distro before yum became available knows how frustrating it can be. I actually documented each package I had to pull down and listed them in the original version of this post, however Blogger didn't do a good job of saving the post, so that list has been lost in the series of tubes.

After pulling down all the packages I needed (apparently RHEL only officially supports up to version 83 of KVM) and checking the Guest Support Status, it looked as though I'd be good to go with virtualizing Windows Vista or 7 on KVM.

The first thing I tried was to convert the VMWare VMDK virtual image of my Windows Vista laptop into qemu's qcow2 format, as outlined in a link from my previous post. I quickly discovered, however, that RHEL does not natively support reading/writing to NTFS filesystems. What!? What is this, 1998? After a bit of Googling, I found this NTFS support in RHEL 5 blog post outlining the basic packages needed. One thing to note is that the dev package (kmdl) is not necessary and will generate a compile-time error if your kernel is not 2.6.18. I went ahead and just skipped installing it and was able to mount ntfs file systems fine. I figured I'd try configuring the automounter later, after I got my converted Vista image converted:

qemu-img convert Vista.vmdk -O qcow2 /home//virtual_machines/Vista.qcow2

The conversion appeared to complete successfully, however it did take a good bit of time (roughly 30 minutes).

kvm -hda Ubuntu-copy.qcow2 -net nic -net user -m 512

Upon attempting to boot this image, I received a blank screen with no indication of the guestOS trying to boot. After a couple more attempts, I did get the "Windows failed to start properly" menu and tried booting into safe mode, however this too failed. No sweat, there's a chance that my virtual image didn't convert well in the P2V, and I haven't yet tested it on VMWare, so I figured why not start from scratch with a brand new Windows 7 image?
qemu-kvm -hda win7.img -cdrom win27.iso -m 1024 -boot d
Success! (at least initially...) The Win7 ISO booted up beautifully and actually relatively quickly. I was able to run through the initial steps to install Windows 7- selecting time zone settings, user settings, etc. That was until I got to the "Setup is Starting" screen and where I was left in indefinite purgatory. I did a bit of googling and found this bugzilla report outlining the same issue I was experiencing, but with no resolution. Tracing duplicate bugs led to no where, and thus again I was stymied.

Alright, well I don't really need Windows 7, why not just use XP Professional? Being an older OS, perhaps it would install more cleanly on KVM. As before, the ISO booted great, I ran through all the OS options, and it actually started to install... only to later hang just as its younger brother did before. After a few repeated attempts (one allowed to run overnight), it was obvious that there was little I could do to get a Windows OS up and running on this version of KVM.

Alright, well maybe the version packages I chose to install KVM were incomplete or still unstable. Afterall, the kvm-qemu package was listed as in Beta. So I decided to scrap my RHEL client idea and go for the real deal: RHEL 5 Server, whose installation media actually contains virtualization packages. Despite this more by-the-book (and probably more officially supported) attempt, I ran into identical problems as noted above

So the conclusion: KVM has potential as an alternative to a baremetal hypervisor, perhaps just not version 83. RedHat is striving to make RHEV (RedHat's implementation of KVM) a market contender for a low-cost virtualization solution, however it seems this may be a bit premature. Maybe they should give their internal developers a bit more time to design and test before selling that horse.

While the battle may be lost, the war is far from over- next attempt: the more tried and true Xen!

Packages: kvm-qemu-img

Links:
HowTos/KVM - CentOS
RHEL Virtualization Guide
(dev package not required- complains if kernel is different)

P2V of Vista machine failed