Linux – How easy is it to migrate a Linux VM image from one VM env to another

linuxvirtualization

If I stick to one of the standard, well-supported VM disk images (like a raw image, or VDI, VMDK, …), are Linux VMs typically easy to move between VM environments? E.g., between (say) VirtualBox and KVM, or VMWare and Xen? I'm talking here of fully virtualized environments, not paravirtualization requiring support within the guest OS.

It seems to me that the kernels in most Linux distributions these days are configured to…keep an open mind and detect things at boot time, so you don't have the issue that you sometimes have moving a Windows VM from one virtualization system to another (I'm thinking particularly of HAL issues that Windows has, like ACPI vs. non-ACPI; I've also just had Windows VMs generally acting strangely when moved from VMWare to VirtualBox, for instance).

I'm looking for a general answer, but if it helps, specifically I'm mostly going to be doing this with Ubuntu 8.04 LTS and 10.04 LTS guests. But that could change.

Best Answer

Linux is able to load modules (drivers) for it's hardware platform on demand. As long as your kernel is able to find modules for you hardware, it does not even matter on what platform you start your VM, save for a couple of caveats:

  • for all hypervisor types, use generic hardware: use IDE disks (not SCSI, KVM sucks with SCSI disks) and use e1000 network adapters. For portability, stay away from KVM's vda disks or VMware vmxnet. This is not alway possible (VMware uses SCSI by default), but it'll help.
  • make sure you use the same MAC addresses for the migrated VM on the new platform as you did on the old one
  • use LVM for your disks: the bootloader will find your kernel and feed it your initrd; if you use LVM, you don't have to worry about disks going awol (worry less, anyway).
  • leave your network configuration at DHCP if possible
  • do not install VMwareTools and similar
  • generate an initrd and try to put as many of the drivers you'll need on the other platforms in it. This will save your behind when trying to go from KVM (IDE disks) to VMware (SCSI disks) and you already have support for VMware's LSI Logic SCSCI controller in your initrd.