6

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

3
  • You mean other way than this example Jul 3 '13 at 11:38
  • Exactly: "How to Increase the size of a Linux LVM by expanding the virtual machine disk" uses the method I already described which I don't like (I not sure that the concatenation of 20 pv comming from the same hard disk is efficient), the one with gparted does not work with Volume Groups :(
    – trax
    Jul 3 '13 at 12:45
  • +1 and favorited, I'd like to know if there is a way too :D Jul 3 '13 at 12:51
5

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.

1
  • how to however I had to replace fdisk with parted because of alignment issues
    – trax
    Jul 3 '13 at 15:23
0

After extending the Physical volume, It says the physical volume is already in use with volume group if you try to extend the same volume group. Instead you can extend the Logical volume directly without first extending the volume group. Use this command

lvextend -l +(physicalExtent) -r /dev/mapper/"lv Name"

this will do an online resize of the logical volume with resize2fs command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.