Resizing an LVM 2 filesystem on Ubuntu inside Virtualbox (Mac)

Problem 1, VirtualBox can’t resize this kind of Linux volume, so, on the Mac:

Create a new HD (for me, ~10G)
VBoxManage createhd –filename Ubuntu.vdi –size 10000
Copy contents
VBoxManage clonehd CartoDB.vdi Ubuntu.vdi –existing

Then, Download GParted ISO, latest version so that you can resize LVM volumes
Add as CD volume to the machine and boot it, Gparted runs
Deactivate the volume, and resize to fill space, apply changes
Shutdown, ensure CD is no longer mounted in VirtualBox, reboot to real Ubuntu

Then, back in real Ubuntu (this is live resizing, use at your own risk!)
sudo lvextend /dev/lubuntu-vg/root /dev/sda5
sudo resize2fs /dev/mapper/lubuntu–vg/root

Done!

Cobbled together from:

http://trivialproof.blogspot.de/2011/01/resizing-virtualbox-virtual-hard-disk.html

http://www.howtogeek.com/114503/how-to-resize-your-ubuntu-partitions/

http://blog.dhampir.no/content/resizing-an-ext3-filesystem-on-an-lvm

http://serverfault.com/questions/501895/used-vgextend-lvextend-to-add-addtional-8gb-space-but-it-is-not-reflected-in-df

…and quite possibly a few others

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>