Hi *,
I hope this is the right category for my questions. If not - please advise.
I'm in the process of setting up a new box for my VMs. Until now I have used Xen for these but the hardware is hvm capable and in order to avoid hardware compatibility issues with Xen (which pop up more and more often lately due to Xens 2.6.18 issue), I want to test KVM as an alternative.
Various questions have come up during the process of setting up KVM and map Xen functionality to KVM.
Here's one of the first topics: disk management.
With Xen I set up every disk of every VM as a logical volume on LVM. I use xfs as my primary filesystem, which lets me transport (xfsdump/xfsrestore) and resize (lvextend, xfs_growfs) disks of VMs very easily.
With KVM that seems to be not so easy. I understand, that I can use LVM logical volumes as drives in KVM. But these drives contain one or more partitions, which can only be accessed (mounted) on the host using kpartx.
But how do I extend these partitions? With lvextend I can extend the drive obviously - but how do I extend the partitions and the filesystems on them? I tried ext2resize and even parted - to no avail.
Any hints? Do I have to live with image-files, when I change to KVM (leaving all the benefits of LVM behind)?
Thx.
Regards
Töns
OK - in order to let everyone here participate I'll share, what I learned so far:
You can get away without partitioning a LV. Just put a filesystem on it (mkfs.ext3 /dev/vg0/new_lv) and you are
done.
You specify the LV like this:
kvm ... -drive if=ide,boot=on,file=/dev/vg0/new_lv
You can get even more Xen-like behaviour, if you specify the kernel (and its start parameters) you like to boot, too:
-kernel /boot/vmlinuz-2.6.24-19-server \
-initrd /boot/initrd.img-2.6.24-19-server \
-append "root=/dev/sda ro"
You would use /dev/sda in the guests /etc/fstab, as well.
It seems, that this trick doesn't allow you to use xfs as the guests/LVs filesystem. Ext3 works like a charm, though.
If you want to extend the LV/filesystem for the guest, you shut it down, do lvextend, ext2resize, and start again.
I haven't checked LVM snapshots, but these should work, as well.
HTH.
If you specify a kernel for your virtual machine another issue is that updating the kernel of the virtual machine does not affect the kernel you specified.
How did you overcome this problem? Do you update the kernel on your host manually?
Using the filesystem based approach works really well but its not quite as flexible if you want to give people access to start and manage their own kernels / etc (which is rarely required but I digress)
one way is to create a 'drive' on the LVM partition and add a bootloader. I wrote a howto on doing this with a file-backed drive, but the approach is the same with an LVM partition.
http://blog.layerboom.com/2009/10/20/how-to-move-a-virtual-machine-from-...
Post new comment