Skip to main content

a silhouette of a person's head and shoulders, used as a default avatar

Migrating a Xen VM to KVM on openSUSE

Xen and KVM are the two major virtualization techologies that are freely available on linux. Although they are quite comparable performance wise, it still may be interesting to convert a Xen virtual machine to a KVM virtual machine.

Xen and KVM both use very similar images. However, there are some subtle differences in the setup:

  1. Xen block devices use the names “xvd?” where KVM uses “vd?”.
  2. The serial device in Xen is “xvc0” while on KVM it is “ttyS0”.
  3. Xen does not use the bootloader from the image but directly accesses the boot directory while KVM really uses the bootmanager.
  4. The modules that are needed for block devices are different.
  5. Although virsh supports both, Xen and KVM, the XML configuration is still somewhat different.

The easiest way would be to just install the necessary packages and do the needed modifications on a running Xen guest, however, if you don’t have your Xen host anymore, you would be busted. Therefore, lets do the migration of an image just on the KVM host.

First, make the image accessible with “kpartx”. To do this run the command

> kpartx -a disk0.raw -v
add map loop0p1 (253:1): 0 319488 linear /dev/loop0 2048
add map loop0p2 (253:2): 0 16435200 linear /dev/loop0 321536

Now, determine which one is a real file system:

> lsblk -f /dev/mapper/loop0p?
NAME           FSTYPE LABEL MOUNTPOINT
loop0p1 (dm-1) swap
loop0p2 (dm-2) ext3

Obviously the device “/dev/mapper/loop0p2” is our root file system that we need to access. Lets mount it and add all the needed devices:

mount /dev/mapper/loop0p2 /mnt
mount -o bind /dev /mnt/dev

Now, copy the needed kernel to the file system and do a “chroot” there:

cp kernel-default.rpm kernel-default-base.rpm /mnt/tmp
chroot /mnt
mount /sys
mount /proc

Next, update several configuration files:

  1. /etc/inittab : comment the line starting with S0 and containing xvc0
  2. /etc/inittab : uncomment line starting with S0 and containing ttyS0. Change the speed to 115200 if needed.
  3. /etc/securetty : remove xvc0 and add ttyS0
  4. /etc/sysconfig/kernel : remove modules starting with xen from “INITRD_MODULES” and add “virtio_blk virtio” instead.
  5. /etc/fstab : remove the “x” from “/dev/xvda” (and possibly more needed block devices)
  6. /boot/grub/device.map : change from “/dev/xvda” to “/dev/vda”
  7. /boot/grub/menu.lst :  comment line starting with gfxmenu
  8. /boot/grub/menu.lst : change the kernel and initrd lines to contain the kernel starting with “vmlinuz” and the default initrd as available in “/boot”.
  9. /boot/grub/menu.lst : fix the kernel parameters to contain the right root and console device, similar to: “root=/dev/vda2 console=ttyS0”.

Now, it is time to install the kernel:

rpm -Uhv /root/kernel-default.rpm /root/kernel-default-base.rpm

The only remaining task now is running “mkinitrd”. There will show up some error messages about not having the right root device available, which is correct. But the command commonly will work anyway.

To finish the work on the image, only some cleanup is needed:

  1. umount /sys
  2. umount /proc
  3. exit
  4. umount /mnt/dev
  5. umount /mnt
  6. kpartx -d disk0.raw

To start the image, the easiest way is to use “vm-install” and select activating an existing image “I have a disk or disk image …”. If it is just for testing, you can also use a command link this:

qemu-kvm \
-drive file=/kvm/images/disk0.raw,id=root,if=virtio \
-m 1024M -nographic

This should bring up your previous Xen image on a KVM machine.

a silhouette of a person's head and shoulders, used as a default avatar

the avatar of Jim Fehlig

It is time

Actually, the time has long since past when I should have started writing about my work and play. But today, one day after my son’s eleventh birthday, I’m finally creating a wordpress account. Yes, that’s right – I have a son that is eleven and a daughter who’s nearly thirteen! That alone should give me plenty to write about. Stay tuned…

a silhouette of a person's head and shoulders, used as a default avatar

My talk at the LibreOffice Conference in Paris

Here: http://www.iki.fi/tml/libocon2011-xcompiling.pdf

(Edit: Haha, I guessed somebody would have a look inside and check what this presentation is "made" with. The PDF file says Keynote. I did create and edit it initially with LibreOffice, then exported to Keynote on my iPad, did a few final edits on the iPad and presented it from the iPad. (I did not bring any laptop to the conference.) I then exported to PDF from Keynote.)

the avatar of Greek openSUSE Ambassadors

Greek openSUSE community, Translation of openSUSE Weekly news in Greek (issue 196)




Hello everyone!

I am very pleased to announce the new issue (196) of openSUSE Weekly News in Greek.
In this issue you will read about:

* openSUSE 12.1 Beta Arrives!
* Hackweek results for openSUSE ARM
* openSUSE Board Election Committee Formed
* Hackweek VII
* Tux Arena/Craciun Dan: Xonotic – Free Shooter Based Off Nexuiz

As well as many interesting news about openSUSE and useful advice, which can make our lives easier.

Enough said though... Read more at: http://own.opensuse.gr, http://el.opensuse.org/Weekly_news or www.os-el.gr

We are always looking forward to receiving your comments as well as suggestions regarding things you would like to read about in our next issue.

The openSUSE Weekly News is being translated in the Greek language from issue #150. You can read older translated issues here: http://el.opensuse.org/Κατηγορία:Weekly_news_issues

Enjoy it!
Efstathios Agrapidis (efagra)

the avatar of Andrew Wafaa

openSUSE ARM Update - 141011

The big update is that a couple of kind companies have stepped up and sponsored some hardware for the effort to get openSUSE on ARM. Huge thank you to: They have kindly sponsored and shipped several EfikaMX devices. Thanks to Peter Czanik for organising this on our behalf. Ti in association with the PandaBoard community have kindly sponsored and are shipping several PandaBoards. Thank you, this is a huge help.

the avatar of Thomas Thym

the avatar of Andrew Wafaa

ARMing openSUSE - 111011

So HackWeek VII has been and gone, but work has not stopped in getting our beloved Geeko some ARMs. Now I’ll be the first to admit, things have been a wee bit scrappy in places. This isn’t anyone’s fault, it’s just that we want to get things rolling ASAP. Thing is, we need more haste less speed; we need to be somewhat more concerted with our efforts. So instead of trying to get everything to build in one hit (would be great if that was possible), we are going to target patterns of packages.

the avatar of Greek openSUSE Ambassadors

Greek openSUSE community, Translation of openSUSE Weekly news in Greek (issue 195)





Hello everyone!

I am very pleased to announce the new issue (195) of openSUSE Weekly News in Greek.
In this issue you will read about:

* Get your package in Factory for 12.1!
* Hackweek VII
* Linuxaria: Pipes – what are they and Example of Use
* LinuxJournal/Leon van Kammen: Playterm, Platform of the Gurus
* Jos Poortvliet: MeeGo and openSUSE – an invitation

As well as many interesting news about openSUSE and useful advice, which can make our lives easier.

Enough said though... Read more at: http://own.opensuse.gr, http://el.opensuse.org/Weekly_news or www.os-el.gr

We are always looking forward to receiving your comments as well as suggestions regarding things you would like to read about in our next issue.

The openSUSE Weekly News is being translated in the Greek language from issue #150. You can read older translated issues here: http://el.opensuse.org/Κατηγορία:Weekly_news_issues

Enjoy it!
Efstathios Agrapidis (efagra)

a silhouette of a person's head and shoulders, used as a default avatar