Issue
I am on termux with root permission. My phone has aarch64 cpu architecture. I'm trying to chroot a ubuntu filesystem with amd64 architecture i've seen and this https://unix.stackexchange.com/a/222981 here's my command
sudo chroot ubuntu /bin/qemu-x86_64-static /bin/bash --login
i logged in successfully but when i run command
ls
or any
it's give an error like Exec format error
then i tried that command with qemu-x86_64-static like qemu-x86_64-static /bin/ls
it's execute successfully
any idea for this???
i think i can add alias for all command for starts with qemu-x86_64-static but that's not good idea...
Solution
You need to tell the kernel that when it sees an arm64 binary it should run it by launching QEMU. The mechanism for this is called "binfmt-misc", and to configure it you need to write data in the correct format to special files in the host system's /proc/sys/fs/binfmt_misc/
directory. Most Linux distros will do this for you automatically when you install their QEMU packages, but obviously Android won't do this for you.
First check that your phone's kernel has binfmt-misc support compiled in at all: there should be a file /proc/sys/fs/binfmt_misc/status
and if you cat
its contents it should read enabled
. If not, try modprobe binfmt_misc
. If after that the status
file is still not there then you won't be able to get this working unless you can somehow build a new kernel for your phone.
If the support is present in your phone's kernel, you can try the qemu-binfmt-conf.sh
script that upstream QEMU ships as a mechanism for registering QEMU with the binfmt-misc machinery:
https://github.com/qemu/qemu/blob/master/scripts/qemu-binfmt-conf.sh
(This is just a script which writes the correct lines of data to /proc/sys/fs/binfmt_misc/register
.)
Answered By - Peter Maydell
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.