FastNetMon

Thursday, 3 July 2014

Installing KVM virtual machines on ploop disk images

What is ploop?

Ploop is modern disk image format from OpenVZ project. There are lot of similar formats like qcow, vmdk and many else.

But ploop has few really important improvements agains they all:
  • ploop can overcommit disk space like sparsed images but without speed overhead
  • ploop can compact VM after freeing up space in filesystem wihtout downtime!
  • ploop can do fast consistent snapshots out of the box
  • KVM and OpenVZ can work over ploop together
  • ploop can work over clustered Parallels Cloud Storage! 
But ploop is NOT real block device and you can't install Windows or Linux using standard installer. 

It's looks like LVM for VM which done in right way. You can read more about ploop here:  http://openvz.org/Ploop

 Because ploop is an in kernel part of OpenVZ project you need to download OpenVZ kernel and install it:
wget -P /etc/yum.repos.d/ http://ftp.openvz.org/openvz.repo
rpm --import http://ftp.openvz.org/RPM-GPG-Key-OpenVZ
yum install vzkernel ploop
After this we need load kernel driver which do main work for ploop:
modprobe ploop
 And now create image and mount it:
mkdir /root/ploop_kvm
ploop init -s 15G /root/ploop_kvm/testploophdd.img
ploop mount /root/ploop_kvm/DiskDescriptor.xml
After this operations you will got folowing output:
Opening delta /root/ploop_kvm/testploophdd.img
Adding delta dev=/dev/ploop20722 img=/root/ploop_kvm/testploophdd.img (rw)
Please take a look at /dev/ploop20722, it's our device name which we need pass to KVM.
 
For testing purposes I will install this KVM container from OpenVZ os template (root tar.gz):
mount /dev/ploop20722p1 /mnt
wget http://download.openvz.org/template/precreated/debian-6.0-x86_64-minimal.tar.gz -O/root/debian-6.0-x86_64-minimal.tar.gz
tar -xf debian-6.0-x86_64-minimal.tar.gz -C /mnt
 
We need prepare chroot for loading VM:
chroot /mnt
apt-get install -y linux-image-2.6.32-5-amd64
depmod -a 2.6.32-5-amd64
vim /mnt/etc/fstab
/dev/sda1 / ext4 defaults 0 0

And for correct VM loading please put kernel and initrd into folder /opt/kernels because I can't install grub on ploop (but I think it's really possible).


Start VM:
/usr/libexec/qemu-kvm -vnc 159.xx.xx.yy:1 --initrd /opt/kernels/debian6/initrd.img-2.6.32-5_45-amd64 --kernel /opt/kernels/debian6/vmlinuz-2.6.32-5_45-amd64 --hdc /dev/ploop20722 --append 'root=/dev/sda1'
For unmounting after shutdown you need call this command:
ploop umount /root/ploop_kvm/DiskDescriptor.xml
As downside I should notify about ability to login into VM for compacting or resizing images but it's really not an problem.

Please be very careful with using this guide in production because it's NOT TESTED at all.

No comments :

Post a Comment

Note: only a member of this blog may post a comment.