cn:ccr:virtualizzazione:documentazione:xen_to_kvm
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| cn:ccr:virtualizzazione:documentazione:xen_to_kvm [2009/07/07 14:42] – chierici@cnaf.infn.it | cn:ccr:virtualizzazione:documentazione:xen_to_kvm [2010/04/19 13:09] (current) – andrea.chierici@cnaf.infn.it | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Migrating from XEN to KVM ===== | ||
| + | This small guide describes how to migrate existing and running machines from xen (para and hvm) to kvm, and NOT VICE VERSA. | ||
| + | KVM is taking over XEN and is getting rather popular, so we think that this is the time for such a guide. | ||
| + | |||
| + | ==== Before you start ===== | ||
| + | We assume you already have an idea on how XEN and KVM work, and how to convert a machine from one hypervisor to the other. | ||
| + | Needless to say that to make the migration, you need to shutdown your machine, the migration can't be done //live//. | ||
| + | This guide has been prepared using the Tier1 environment and installation system, so it's possibile that something different could be required on other sites/ | ||
| + | We assume that the dom0 is running on a SL 5.x machine and that the VMs are SL 4.x. This does not mean that if you start from a different setup things won't work, but additional effort may be required.\\ | ||
| + | |||
| + | This procedure works both for disk-on-a-file and disk on partition approaches. | ||
| + | In our environment generally disk partitions are LABELLED, so there is no need to change anything inside // / | ||
| + | |||
| + | |||
| + | ==== XEN-para to KVM ==== | ||
| + | Log on the node and perform some modifications: | ||
| + | |||
| + | * If the machine does not have already one, install a // | ||
| + | * Set the default kernel to the one you just installed | ||
| + | * Remove any reference to the virtual console on the kernel line // | ||
| + | * modify // / | ||
| + | * comment in tty section of inittab the line beginning with //co:// that enables the serial console | ||
| + | * uncomment all the 6 standard consoles | ||
| + | * if you don't need ldap or if you want to speed up the first boot process, add this line to // / | ||
| + | * bind_policy soft, **remember to add it again after you reconfigured the network** | ||
| + | |||
| + | After all these operations, you can reboot the node using kvm instead of xen. As an example, a command line to launch a node could be something like: | ||
| + | |||
| + | qemu-kvm -hda disk.img -net nic, | ||
| + | |||
| + | When the machine starts, //kudzu// will detect several hardware changes; it is quite safe to answer //yes// to all the questions and after some seconds, the node should be ready again, this time running on KVM. | ||
| + | |||
| + | ==== XEN-hvm to KVM ==== | ||
| + | With XEN-hvm the process is simpler. Log on the node and perform some operations; | ||
| + | |||
| + | * if you are using para-virtualized drivers, erase the corresponding line in / | ||
| + | * if you plan to use e1000 network driver, add //alias eth0 e1000// in / | ||
| + | * if you don't need ldap or if you want to speed up the first boot process, add this line to /// | ||
| + | * bind_policy soft, **remember to add it again after you reconfigured the network** | ||
| + | |||
| + | After all these operations, you can reboot the node using kvm instead of xen. As an example, a command line to launch a node could be something like: | ||
| + | |||
| + | qemu-kvm -hda disk.img -net nic, | ||
| + | |||
| + | When the machine starts, //kudzu// will detect several hardware changes; it is quite safe to answer //yes// to all the questions and after some seconds, the node should be ready again, this time running on KVM. | ||
| + | |||
| + | ===== Appendix: Mounting a disk image file to edit configurations ===== | ||
| + | If your VM is already turned off, you can avoid turning it on again to perform the modifications described in this page. | ||
| + | You can follow this small guide. | ||
| + | |||
| + | At first place create a device mapper for the disk image: | ||
| + | |||
| + | //kpartx -a node1.img// | ||
| + | |||
| + | |||
| + | You can check which is the device by ‘kpartx -l node1.img’. | ||
| + | |||
| + | # kpartx -l node1.img''< | ||
| + | loop0p1 : 0 8177022 /dev/loop0 63'' | ||
| + | |||
| + | |||
| + | Then mount the filesystem: | ||
| + | |||
| + | mount / | ||
| + | |||
| + | |||
| + | Chroot to the the Xen VM filesystem: | ||
| + | |||
| + | chroot / | ||
| + | |||
| + | |||
| + | Perform an update on the existing package to avoid any package conflicts during kernel installation and then installed the normal Linux kernel: | ||
| + | |||
| + | yum update | ||
| + | yum install kernel | ||
| + | |||
| + | |||
| + | Exit the chroot environment: | ||
| + | |||
| + | exit | ||
| + | |||
| + | |||
| + | Umount the disk image and remove the mapper: | ||
| + | |||
| + | umount / | ||
| + | kpartx -d node1.img | ||
| + | |||
| + | The disk could then be used with KVM with no problems at all, both via libVirt and direct KVM/Qemu environment. | ||
