Wednesday, September 30, 2009

resize hvm guest

$ dd if=/dev/zero of=new_image bs=1 count=new_size_of_ext3_in_bytes
$ dd if=old_image of=new_image conv=notrunc #copy the old image bytes to
the new image (without overwritting the new file)
$ losetup -o 32256 /dev/loop0 new_image # /root doesn't actually live
at front of image for HVM
$ fsck -f /dev/loop0 #check the new image for errors
$ echo "new_image_bytes / 8225280" | bc # this is number of cylinders
in new device
$ fdisk new_image
$ # go to the "extra" menu and type "c" and type the new number of cylinders
$ # go back to main menu
$ # delete primary partition (yes, delete it)
$ # add new primary partition w/ defaults # resize partition to size of
actual image file
$ # 'w' write out fdisk and exit
$ resize2fs /dev/loop0 20G #resize ext3 to whatever GB you want MINUS
a gigabyte ..... just to be on the safe side
$ losetup -d /dev/loop0 # get rid of the loop device
$ edit xen config and test new image (don't delete the old one!)

No comments:

Post a Comment