Linux – Ubuntu: Resize the root LVM(2?) partition

linuxlvmpartitionUbuntuvirtualbox

I have an Ubuntu virtual machine running in VirtualBox 2.2.4, and I created it on an 8gb virtual disk which is too small.

So, I am trying to increase the size of the disk. So far, I have done this:

  1. Created a new larger virtual disk
  2. Added the 2nd disk to the machine
  3. Used CloneZilla to clone the first disk onto the 2nd disk
  4. Removed the first disk
  5. Booted up off the 2nd (larger disk)

But now I'm still stuck with an 8gb partition on my new 100gb virtual disk.

Whats the easiest path from here to having a 100gb partition? 🙂 I gather GPart can resize partitions, but it doesn't seem to support LVM2 partitions, which mine seems to be.

thx

  • Alex

Best Answer

In general, here's how to resize LVM volumes:

Let's say /mountpoint is on /dev/VolGroup00/mountpoint. You can find this out by checking out /etc/fstab or by running mount -l.

You may also need to resize the actual Physical Volume, depending on your setup. Use pvdisplay to find out if it's big enough, and use pvresize (much like lvresize below) if necessary.

umount /mountpoint
lvresize -L +<HOW MUCH BIGGER> /dev/VolGroup00/mountpoint
e2fsck -f /dev/VolGroup00/mountpoint
resize2fs /dev/VolGroup00/mountpoint <TOTAL SIZE>
mount /mountpoint

This amounts to umounting, resizing the underlying LVM, then resizing the actual ext3 partition.

A few things to be careful of:

  1. Obviously playing with / will be different from a data partition. You may need a boot disk such as Sysrescuecd instead of Doing It Live. Also see Kristof's comment below -- you may actually be able to do this without unmounting /.
  2. lvresize has a few different syntax options, and reducing a logical volume will probably harm the overlaying partition. Consult your local man pages for more information.