Lvm – Relayout LVM Disk

hard drivelvm

I have an Ubuntu 11.10 system with two 500GB disks. The partition tables look like this:

/dev/sda1      primary   465.52GB
/dev/sda2      extended  243.17MB
  -> /dev/sda5 logical   243.14MB
/dev/sdb1      primary   465.76GB

sda1 and sdb1 are in a single LVM physical volume group containing a single logical volume containing a single logical filesystem which is mounted as /. sda5 is mounted as /boot.

The problem comes when I want to upgrade to Ubuntu 12.04, which requires at least 247MB free on /boot. So I need to reduce the size of sda1 so that I can increase the size of sda2 and sda5. How the heck do I do that? I can find how to shrink the logical volume group, but I'm not at all clear on how to clear out the end part of sda1 so that I can reduce the physical volume group. Does pvresize just deal with this automagically? Or is that wild wishful thinking?

I guess the alternatives are to back everything up onto something or other and recreate the thing from scratch or find out whether GRUB2 supports using LVM for /boot.

Best Answer

After shrinking the first partition that holds the first physical volume with pvresize, you need to grow the /boot partition.

In order to extend the /boot partition you would have to move its start point on the first disk. You can accomplish that with parted using the move command.

Then you can resize the partition again with parted and finally grow the filesystem.