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
link|improve this question
feedback

3 Answers

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 live 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.
link|improve this answer
Thanks, that looks promising, can you suggest a LiveCD I might use which has LVM tools on it? – user12259 Jul 9 '09 at 19:35
Sysrescuecd is nice (sysresccd.org) – Zoredache Jul 9 '09 at 19:44
4  
ext2/3/4 support live growing of your filesystem. You don't need to unmount or e2fsck your partitions. resize2fs is also clever enough to figure out the size of the partition (or logical volume) it's on. If you don't specify a size it will just grow to fill all available space. – Kristof Provost Jul 9 '09 at 21:22
I tried "sudo resize2fs /dev/sda1" and it responded: "resize2fs: Device or resource busy while trying to pen /dev/sda1 Couldn't find valid filesystem superblock" – user12259 Jul 9 '09 at 22:00
I'm not familiar with mountpoint, how do I find out my mountpoint for say /dev/sda1? – user12259 Jul 9 '09 at 22:04
show 1 more comment
feedback

See a related answer here.

(excerpt)

Resizing physical volume:

pvresize --verbose --test /dev/md0

Resizing logical volume:

lvresize --verbose -L <SIZE> --test /dev/VG1/LV1

And finally, resizing ext3 FS:

resize2fs /dev/VG1/LV1
link|improve this answer
When i do lvresize, i get an error "Failed to suspend root" – user12259 Jul 9 '09 at 22:23
I tried: "sudo lvresize --verbose -L 40G /dev/ubuntu/root" – user12259 Jul 9 '09 at 22:29
ok, I fixed that with "sudo modprobe dm-mod", now I can successfully lvresize – user12259 Jul 9 '09 at 22:42
feedback

Check out this other serverfault question's answer, How do you increase a KVM guest's disk space?. The technique used to increase the LVM partition in this KVM guest is similar to what you're trying to accomplish.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.