Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadaskay/5cc1b7bebb46b3e1a5d883cf23eedf22 to your computer and use it in GitHub Desktop.
Save tadaskay/5cc1b7bebb46b3e1a5d883cf23eedf22 to your computer and use it in GitHub Desktop.
Chroot into Raspberry Pi ARMv7 Image with Qemu
# install dependecies
apt-get install qemu qemu-user-static binfmt-support systemd-container
# download raspbian image
#wget https://downloads.raspberrypi.org/raspbian_latest
# extract raspbian image
#unzip raspbian_latest
# extend raspbian image by 1gb
#dd if=/dev/zero bs=1M count=1024 >> 2016-05-27-raspbian-jessie.img
# set up image as loop device
/sbin/losetup --find --partscan --show 2019-04-08-raspbian-stretch-lite.img
# check file system
#e2fsck -f /dev/loop0p2
#expand partition
#resize2fs /dev/loop0p2
# mount partition
mkdir -p /mnt/rpi
mount --options rw /dev/loop0p2 /mnt/rpi
mount --options rw /dev/loop0p1 /mnt/rpi/boot
# ld.so.preload fix
#sed -i 's/^/#/g' /mnt/rpi/etc/ld.so.preload
# copy qemu binary
cp /usr/bin/qemu-arm-static /mnt/rpi/usr/bin/
# copy files
export SETUP_DIR=/home/myst-setup
mkdir -p "/mnt/rpi${SETUP_DIR}"
cp build/package/myst_linux_armhf.deb "/mnt/rpi${SETUP_DIR}"
cp bin/package/raspberry/files/* "/mnt/rpi${SETUP_DIR}"
# run cmd in container
systemd-nspawn --directory=/mnt/rpi --chdir="${SETUP_DIR}" bash -ev setup.sh
# revert ld.so.preload fix
#sed -i 's/^#//g' /mnt/rpi/etc/ld.so.preload
# unmount everything
umount --recursive /mnt/rpi
# unmount loop device
/sbin/losetup -d /dev/loop0
#[Source](https://wiki.debian.org/RaspberryPi/qemu-user-static)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment