Linux – Extend volume group after extending physical volume

linuxlvmpartitioning

I am using LVM to allocate disk for my VMs so I can increase the "physical disk size".

The only way I found to merge this free space to my VM Volume Group was:

  1. create a partition on new free space
  2. extend the volume group with the new partition

As I often need to increase vm disk, this solution seems to me a little bit dirty.

Any better way to extend vg to free space?

Regards

Best Answer

You should also be able to extend the existing partition (which is a "physical volume"). First resize the partition using fdisk or whatever, then run pvresize /dev/partition . See man pvresize.

Note: you probably can't convince the kernel to notice first the increased disc size, and if you can, then after modifing the partition table, you'll need to convince the kernel to re-read the partition table which you probably can't do either. A reboot is a sure way. So, first resize the disc from the virtual host, then reboot. Resize the partition with fdisk, reboot. Then run pvresize. If you need to do this without reboots, then the best way is just to add a new disk to the VM. That can be detected for sure without a reboot.

Related Question