I got a KVM/Qemu setup that works great. Now I want to streamline the provisioning of new VMs.
The two obvious ways are to either clone an existing disk or install from scratch (with an automated preseed/kickstart).
In my tests, installing with a preseed/kickstart takes at least a few minutes from creation to up and running (even with local mirrors). The result is great, but it takes too long.
Cloning is obviously a lot faster, but it creates problems as soon as you need a bigger disk than the source.
Now, if it was just a one-off thing, it would have been trivial to boot it up and expand the disk by hand. However, I'm looking to do this in an automated fashion on first boot.
There are basically three tasks that needs to be performed:
- Expand the disk (fdisk/cfdisk etc)
- Resize the volume pool (in case of LVM)
- Expand the actual file system
While it would be possible to script this, I wanted to raise it here, since I doubt that I am the only one looking to do this in an automated fashion. The closest thing that I've found is raspi-config for the Raspberry Pi, which offers an automated tool for this.
I could of course lift the code from raspi-config, but it makes a lot of assumptions, so I was hoping that there might be a more universal tool available.
libguestfs might be up to the task, it can't do it in place though, Quote:
Doing this as the cloning step should work.
Turns out that
growroot
, which is part of Cloud Init can do this. For a complete example on how this works, please take a look at my implementation in vmprep.