Part 7 of experiments in FreeBSD and Kubernetes: Custom Linux VM Installs in CBSD

See all posts in this series


Custom Linux VM

Finally, as promised, I’m going to make a bhyve VM for a Linux distribution for which CBSD currently does not have an existing configuration. (I’m using CBSD version 12.1.16.) I chose Alpine Linux, in part because they have offer an ISO image for installation. (I wanted to use Google’s Container-Optimized OS, but they don’t distribute a public anything. The same for AWS’s Bottlerocket distribution, which is also optimized as a server for container runtimes. Both are open-source, but both require compiling from source if you’re not deploying in their respective clouds, and that is a completely different experiment.)

To start, I cd into the directory with the profile configuration files. Then I copy a random Linux configuration and edit to change the name, version, and download site for the ISO image. I’m not sure about some of the options, so I just leave them as-is.

When I run cbsd bconstruct-tui and navigate to the OS profile menu, my new entry for Alpine Linux is there.

Screenshot of CBSD Linux VM menu with new Alpine Linux entry at the top


Screenshot of CBSD VM creation menu configured to create a VM from the new Alpine Linux configuration


After exiting, I run cbsd bstart alpine and it boots up.

Screenshot of the VNC console of the newly booted alpine installer disk


I’ve used the Alpine container image as a base in Dockerfiles, but I had never installed it on a server, virtual or real. Fortunately, the ISO image comes with an installer command, setup-alpine. I walk through the options, then reboot. It does look like I don’t need the CBSD mirrors, because those seem to be alternate hosts for the supported ISO images.

Screenshot of the alpine console showing the system installer
Yes, I messed up on the root password the first time


Screenshot of the alpine console showing more installer steps


Screenshot of the final steps of the alpine installer


That was a success and pretty straightforward, once I figured out where the configuration files lived.

Customizing with cloud-init

What if I wanted to automate the installation using CBSD’s support for populating cloud-init files?

With cloud-init, you generally use a disk image, rather than installing from an ISO image. And, in fact, CBSD seems to be using custom-made raw disk images in place of ISO images for its cloud VM profiles. (I suppose you could still make starting with an ISO image work, if booting the ISO triggered a totally automated installation, including installing the cloud-init package; it would still need to be a two-step process to populate the resulting installation’s cloud-init files with the VM’s custom configuration, but CBSD doesn’t support that, so nevermind.)

I could try to build a raw disk image for Alpine to use for cloud installs.

BUT WAIT! It looks like cloud-init support isn’t in the Alpine release I used, 3.12.1, but it has been added as a supported package in the unreleased edge branch. Ok, let’s see if we can install the unnumbered edge branch because using a tag recycled for rolling versions never broke anything. (Actually, it has. Don’t do this in production, kids.)

It took a little digging to find where Alpine hides its edge development build artifacts. (Here.) Unfortunately, it looks like they stopped building ISO images or other artifacts for edge several years ago, so that’s out. (As I noted at the beginning of this post, if I wanted to compile an entire distribution from source, I would have been using another distro.)


OK FINE. In the next part, I will actually create an image to create and configure an Alpine Linux VM using cloud-init.

Sources / References