Nesting LVM for resizeable VMs
As part of my role wearing the DevOps hat at DigiResults I’m in charge of setting up new machines; since I’m terminally lazy I clearly want to automate this. My first attempt used the ubuntu-vm-builder
(which is a ubuntu-provided wrapper around the more generic vmbuilder
script and was good enough for the first version but not without its drawbacks - namely I got bitten by making the VM disk too small.
vmbuilder
will happily write to a ‘raw’ partition, which in my case was a LVM logical volume. The easiest way to show what I mean is by utilising my stunning ASCII-art skills. Running (not the complete command):
ubuntu-vm-builder kvm --raw /dev/mapper/vms-my_vm --hostname=my_vm
produces as disk layout the looks something like this (the PV and VGs aren’t shown as they just complicate matters
--- LVM on Host -------------------
| /dev/mapper/vms/my_vm (LV) |
| |
| ----- VM ------------------- |
| | /dev/sda* | |
| | | |
| | | |
| | | |
| | | |
| ---------------------------- |
-----------------------------------