1

I would like to use my Linux host to update and upgrade a Raspian image. Can this be done?

I know you can mount the image and make permanent changes, see e.g. https://raspberrypi.stackexchange.com/a/13138/101680

The reason I want to do this is I have a Pi Zero that won't boot. I suspect a bug in Raspian Buster and would like to experiment with the latest changes (Pi Zero USB On The Go cannot connect)

3
  • You could run it inside of a Docker container with QEMU: raspberrypi.stackexchange.com/a/109524/107831
    – tttapa
    Mar 27 '20 at 17:00
  • Not an answer to your question, but if I were doing work with a Pi Zero, I'd seriously consider having a Pi 3 B+ or Pi 4 with monitor and keyboard available. If monitor and keyboard are a constraint, you could still use VNC from your Linux system.
    – Bob Brown
    Mar 27 '20 at 18:29
  • @tttapa Your comment would make a great answer if you included how to save the changed container into a new Raspbian image.
    – Peter bill
    Mar 30 '20 at 19:41
1

You should be able to use Qemu User Emulation to accomplish this via chroot. Its a similar sort of setup to debootsrapping a foreign arch but you'll already have the OS installed.

This assumes your host is Debian based - i'd assume the Qemu stuff is available on other distros though.

Important steps from the Debian Wiki

sudo apt-get install qemu binfmt-support qemu-user-static

Mount your Pi SD card somewhere on your linux host

mkdir /tmp/pizero
sudo mount /dev/mmcblks0p1 /tmp/pizero (or whatever it is called on your system)

Copy the Qemu binary onto the pi SD card (can be deleted when you've finished) - might not need to do this anymore though.
cp /usr/bin/qemu-arm-static /tmp/pizero/usr/bin

Chroot into the Pi and you can then treat it as if it was running natively.
sudo chroot /tmp/pizero

and you should end up as root on the Pi and able to run apt and stuff against the Pi FS.

2
  • I've not tried this, but the referenced link does not seem to cover saving the changed Raspbian image.
    – Peter bill
    Mar 30 '20 at 19:44
  • The changes you make whilst the card is mounted on the host will persist. When you have finished exit the chroot by typing exit and sudo umount /dev/mmcblkp01 (or whatever it is) to unmount the volume and then sudo sync to write back any lingering changes. You can then eject the SD card.
    – tobyd
    Mar 30 '20 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.