Resizing file based xen virtual machine

You can create file based xen instances (eg, blarblar.img). If you have partitions in the file and want to increase the disk space, you cannot use resize2fs straight away on it. So you need to create a new larger file, then transfer the old file data onto it:

say I want the new filesize to be 4Mb,

dd if=/dev/zeo of=newImage.img count=4000 bs=1M

now, transfer the files over. Note that notrunc is important because we still want the output file to be 4 Mb.

xm shutdown oldImage.img
dd if=oldImage.img of=newImage.img conv=notrunc

Next, rename the images and boot up!

mv oldImage.img oldImage-dd-mm-yyyy.img
mv newImage.img oldImage.img
xm create /etc/xen/newImage

you can then do resizefs once the vm is booted up. You can copy the files even if the vm is up but then there is a danger of data inconsistency. Easier to manage than using LV.

Like it.? Share it:

Comments are closed.