This repository contains a simple script to automate the process of building custom Ubuntu images for the Raspberry Pi. It provides two ways of customizing the image:
- Script file: A script file to be run inside chroot during the image creation.
- Cloud-init configuration file: A configuration file to be applied by cloud-init once the system boots up for the first time.
In this section, the arguments of the tool are described. All arguments are optional.
-a
[armhf|arm64]
: Target architecture of image.-v
[18.04.5|20.04.3]
: Target version of Ubuntu.-h
[raspi|raspi2|raspi3|raspi4]
: Target hardware for image. It is important to provide the right value[raspi2|raspi3|raspi4]
for Ubuntu 18.04.5 and[raspi]
for Ubuntu 20.04.3. The value must align with available downloads from https://cdimage.ubuntu.com/releases/.-s
[path]
: Script file to customize image inside chroot.-c
[path]
: Cloud-init configuration file to customize image after system boot.-o
[path]
: Output image file.-q
: Enable virtualization with QEMU (unstable).
In this section, two example usages are described.
-
Build an Ubuntu 18.04.5 image with a cloud-init file.
sudo ./build.sh -a arm64 -v 18.04.5 -h raspi4 -s ./examples/script.sh
-
Build an Ubuntu 20.04.3 image with a script file and cloud-init file. Notice that the version of Raspberry Pi is not specified for Ubuntu 20.04.03.
sudo ./build.sh -a arm64 -v 20.04.3 -h raspi -s ./examples/script.sh -c ./examples/cloud.cfg -q -o output.img.xz
Out-of-the-box virtualization is possible using QEMU. However, the virtualization support for actions such as apt-get upgrade
and apt-get install
is unstable and frequently hangs. It is recommended to run the tool on the target architecture.