Skip to content

This tool able to customize any RPi image (ARM arch) by ansible playbooks on (x86_64 host).

License

Notifications You must be signed in to change notification settings

calcite/rpi_image_builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RPi SD image builder

This tool able to customize any RPi image (ARM arch) by ansible playbooks on (x86_64 host).

Requirements:

Setup docker

  • The older docker versions require to enable "experimental" mode.
    $ cat /etc/docker/daemon.json
    {
        "experimental": true
    }   
    systemctl restart docker.service
  • Run multiarch setup
      $ sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
  • Test configuration
      $ docker run --rm -t arm32v7/alpine uname -m
      ...
      armv7l

Prepare source image

Download RPi image and unpack it.

$ mkdir -p output && cd output 
$ wget https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-05-28/2021-05-07-raspios-buster-armhf-lite.zip
$ unzip 2021-05-07-raspios-buster-armhf-lite.zip
$ cd ..

Customize SD image

This demo profile kiosk creates SD image for kiosk box.

$ sudo docker build -t sd_builder:local .
$ sudo docker run -it --rm --privileged \
   -e "IMAGE=2021-05-07-raspios-buster-armhf-lite.img" \
   -e "PROFILE=kiosk" \
   -e "IMAGE_RESIZE=7G" \
   -v $(pwd):/app -v /dev:/dev sd_builder:local

Options:

The options are setup by docker environment variables.

  • IMAGE - filename of SD image (required)
  • PROFILE - profile name (required)
  • IMAGE_RESIZE - resize SD image (optional)
  • NO_BOOT_PARTITION - No. boot partition (optional, default 1)
  • NO_ROOT_PARTITION - No. root partition (optional, default 2)

Unfortunately, the progress of customizing is not shown in the main console. We can check the output by

$ tail -f ansible-log.txt 

Sometimes, the script can not unmount all folders, this error can be ignored. But we can clean up this manually by

$ sudo losetup -D  

structure of the profile

The profiles are stored in profiles folder. Important files:

  • profiles/myprofile/playbook.yml - The main ansible playbook (required). This playbook is run inside SD image. In this file, we should install packages and setup configuration.
  • profiles/myprofile/pre_tasks.yml - The file with ansible tasks (optional). Here we can manipulate with partitions or prepare external resources.
  • profiles/myprofile/post_tasks.yml - The file with ansible tasks (optional). Here we can cleanup or get data from prepared SD image (package list, ...)
  • profiles/myprofile/requirements.yml - The list for ansible roles (optional). They will be automatically installed.

About

This tool able to customize any RPi image (ARM arch) by ansible playbooks on (x86_64 host).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published