Showing posts with label virtualization. Show all posts
Showing posts with label virtualization. Show all posts

2014-01-17

Root into a virtual machine (KVM)

Scenario: I have a KVM virtualization server with a number of VMs defined. Suddenly, I cannot log in as root to one of the VMs. I will need to reset the root password. The "normal" methods like adding single or init=/bin/bash to the kernel boot line in GRUB do not work. The only option left is to boot from a rescue disc, but this is a virtual machine -- there is no DVD drive. Oh, no -- what to do?

NEWS FLASH: I just learned from a colleague that there is a much easier method. It is possible to chroot directly into the VM from the virtualization host. Will post detailed instructions as soon as I get them. Until then, there is always the "long route" described below.

2013-10-04

KVM: boot VM from PXE or ISO image

Boot from PXE

Scenario: you have a KVM virtualization host with some VMs and you want to boot one of them from PXE instead of the virtual hard drive.

Magic incantation:
  1. edit the /kvm/vm/[guestname].xml file
  2. find the line that says <boot dev='hd'/>
  3. add a line before it that says <boot dev='network'/>

Boot from ISO

Second scenario: you have a KVM virtualization host with some VMs and you want to boot one of them from an ISO that you have downloaded.

Magic incantations available here:
* http://mycfg.net/articles/booting-from-a-cdrom-in-a-kvm-guest-with-libvirt.html

2013-04-30

Virtualize Windows XP

It seems like it will only be a matter of time before someone I know needs to virtualize a Windows XP instance, so I decided to look into it.

The procedure is not exactly straightforward; one must navigate around several obstacles:
  1. At install-time, Windows XP stores ("remembers") the HW signature of the IDE/SATA controller it was installed to, and will refuse to boot from any other controller. This behavior can be disabled by making certain changes to the Registry. This is accomplished using the MergeIDE utility.
  2. Once you get past the controller obstacle and get the virtualized XP instance to boot, it will still think it's running on different hardware (even when it isn't), because it also remembers DMI information from the BIOS.
  3. The DMI information can be dumped and then programmed into the virtual machine configuration file (XML). How exactly to do this is not clear to me, but there are some pointers below.
  4. In terms of licensing, once the virtualized instance of Windows XP is up and running, one should purchase a new license for it, just to be on the safe side. Stay legal, folks, and by "legal" I mean whatever Microsoft says it means.

Here are some links:

Salient part of the latter:
"The Windows XP volume license registers your license key against the BIOS for that machine. When Virtualbox loads your guest operating system it presents virtual BIOS information to that OS, which obviously invalidates the license you currently have installed for XP since from it's point of view it's now on a different machine.

In order to fix this you have to modify the settings of your VM config file in order to report your physical BIOS information.

First you have to get the information using the dmidecode command. To get the DMI bios information and the the DMI system information run: dmidecode -t0 and dmidecode -t1 respectively.

You then have to append this information as a set of key-value pairs to your virtual machine settings. A list of all the variables can be found in section 9.13 of the VirtualBox user guide."

2013-04-16

kde5 kwallet ssh-agent cache passphrase

Known working instructions for caching SSH passphrase in kwallet on openSUSE distros using KDE5.

2013-03-10

How to mount VirtualBox VDI image in Linux

OK, how _do_ you mount a VirtualBox VDI image in Linux?

Well, here's how Jeff Waugh does it, anyway.

2013-02-14

How to grow a raw disk image

The problem: I have a raw disk image for use in a virtual machine, and it's too small. I want to make it bigger. In other words, I want to increase the size of the disk.

When I poked around, I found this amusing blog entry by Michael Orlitzky that showed me how to do it. Michael has some extra steps in there, because he wanted to grow a KVM disk image. In this blog entry I will only show the bare minimum, and it is very, very easy:

Step 0: Install qemu-tools package for your distribution (I'm using openSUSE 12.2):
# zypper install qemu-tools

Step 1: Create some additional space (8 GB in this example):
$ qemu-img create -f raw additional.raw 8G

Step 2: Append the additional space to the end of the raw image:
$ cat additional.raw >> too_small_image.raw
$ mv too_small_image.raw big_enough_now_image.raw
$ rm additional.raw

That's all there is to it. It may be possible to replace the qemu-img command in Step 1 with a dd command that creates a file consisting of all zeroes. That way, I wouldn't have had to install an extra package.

Convert the raw image into a VDI container for VirtualBox


$ VBoxManage convertfromraw big_enough_now_image.raw big_enough_now_image.vdi \
--format vdi

Convert the raw image into a qcow2 container for Qemu/KVM


$ qemu-img convert -f raw big_enough_now_image.raw -O qcow2 \
big_enough_now_image.img

2013-01-07

How to use virsh (KVM)

First, find out the names of the virtual machines you're running (including those that are shut off):
# virsh list --all

Then, connect to the text console of the VM you're interested in:
# virsh console VMNAME
Important: To exit the console, use CTRL-] (To connect to the graphics console, use VNC.)

Other useful commands:
# # Hard power off:
# virsh destroy VMNAME 
#
# # Power on:
# virsh create VMNAME
#
# # Remove a VM that you can't destroy
# virsh undefine VMNAME

Read more here:




How to tell if a machine is virtual (KVM) or not?

# cat /proc/cpuinfo

If the CPU is listed as "QEMU Virtual CPU", then the machine is virtual (KVM).