Customize RaspberryPi disk images on x86_64
- Ubuntu 20.04
- Statically linked QEMU user mode emulator for armhf/aarch64
- Binfmt configuration for armhf/aarch64
- parted and kpartx
$ sudo apt install -y qemu-user-static binfmt-support parted kpartx
$ curl -O https://raw.githubusercontent.com/keichi/pi-oven/master/oven
$ sudo install oven /usr/bin
Oven is a simple yet flexible tool for customizing RaspberryPi disk images to match your needs.
$ sudo oven [options] src [dst]
By default, oven modifies and overwrites the disk image at src. If dst is
specified, src is first copied to dst and then modified. Note that oven
requires root privilege because it internally uses loop mounts and chroot.
Available options are:
-r,--resize SIZE: Resize the root file system before provisioning-s,--script PATH: Path to a shell script for customization-i,--interactive: Start an interactive shell for customization--bootpart [1-4]: Partition number of the boot partition (default=1)--rootpart [1-4]: Partition number of the root partition (default=2)-v,--version: Print version information-h,--help: Show usage
The following command will:
- Use
./raspbian-jessie-lite.imgas a base image. - Resize the image to 2000 MB.
- Customize the image by running
./foo.sh. - Save the resulting image to
./foo.img.
$ sudo oven -r 2000 -s ./foo.sh ./raspbian-jessie-lite.img ./foo.img
- If DNS resolution fails, check if
/etc/resolv.confexists within the disk image and contains a valid configuration.nameserver 8.8.8.8 - If kernel update fails on a Ubuntu image with the following error:
It's likely because of this bug in Ubuntu. Adding the following lines to
Failed to create symlink to vmlinuz-5.4.0-1038-raspi: Operation not permitted at /usr/bin/linux-update-symlinks line 64./etc/kernel-img.confshould fix the issue.do_symlinks = No no_symlinks = Yes - If you encounter the error "no space left on device" when installing
packages, resize the disk image using the
-roption.