Extending LVM for LXC

I finally got back to experimenting with LXC recently.  There have either been some improvements, or I’ve given it sufficient time to sink in, because it’s pretty much a cinch now (at least as long as you’re not trying to bridge the network, but that’s another story).

I’ve managed to set up a fairly lightweight VirtualBox host running Ubuntu with an Ubuntu container for use as a monitoring server.  Unfortunately my planning was a little shortsighted when I initially set the system up, and I left myself short on space.  With the help of the following sites, I was able to extend my logical volume using the LVM tools and (hopefully, I haven’t checked yet!) clear an ugly splat on my monitoring display.

http://www.howtogeek.com/howto/40702/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu/
http://sujithemmanuel.blogspot.com/2007/04/how-to-add-disk-to-lvm.html
http://www.turnkeylinux.org/blog/extending-lvm

With the help of the man page for lvextend I was able to determine the appropriate command to resize the logical volume to the total free space in the volume group with ‘lvextend -l+100%FREE /dev/vol-group-name/root’.

All together, here’s the summary of what I did.
Added a VDI disk in VirtualBox
fdisk /dev/sdb
Partitioned as needed, per first link.
pvcreate /dev/sdb1
vgextend vol-group-name /dev/sdb1
lvextend -l+100%FREE /dev/vol-group-name/root
resize2fs /dev/vol-group-name/root
Confirmed that the added space was apparent to the kernel.
df -h
Finally, I restarted my monitoring container.
lxc-start -d -n monitor-01
And confirmed that the free space was also apparent within the container.
df -h

After checking the basics, I confirmed that everything looks clean and clear in the monitoring system. Now I’m on to the task of figuring out how best to monitor some new equipment.

Leave a Reply

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