Skip to content

Instantly share code, notes, and snippets.

@kleo
Last active April 7, 2022 08:55
Show Gist options
  • Save kleo/c3c7bf87bb920034c111ba0646f3626f to your computer and use it in GitHub Desktop.
Save kleo/c3c7bf87bb920034c111ba0646f3626f to your computer and use it in GitHub Desktop.
Chroot to Pi SD card on Arch Linux with Docker

Installing qemu-user-static and binfmt-support from AUR have more trouble than it should on Arch Linux I opted on using Docker for using chroot-to-pi

Credits:

https://gist.github.com/jkullick/9b02c2061fbdf4a6c4e8a78f1312a689

https://gist.github.com/htruong/7df502fb60268eeee5bca21ef3e436eb

Install and start docker

sudo pacman -S docker 

sudo systemctl start docker

Create a Dockerfile and use a recent Debian based distro as base

FROM debian:buster-slim
WORKDIR /work

Build and tag image

docker build -t kbeflo/chroot-to-pi .

Before continuing make sure you have already written the Raspberry Pi image to your SD card and already booted it at least once

Start the container

docker run -it --privileged -v /dev/bus/usb:/dev/bus/usb kbeflo/chroot-to-pi bash

Check if your sd card is present

fdisk -l

Install dependencies

Note: Except qemu, do not add these packages to the Dockerfile. They will not be installed properly on build

apt-get update

apt-get install -y wget qemu qemu-user-static binfmt-support

Get chroot-to-pi.sh

wget https://gist.githubusercontent.com/htruong/7df502fb60268eeee5bca21ef3e436eb/raw/e02726a023d57b29090dfb6485093d0f032db181/chroot-to-pi.sh

Set executable

chmod +x chroot-to-pi.sh

Start chroot-to-pi.sh

./chroot-to-pi.sh /dev/sdX

You can now continue as root or login as pi

su pi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment