Resize a xen guest's root partition (where the disk is a filesystem)
I have a guest (foo) with a 6GB / partition (/dev/VolGroup00/LogVol00), and I want to increase it to 12GB. The image file is /var/xendisks/foo.
* Shutdown the guest
* run `dd if=/dev/zero of=/var/xendisks/foo bs=1M conv=notrunc count=1 seek=12000`
* run `losetup /dev/loop0 /var/xendisks/foo` to create a loopback device from the disk image
* run `kpartx -a /dev/loop0` to create mapped partition table entries
* the kpartx creates /dev/mapper/loop0p1 and loop0p2
* Run `fdisk /dev/mapper/loop0`
* in fdisk, I delete the second partition, then recreate it accepting the default values. This ensures that the partition starts at the same cylinder as the original partition, and takes up the rest of the space.
* boot up the guest and log in
* run `pvdisplay` to identify the physical volume you've just resized. In my case, it is /dev/xvda2
* run `pvextend /dev/xvda2` to increase the physical volume size to fill the extended partition
* run `lvresize /dev/VolGroup00/LogVol00 -l 100%VG` to resize the logical volume
o actually that failed for me, something about not enough extents, so I ran `lvresize /dev/VolGroup00/LogVol00 -L 12G` instead
* run `resize2fs /dev/mapper/VolGroup00-LogVol00`
* `df` now shows a 12GB partiton.