8

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 Commented Jul 3, 2013 at 11:38
  • 1
    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
    Commented Jul 3, 2013 at 12:45
  • 1
    +1 and favorited, I'd like to know if there is a way too :D Commented Jul 3, 2013 at 12:51

2 Answers 2

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.

2
  • how to however I had to replace fdisk with parted because of alignment issues
    – trax
    Commented Jul 3, 2013 at 15:23
  • Thanks a lot. This is still relevant in 2024 and the documentation is only clear in the situation described by the OP (adding more partitions to the volume group)
    – Igb
    Commented Feb 2 at 14:26
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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .