[Libguestfs] How to make a Google Compute Engine boot image with guestfish?

Andrew Stuart
Fri, 17 Feb 2017 10:15:09 -0000

wow - guestfish has a dizzying array of options and functionality - looks
awesome.

I feel a bit like I’m asking for homework help, but perhaps someone might be
willing to save me a weekend (or more) of trial and error by pointing me in the
right direction…..   I’ve done so much fiddling with this sort of stuff that I
know a little insider guidance can be a *huge* help and time saver. And if it is
considered rude or lazy to ask straight up for help then please accept my
apologies and I’ll set out on the grinding road to find the commands that work.

Background:
I have a zipfile containing a kernel and an initramfs. These are all that is
needed to boot an in-memory operating system.

I want to put these into an image suitable for booting on Google Compute Engine,
using syslinux or extlinux.

Google’s requirements for such images are described here (and summarised at the
bottom of this email)
https://cloud.google.com/compute/docs/images/import-existing-image

This is a script that does something very similar what I need (although without
an initramfs), but it seems to me that guestfish might be able to do so in a
much more straightforward manner:
https://github.com/Solo5/solo5/blob/master/tools/mkimage/solo5-mkimage.sh

So my question, does anyone know off the top of their head the right incantation
to get guestfish to take my kernel and initramfs files and put them into a
syslinux/extlinux Google Compute Engine “disk.raw” 10G MBR sparse bootable
image, equivalent to the solo5 script above, and compliant with the Google
requirements below?  I’m hoping that there’s a simple one or two commands to do
so.

An important constraint is that I will be scripting this and running it on a
server that I am not permitted to run “mount” on.

thanks heaps!  And if I’ve broken etiquette by not first grinding it out before
asking, then I apologise.

Andrew


Requirements

To import your boot disks to Compute Engine, your existing boot disks must meet
the following requirements:

	• If you built a custom operating system kernel, it must meet the hardware and
kernel configuration requirements. Most stock Linux distributions already meet
these requirements, so this requirement is only for advanced users who build
their own custom operating systems to run on Compute Engine.
	• The boot disk must be no larger than 2048GB (2TB).
	• The boot disk that you import must have a functional MBR partition table or a
hybrid configuration of a GPT partition table with an MBR bootloader.
	• The primary partition on the boot disk can be in any format that you like as
long as it boots properly from the MBR bootloader.
	• The bootloader on the boot disk must not have quiet, rhgb, or splashimage=
kernel command line arguments. Compute Engine does not support splash screens on
boot. You can remove these values from the GRUB config during the bootloader
configuration step.
The image file that you import must meet the following requirements:

	• The disk image file name must be disk.raw.
	• The RAW image file must have a size in an increment of 1 GB. For example, the
file must be either 10 GB or 11 GB but not 10.5 GB.
	• The compressed file must be a .tar.gz file that uses gzip compression and the
GNU tar format.