[READ-ONLY] Mirror of https://github.com/fliphess/build-pi-image. Based on pi-gen: Build a custom raspberry pi image
README.md

pi builder tool #

Pi builder tool is a raspberry pi image builder that installs all the required dependencies for a raspberry pi 4, 5 or zero 2w to be used as a travel devbox.

When traveling, I always bring a raspberry pi together with my tablet (ipad). This way I have a full linux devsuite at hand using only a raspberry pi connected to my iphone or tablet using a simple usb cable.

The pi boots off the power of my phone or tablet, and I can share the internet connection of the phone to connect to the internet on the pi.

It has code-server, tailscale, syncthing and samba installed to be able to do file management and coding from the phone or tablet and sync all the changes to my offsite server for retention.

This way I can code on my zero or pi4 in the plane, on airports or wherever you have a lot of time to dev, but not a very stable internet connection.

After arrival, I start syncthing to sync my changes to and from my main server at home.

Features #

The pi builder builds a raspberry pi image based on debian with cloud-init and several utilities installed.

I use cloud-init to install my dotfiles and personal repositories post-install at first boot, as this is the configuration I am to keep private, where the image builder itself is publicly available

Using the builder #

Some background #

The builder is based on pi-gen: We use the same layered aproach but only use a single stage to create an image and add additional utilities.

A basic cloud init is installed that creates a user account and does some generic magic, but you are strongly adviced to create your own cloud-init to personalize your own image.

Directories #

We only build in a container, so paths don't have to be changed. We use a set of static directories that reduce the amount of required variables massively compared to pi-gen.

This aims to massively reduce the complexity as we only build a single stage one-ring-to-rule-em-all image without a graphical environment and other bells and whistles the multi-faceted raspberry pi image provides: We only want our dev box 😃

We use the following directories:

  • The /work directory, which contains our modules
  • The /build directory, which contains the chroot and optional temporary files
  • The /deploy directory, which is mounted to the host and will contain the image artifacts.

The config #

The config contains all the variables that can be changed and overrules.

To get started, use the config.example file and change what you know you need and leave the other values out or set to the default values.

Build an image #

First install the required tools using homebrew:

brew install moreutils qemu docker

Then build the image and the container at once:

./pi-builder -c config --build-container --build

Or use:

./pi-builder -c config --all

Run the image in qemu #

if you build your image using the --qemu flag, you can boot the image locally using qemu:

./pi-buider.sh  \
  --qemu-run \
  --qemu-image deploy/image.img.gz

Credits #

This tool is heavily inspired and based on pi-gen, from which I used a lot of functionality. pi-gen is Copyright (c) 2015 Raspberry Pi (Trading) Ltd.

Rather than having stages, we build only a single stage: Our own image.

The image is build from modules, what used to be substages, containing a set of configurations. To speed up the build, all packages are installed as much as possible in a single run.