Aug 10, 2019
How to boot up a custom disk image on Linode

My Mu project generates bootable disk images out of programs written in a custom Assembly language. One use for such disk images is deploying them to the cloud, and the recipe to do so generalizes beyond my project. Here it is for my specific cloud provider: Linode. There are three broad steps:

  • Create a server.

  • Split its root disk in two. You can't image a cloud server's disk directly from outside, you have to get the disk image on the computer first. So you need a ‘host’ disk (I call mine ‘Origin’) and a ‘guest’ disk that will get imaged (I call mine ‘Planet Lambert’).

  • Teach the server to boot into either disk on demand.

There's existing documentation for the first step, so we'll start with the second, where you're at the dashboard for a server that looks something like this:

Click on the ‘Running’ dropdown on the top right (1) and click ‘Power off’ (2).

Your server will now be offline (3).

Select the menu for the main disk (4) and select ‘Resize’ (5).

Reduce the size of the disk.

Wait for the resize to take effect (6).

Now add a new disk (7).

Give it a name and hit ‘Submit’.

Now that we have two disks, we want to be able to boot from either of them. We'll achieve this using Linode's notion of ‘Advanced configurations’.

Select the dropdown on your default configuration (8) and hit ‘Edit’ (9). I rename mine to ‘Origin’. This is the configuration that will continue to operate as before. We'll now give it access to the new disk.

Assign an open disk device to the ‘Planet Lambert’ disk (10).

Set the kernel type to ‘Grub 2’ (11).

Turn off all Linode's proprietary smarts (12) and hit ‘Submit’ (13).

We now can boot into this server and we'll see a new disk on /dev/sdc that we can format, mount, etc.

Now let's add support for booting it. Create a new configuration (14). I call it ‘Planet Lambert’ after its desired boot disk.

Set this configuration's kernel to ‘Direct disk’ (15).

Add the new disk as before (16).

Finally the key step: configure this configuration to boot from the new disk (17).

As before, turn off all Linode's proprietary smarts (18) and hit ‘Submit’ (19).

From now on, rebooting this server will always give you a choice of configurations to boot into. My debug cycle tends to go like this:

  1. Boot into ‘Origin’
  2. dd if=___.iso of=/dev/sdc
  3. Boot into ‘Planet Lambert’
  4. Launch console

(Based on https://www.linode.com/docs/tools-reference/custom-kernels-distros/install-a-custom-distribution-on-a-linode and linked articles.)

Making the big picture easy to see, in software and in society at large.
selected
Code
Prose (shorter; favorites)