August 19, 2013

Bootable, mountable VM images

The Problem There’s a classic pain point that anyone building disc images for virtual machines comes across. It’s easy to make a filesystem image in a file, and you can work with it easily by mounting it as a loopback filesystem. But to get KVM to boot it you’ve got to copy the kernel and initrd out, because GRUB can’t make a filesystem image bootable. If you want a totally self-contained bootable image, you’ve got to mess with kpartx and losetup to make a disc image that includes partition information, just to keep the bootloader happy, and working with that is a pain because it doesn’t loopback mount. Read more