Resizing KVM guests disk

Follow these steps to resize a linux kvm guests disk.

1) Shutdown the vm.

# virsh shutdown <guest_hostname>

2) Add 10GB to the disks image.

# qemu-img resize guest_hostname.img +10G

3) Start the vm.

# virsh start <guest_hostname>

4) Log on to the vm and fdisk the disk device.

# fdisk /dev/vda

5) Print the partition table and take note of the start cylinder of the Linux LVM partition then delete the Linux LVM partition.

6) Create a new partition using the same start cylinder as in the previous step and make the partition type 8e for Linux LVM partition.

7) Write the changes and then reboot the vm.

# reboot

8) Log back on to the vm and resize the physical volume.

# pvdisplay
# pvresize /dev/vda2
# pvdisplay

9) Resize the logical volume.

# lvresize /dev/vg_system/lv_root -l +100%FREE

10) Resize the filesystem.

# resize2fs /dev/vg_system/lv_root

Leave a Reply