2

I have a physical volume in a virtual machine that I've grown. Now I need to tell LVM that it is bigger. How do I do that?

I expected pvextend to be the command like lvextend and vgextend, but that doesn't seem to work.

1 Answer 1

4

The command you need is pvresize; however, there are two cases that may come into effect.

  1. Your physical volume is a partition on a drive
  2. Your physical volume is a whole drive

In the case of #1, you'll need to use tools like fdisk, parted or others to work out extending the partition into the new space on the drive. Depending or the arrangement of the partition, this could get really tricky and opens you up to more opportunity for downtime or an error making the system unbootable. You can avoid this now by simply adding an additional drive and making the whole thing a physical volume. If you can, do that. Use pvcreate and vgextend to make the space available to LVM.

I recommend setting up virtual templates with a separate drive just for LVM allowing boot, swap and whatever partitions you might not have in LVM to take their own drive. This way you are in position #2 when this comes up.

At that point, you'll just add the space to the physical drive, trigger the kernel to detect the new space and then you can resize:

pvresize /dev/sdb

Then continue in the typical way with your vgextend, lvextend and resize2fs (or otherwise) to gain access to the space.

You must log in to answer this question.

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