5

I am in the process of switching from Xen to qemu-kvm. My current Xen installation has a number of LVM volumes each with a partition (rather than a full disk image). In Xen, I start each VM with a configuration like so:

kernel = "/boot/vmlinuz-2.6.18-128.4.1.el5xen"
ramdisk = "/boot/initrd-xen-2.6.18-128.4.1.el5xen"
disk   = [ 'phy:/dev/vmdata/vm-standalone,sda1,w' ]

I now want to reuse these VMs but start them under kvm instead. It seems that virt-install --import would let me do this, using --boot kernel=<kernel>,initrd=<initrd>, but I don't see how I can instruct virt-install to attach the existing volume as boot/root file system. Is this possible?

3 Answers 3

3

I've been researching this topic as well and just posted a somewhat similar question, but with a different scope: KVM/qemu - use LVM volumes directly without image file?

For your particular question, does this work: https://wiki.archlinux.org/index.php/QEMU#By_specifying_kernel_and_initrd_manually

In particular, -append root=/dev/sda /dev/sda3. I haven't tried it myself, but it seems like it should do what you want.

3

Answers from dynasy and Jared are both pointing in the right direction, but leaves a bit unexplained.

The short answer to my question is that virt-install is perfectly capable of supplying a partition to the booting system. In fact, for block devices, it doesn't care and just pass it on to qemu that sets it up like a block device. Then the kernel uses /dev/sda (rather than /dev/sda1) as root file system.

The command line for achieving this looks like this:

virt-install --name nic 
  --ram 512 
  --disk /dev/vg_ext/nic-standalone
  --disk /dev/vg_ext/nic-swap
  --network bridge=br0
  --boot kernel=/boot/vmlinuz,initrd=/boot/initramfs.img,kernel_args="console=ttyS0 root=/dev/sda" 
  --serial=pty

In order to make this work, I had to modify /etc/fstab on nic-standalone so that it pointed to the correct root file system and swap partition (/dev/sda, /dev/sdb). Kernel and initrd above are standard CentOS 6 stuff. (There may be various performance parameters/tweaks desired as well, I just haven't gotten that far yet.)

2

Simply create a new VM in virt-manager or via virsh with similar parameters as the Xen one (memory, CPU etc), and when asked to create virtual disks for it, point to the existing Xen disks.

You might need to adjust fstab a bit, to point to /dev/vdX instead of xvdX (or whatever Xen uses)

If you want a really nice move procedure that will take care of everything for you, you can use virt-v2v.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .