expand lvm partition

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
This is a virtual machine and I needed more space on the root partition. I powered it off and increased the size of the vmdk file which was a snap. I boot up, the new size of the drive is shown but now I need to increase the size of the LVM partition (and then the / logical volume after that).

I tried using "pvresize /dev/sda2" at the command line and it says it resized a physical volume, when when I check the size, it didn't change. Any help here? I thought pvresize would automatically expand to fill any empty space, but I guess maybe not. Right now sda2 fills extents 14 - 652 and I want it to fill extents 14 - 1174.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
pvresize expands the pv inside of the vg, now the vg hosting that lv should have more free space so you'll need to resize the lv and then the filesystem after that.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Ok, so after I've done pvresize, I try
lvextend -L +3000 /dev/VolGroup00/LogVol00 /dev/sda2
but I get
No free extents on physical volume "/dev/sda2"
No specified PVs have space available
I think it's because, for some reason, pvresize isn't actually expanding the pv so the vg doesn't have any more free space.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Does pvdisplay show the right size? And you shouldn't need to specify /dev/sda2 afterwards, it should take the space from where ever it can.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
pvdisplay showed the original size. After running pvresize, the size reported by pvdisplay never changed.

I can't really verify anything for you now though. I got it to work by creating a third partition with the rest of the free space on sda (partition sda3) and added that to the volume group. After that, expanding the lv and filesystem went without a hitch. I would have rather just expanded sda2 but I guess this gets the job done.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I got it to work by creating a third partition with the rest of the free space on sda (partition sda3) and added that to the volume group.

Ah then you changed the size of the device but not the partition on the device and since the pv was the partition (sda2 in this case) it was still the same size. You needed to use something like fdisk to grow the partition.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: Nothinman
I got it to work by creating a third partition with the rest of the free space on sda (partition sda3) and added that to the volume group.

Ah then you changed the size of the device but not the partition on the device and since the pv was the partition (sda2 in this case) it was still the same size. You needed to use something like fdisk to grow the partition.

Well, from reading documentation I gathered that, but reading the fdisk documentation said in order to expand a partition the file type must be fat, swap, ext2, ext3, and a few others so I didn't even try it since the type would Linux LVM (or type 8e, I think it is).
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Just delete the partition and recreate it, just make sure it starts on the same spot as before and you should be fine.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Originally posted by: Nothinman
Just delete the partition and recreate it, just make sure it starts on the same spot as before and you should be fine.

Say what?! It's the root partition. Even if I moved it to a different machine and did that, wouldn't I lose all the data?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Say what?! It's the root partition. Even if I moved it to a different machine and did that, wouldn't I lose all the data?

Well I'd use a LiveCD but no, deleting the partition just deletes the entry in the partition table. The data itself is never touched.
 

Brazen

Diamond Member
Jul 14, 2000
4,259
0
0
Sweet, I tried the fdisk thing and it worked with no problems. Thanks for the info, Nothinman.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
No problem, if all you'd used before was old MS fdisk I could understand your hesitation since it does do extra crap behind your back when all it really should be doing is touching the partition table.