0

I have downloaded some firmware and I want to run some commands in it. I have extracted the firmware, installed qemu and configured binfmts. The problem is that binfmt does not work in the chroot.

Mipsel files are automatically executed by qemu-mipsel-static:

firmware$ bin/ls
/lib/ld-uClibc.so.0: No such file or directory

The command qemu-mipsel-static is available within the chroot:

firmware$ sudo chroot . /usr/bin/qemu-mipsel-static /bin/ls
webroot     tmp         sbin        media       home        dev

When combining the two, it no longer works:

firmware$ sudo chroot . /bin/ls
chroot: failed to run command ‘/bin/ls’: No such file or directory

It says "No such file or directory". Is there any way to get more information about this, for example which file can not be found? Is this indeed a problem with binfmt?

My binfmt config looks like this:

$ cat /proc/sys/fs/binfmt_misc/qemu-mipsel 
enabled
interpreter /usr/lib/binfmt-support/run-detectors
flags: 
offset 0
magic 7f454c4601010100000000000000000002000800
mask ffffffffffffff00fffffffffffffffffeffffff

Is it a problem that /usr/lib/binfmt-support/run-detectors is not available in the chroot?

1

Is it a problem that /usr/lib/binfmt-support/run-detectors is not available in the chroot?

Yes, you need to have the interpreter (and everything it needs) inside the chroot. On my system, /proc/sys/fs/binfmt_misc/qemu-mipsel contains

enabled
interpreter /usr/bin/qemu-mipsel-static
flags: OC
offset 0
magic 7f454c4601010100000000000000000002000800
mask ffffffffffffff00fefffffffffffffffeffffff

You should try either adding run-detectors and everything it needs in your chroot, or reconfiguring binfmt-misc to use qemu-mips-static directly.

  • Thanks. I tried putting the libs for run-detectors in the chroot, but this didn't work. Then I removed qemu, binfmt-support and qemu-users-static and reinstalled them. After that the run-detectors was no longer in my binfmt config, and it looked like yours. Now it works correctly. – Sjoerd Sep 2 '16 at 12:18

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.