summaryrefslogtreecommitdiff
path: root/blog/gentoo-on-gcloud.org
blob: 2ab530e6a7cc4da8a3d9a6ad3f7a89eaadab5286 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
* Gentoo On Google Cloud

Google Cloud only provides Debian and a few other operating system images by default, but does allow bringing your own ISO.

** Gentoo Official QCOW2 Images

The first thing I tried was booting one of Gentoo's official qcow2 images directly.

Importing custom images requires downloading the image to a "bucket" which is basically Google's s3 object store.

Downloading images to a bucket requires transfering data via a URL list. The URL list is a file hosted somewhere with a list of URLs in it, one per line. Maybe using a pastebin for the URL list could work?

After getting the image downloaded to the bucket, you must go to the "Migrate to Virtual Machines" entry, which is underneath "Compute Engine". Then there will be a button that says "Import Images" (note there is another button called "Import Machine Images" which won't work). The rest should be easy.

After getting the image imported, you can use it like any other gcloud disk image.

After doing these steps, I created a new vm instance with the Gentoo qcow2 image as the base, but it failed to boot with an error saying something along the lines of "no bootable media found".

I am not exactly sure what is wrong with gcloud, but these images boot fine in qemu for me.

** Hijacking A Debian Image
Instead of using one of the official Gentoo images, we decided to "hijack" one of gclouds already booting Debian images.

To do this, I created a new instance using the default Debian boot disk, and then cloned the instance's disk while the instance was shut down. Then I booted the instance back up, and attached the clone'd disk to the instance.

From here, I made a brand new filesystem on the main rootfs partition, but left alone the rest of the disk. You can install Gentoo from a stage3 and chroot in like normal to configure stuff, or install however you'd like.

When installing the kernel, I just deleted the old debian ~/boot~ contents, and installed ~gentoo-kernel-bin~, and ran ~grub-mkconfig~ like you'd normally do. This also failed to boot, with an error about $UUID not existing. It looks like the old EFI binaries/bootloaders are somehow conflicting with out setup.

The trick that got it to boot, was clearing out the old EFI binaries completely, and then installing grub with the ~--removable~ flag. Without the ~--removable~ flag, it would not boot.

After installing our new bootloader, I shut down the instance, detached the boot disk, and reattached the Gentoo disk as the new boot disk. Then booted into Gentoo!

* TLDR

To get it to boot, you hijack a working image by making a new rootfs on the rootfs partition, replace the kernel, initramfs and then the bootloader with a "removable" bootloader (aka ~grub-install --removable~).