News for hackers. Stuff that matters.
Re:The chroot Technique – a Swiss army multitool for Linux s... by benou on Wednesday April 09, 2025 @03:45PM (#43636877)
Here is an example of preparing a debian ARM image on x86 with debootstrap, qemu and chroot:

  ~# sudo apt install qemu-user-static debootstrap
  ~# mkdir /tmp/arm
  ~# debootstrap --foreign --arch=armhf buster /tmp/arm http://deb.debian.org/debian
  ~# cp /usr/bin/qemu-arm-static /tmp/arm/usr/bin/
  ~# chroot /tmp/arm   # from that point, you're running ARM!
  ~# /debootstrap/debootstrap --second-stage
Re:The chroot Technique – a Swiss army multitool for Linux s... by seba_dos1 on Wednesday April 09, 2025 @06:03PM (#43638539)
These days (with recent kernels) you don't even have to copy the qemu binary into the rootfs nor use a static binary - these used to be workarounds for things that kernel now handles on its own.
Re:The chroot Technique – a Swiss army multitool for Linux s... by fsniper on Thursday April 10, 2025 @07:05AM (#43642705)
This is very cool! I had no idea you could chroot into different architectures.
Re:The chroot Technique – a Swiss army multitool for Linux s... by ranger_danger on Thursday April 10, 2025 @10:31PM (#43649954)
Well technically you can't, in the sense that chroot has no idea you're doing it... the magic of binfmt support in the kernel (setup for qemu by the post-install script for qemu-user-static I believe) basically lets you run any architecture's binary that qemu-user-* supports just by trying to execute it natively, it basically just translates the execution of "./other-arch-cmd" into "qemu-user-static ./other-arch-cmd".
Re:The chroot Technique – a Swiss army multitool for Linux s... by fsniper on Friday April 11, 2025 @05:10AM (#43651905)
Thank you. That makes sense. Even though there is a translation layer via qemu-user-static, still having the facilities to have that transparently is very fantastic. And also very fascinating and a revelation to learn about for a bearded old timer like me who has never seen it before.