xen to kvm
Michael Zoet
Michael.Zoet at zoet.de
Mon Mar 4 11:09:05 UTC 2013
Hi Michael,
I have done this for several (about 50 or so) Xen VMs now and never
found a good "best practice" guide.
Most importantly is that Xen has it's own boot loader so a Xen VM
might not have lilo or grub installed. This makes it really difficult
to automate the process. In the KVM environment you need a installed
bootloader otherwise the VM will not boot...
What I do for migration:
1. shutdown the VM
2. make a copy of your VM and copy this to the KVM server. (how to do
this depends on how you store your VMs, with LVM or as disk images and
so on.) Sometimes I had to create tar.bz2 images for LVM volumes or
could copy a disk image.
3. if you want to use normal disk images: create on the KVM server a
disk image with qemu-img (or kvm-img) that can hold the content of the
Xen VM or prepare a LVM volume
4a. prepare a new disk image with qemu-nbd when you use a disk image
4b. mount the disk image or LVM volume on the KVM server. What ever
you prefer or need.
4c. mount the old Xen VM on the KVM server.
5. copy all the stuff of the tar.bz2 file to the mounted disk image or
LVM volume
6. edit some stuff in the mounted disk image or volume:
/mnt/<KVM_VM>/etc/fstab, /mnt/<KVM_VM>/etc/securetty,
7a. create a login for a serial line in
/mnt/<KVM_VM>/etc/init/ttyS0.conf Than you have access to a serial
login via "virsh console <KVM_VM_NAME>" on the booted system.
7b. most of the time I disable networking on the KVM VM in
/mnt/<KVM_VM>/etc/network/interfaces. So I can test everything on the
KVM VM and later switch on networking.
8. change every occurrence of Xen specific stuff like hvc0 and so on
the mounted VM. I use "grep -rils hvc0 *" in /mnt/<KVM_VM>/etc and so
for this.
9. unmount the new and old VMs from the KVM server
10. create a XML file for the new KVM VM and integrate it with "virsh
define <VM_XML_FILE>" on the KVM server
11. boot the new VM with a server CD and use the rescue mode to
install grub on the VM
12. test everything thoroughly
13. setup networking and be happy about the new VM
There are several others ways to achieve this but in my experience
this works best. Even fro other Linux distributions. And there are a
lot of things that might go wrong, so you need some time and good
planing.
If you need some more specific help in German feel free to ask.
Michael
> dear admins,
>
> back in the old days when virtualization was still something new i was
> setting up a couple of servers with Xen since Kvm was not in a very
> convenient state of usability yet. this was done on 8.04 lts. things
> changed dramatically since then.
>
> currently i a about to migrate some of them to a 12.04 lts server
> version on Kvm. i was looking for tools that would ease the process of
> migration but did not find anything convincing yet. anybody out there
> who could point me in the right direction? since this should be a quite
> common szenario there should be some best practice guides i am
> overseeing.
>
> thank you for your attention!
>
> regards
> Michael
>
>
>
More information about the ubuntu-server
mailing list