You are not logged in.
Pages: 1
Hello! First time poster.
I'm trying to perform a cross architectural chroot as described in this blog post:
https://gitbook.seguranca-informatica.p … c-approach
Basically, I parse the firmware (using binwalk) then decompress the squashfs filesystem. Then I copy over qemu-arm static and chroot in:
cd squashfs-rootsudo chroot . qemu-arm-static bin/shls
bin/sh: ls: not foundThe chroot works, but the bins on the new file system cannot be discovered... besides 'pwd' for some reason.
If I hit the tab key twice for auto-complete, I can also see all of the available commands I would expect.
I've checked my path variable and everything looks good. I can also successfully run the binaries if I pass them to qemu-arm-static directly:
./qemu-arm-static /bin/lsHere's my path:
export PATH='/bin:/usr/bin'I'm also using kitty/zsh if that makes a difference. But I've also tried with Konsole/bash. Appreciate any help!
Last edited by greatergood (2022-12-14 13:30:08)
Offline
are the binaries present, with executable bits set? does 'set' work and does it show that the PATH is indeed set? does /bin/ls or /usr/bin/ls work?
Offline
are the binaries present, with executable bits set? does 'set' work and does it show that the PATH is indeed set? does /bin/ls or /usr/bin/ls work?
Yes, the binaries are present and marked executable. They are mostly sym links to busybox. Busybox is present.
'set' works surprisingly, and shows that the PATH is correct.
Neither /bin/ls nor /usr/bin/ls work, even though I can see they are present.
Offline
does it show up in /proc/sys/fs/binfmt_misc/? if not then I guess the binfmt_misc step is somehow missing or fails for you, and you have to manually specify qemu-arm-static every time
note that even in a chroot, it's still quite dangerous to run random stuff with root permissions. qemu might not protect you from that unless you run a full VM
Offline
does it show up in /proc/sys/fs/binfmt_misc/? if not then I guess the binfmt_misc step is somehow missing or fails for you, and you have to manually specify qemu-arm-static every time
note that even in a chroot, it's still quite dangerous to run random stuff with root permissions. qemu might not protect you from that unless you run a full VM
This arch install is running in a VM since it's for doing goofy stuff like this, appreciate the warning though ![]()
Here's what's in /proc/sys/fs/binfmt_misc (outside of the chroot):
ls /proc/sys/fs/binfmt_misc
CLR register statuscat /proc/sys/fs/binfmt_misc/CLR
enabled
interpreter /usr/bin/mono
flags:
offset 0
magic 4d5acat /proc/sys/fs/binfmt_misc/status
enabledAppreciate you helping to debug!
Offline
Well, I'm not that familiar with qemu user mode or binfmt_misc myself. But I expect it should be registered in there if it was to run automatically.
Debian wiki has a guide for Raspberry Pi https://wiki.debian.org/RaspberryPi/qemu-user-static where they also put the qemu-arm-static binary in the path ( /mnt/usr/bin instead of /mnt ) maybe that could be related?
Otherwise there is some ingredient for binfmt_misc functionality missing. Here are also some binftm configuration steps mentioned: https://unix.stackexchange.com/question … hitechture
Never done it myself but something like that should probably be it then
Offline
Well, I'm not that familiar with qemu user mode or binfmt_misc myself. But I expect it should be registered in there if it was to run automatically.
Debian wiki has a guide for Raspberry Pi https://wiki.debian.org/RaspberryPi/qemu-user-static where they also put the qemu-arm-static binary in the path ( /mnt/usr/bin instead of /mnt ) maybe that could be related?
Otherwise there is some ingredient for binfmt_misc functionality missing. Here are also some binftm configuration steps mentioned: https://unix.stackexchange.com/question … hitechture
Never done it myself but something like that should probably be it then
An issue I'm having is a lot of these guides (including the one mentioned in the StackExchange post) talk about using binfmt-support packages and related commands (update-binfmts). This package/commands seem to be deprecated as this functionality is included in systemd now I believe...
I moved the qemu-arm-static to the /x/usr/bin/ directory, where x is my alternate filesystem. I then chrooted using the following command:
sudo chroot . qemu-arm-static /bin/shStill no luck ![]()
whoami
/bin/sh: whoami: not foundI also found this post: https://archlinuxarm.org/forum/viewtopi … 57&t=12969
which led me to this script: https://github.com/qemu/qemu/blob/maste … mt-conf.sh
which also didn't work out...
Last edited by greatergood (2022-12-14 14:26:48)
Offline
Just tested on a debian based distro and everything worked properly...
Offline
I came across this problem as well, I think. For me I think the fix was to install
qemu-user-static-binfmt. It automatically replaced
qemu-user-binfmtand after that everything worked fine.
I got the clue from https://wiki.archlinux.org/title/QEMU#C … rom_x86_64, but it was not really described there.
Offline
To clarify, static QEMU worked even before, but unexpectedly not inside a chroot, and I think that was the problem described in this thread as well.
Offline
Pages: 1