Code Monkey home page Code Monkey logo

pidock's Introduction

Dockerfile-driven raspberry pi disk image creator "pidock"

TIRED: Maintaining your fleet of raspberry pi devices by running commands and writing things on them ad-hoc and probably replicating by manually creating large, corruptible disk images with undocumented contents

WIRED: Maintaining your fleet of raspberry pi devices by generating disk images from a dockerfile containing their IP in one place concentrated enough to be self-documenting and highly reproducible, able to be deployed onto the latest version of an upstream base image

Requirements

To run commands as pi root during image build, the host machine must be set up with binfmt_misc to run qemu for arm binaries

On ubuntu 20: apt install qemu-user-static

Ubuntu 19.x?

This package doesn't install binfmt_misc properly prior to ubuntu 20. Run ./binfmt_setup.sh if you're running an older version of ubuntu or debian. Other distributions might require other packages or steps.

Ubuntu 18.04 Fix:

sudo apt-get install qemu-user-static

git clone https://github.com/computermouth/qemu-static-conf.git
sudo mkdir -p /lib/binfmt.d
sudo cp qemu-static-conf/*.conf /lib/binfmt.d/
sudo systemctl restart systemd-binfmt.service

Last Resort

Another easy (but insecure) method to do this is to run the following command

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

See https://github.com/multiarch/qemu-user-static

Also requires python3 and docker

How to use

Move desired raspbian base disk image to file raspbian.img

./pidock.py <action>
    [--host <hostname=raspberrypi>]
    [--passwd <password=raspberry>]
    [--dev <flash_device=/dev/mmcblk0>]
    [--img <base_image=raspbian.img>]
    [--entrypoint <run_entrypoint=bash>]

Where action is one of the following

all - Does the same as the next four commands in order
extract - Extracts files from raspbian.img to run in docker
build - Builds docker image from extracted files and custom additions
compose - Creates custom.img from built docker image
flash - Flashes custom.img onto memory device (default: /dev/mmcblk0)
run - Runs the custom Docker image after the 'build' step (Default entrypoint: 'bash')

Use Dockerfile to build the pi's root as if it were a docker image. Example simply changes pi's password to that specified by --passwd instead of the normal 'raspberry'. And installs vim, because why not?

Files in boot-overlay and root-overlay will be copied onto their respective partition. For example, touching 'ssh' on the boot partition will cause raspbian to enable ssh.

An example wpa_supplicant.conf is provided; if copied into boot-overlay, raspbian will use its ssid/psk information and auto connect on first boot.

Permissions

Note: currently requires sudo access to work around multiple permission issues

Errors

standard_init_linux.go:211: exec user process caused "exec format error"

Your binfmt_misc isn't set up correctly and docker is unable to run an ARM binary

No space left on device

Export CUSTOM_IMG_SIZE={Size in MiB of output image file} larger, default 4096 (4GiB)

Author

Erin Hensel <[email protected]>; Copyright 2020 Boulder Engineering Studio

pidock's People

Contributors

dvoros avatar eringr avatar jacobcrabill avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.