Building Raspberry Pi images with Packer

I recently had to build a couple of Raspberry Pi images, I decided to try and set it up using Packer so the process was documented, version controlled and automatic.

I searched around for a bit, and found the project named packer-builder-arm by mkaczanowski.

Installing and running #

The project is distributed through a Docker image, so it’s quite easy to get started:

$ docker run --rm --privileged -v /dev:/dev -v ${PWD}:/build mkaczanowski/packer-builder-arm:latest build install.json

The examples for the Packer code are a bit outdated inside the project, but for the newest version of Raspberry Pi OS (based on Debian Bookworm) this worked for me:

  "variables": {},
  "builders": [{
    "type": "arm",
    "file_urls" : [""],
    "file_checksum_url" : "",
    "file_checksum_type": "sha256",
    "file_target_extension": "xz",
    "file_unarchive_cmd": ["xz", "--decompress", "$ARCHIVE_PATH"],
    "image_build_method": "resize",
    "image_path": "outputted-image.img",
    "image_size": "6G",
    "image_type": "dos",
    "image_partitions": [
        "name": "boot",
        "type": "c",
        "start_sector": "8192",
        "filesystem": "vfat",
        "size": "256M",
        "mountpoint": "/boot"
        "name": "root",
        "type": "83",
        "start_sector": "532480",
        "filesystem": "ext4",
        "size": "0",
        "mountpoint": "/"
    "image_chroot_env": ["PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"],
    "qemu_binary_source_path": "/usr/bin/qemu-arm-static",
    "qemu_binary_destination_path": "/usr/bin/qemu-arm-static"

Now I can build images with Packer, happy hacking! :)


Now read this

Teazr, a “secure” dating app with privacy issues

I have to admit, one of my hobbies include watching API implementations and looking at the traffic flow between clients and backend-servers. Teazr is the new kid on the block in the dating app scene, it is built by three danish guys, and... Continue →