Saturday, December 15, 2012

QEMU User-Mode ARM for Raspbian chroot

The other day I forgot my password for my raspberrypi running raspbian. If this were a amd64 system, I would chroot the system and use passwd to reset my password, but the raspberrypi is an arm system, and the passwd binary of the guest system cannot be executed on my amd64 host system. Enter QEMU user-mode emulation.

Following loosely these intructions here:

  This is what I did: Install qemu, binfmt-support, and qemu-user:
# apt-get install qemu binfmt-support qemu-user
The step involving dpkg-cross I did slightly differently, as I noticed the necessary packages were available in synaptic for Ubuntu 12.04. This is what I installed
# sudo apt-get install libc6-armel-cross libc6-dev-armel-cross
"Point QEMU to the target linux loader For example, for the arm(el) architecture." Add this line to the /etc/qemu-binfmt.conf:
EXTRA_OPTS="-L /usr/arm-linux-gnueabi"
This is needed for chroot user-mode (no dynamic loading is possible because paths would be frubbed):
# sudo apt-get install qemu-user-static
Then I removed the raspbian sdcard from the raspberrypi, and mounted it using my laptop sdcard reader @ /media/disk. It is necessary to copy this file to the /usr/bin of the tree to be chrooted:
# cp /usr/bin/qemu-arm-static /media/disk/usr/bin
# chroot /media/disk
I was able to reset my password successfully, and I notice I can also use the chroot to build (e.g. xbmc) for arm using my laptop, which, even if its user-mode emulated arm, should still be faster per core, and I can build multi-core. That was easier than I thought it would be!

No comments:

Post a Comment