Introduction:
I formatted a SDCard in ext4 and copied an ArchVersion on it to run it from Android like in this guide (step 6). Of course my device is rooted and am running the following scripts and commands in the Terminal Emulator as superuser.
Device-info:
- Phone: Sony Xperia Z1
- Model number: C6903
- Android version: 5.1.1
- Build Number: 14.6.A.1.236
Issue:
When I execute sh chroot_bashonly.sh
the error tmp-mksh: chroot: not found
appears. Of course I looked in the script to figure it out myself:
chroot_bashonly.sh:
#!/bin/sh
export LINUXROOT=/data/local/mnt
export TMPDIR=/tmp
export HOME=/root
export USER=root
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:$PATH
export TERM=vt100
sh ./mount.sh
echo "******* Your chroot-environment is starting now ********"
chroot $LINUXROOT /bin/bash # tmp-mksh: chroot: not found
echo "******* You exited the chroot-environment, unmounting... ********"
sh ./umount.sh
echo " ## DONE"
mount.sh:
#!/bin/sh
export LINUXROOT=/data/local/mnt
export TMPDIR=/tmp
export HOME=/root
export USER=root
export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:$PATH
export TERM=vt100
# mount /
mkdir $LINUXROOT #works
mount -t ext4 -o noatime,rw /dev/block/mmcblk1p2 $LINUXROOT #works
# mount other stuff
mkdir -p $LINUXROOT/proc
mkdir -p $LINUXROOT/sys
mkdir -p $LINUXROOT/dev
mkdir -p $LINUXROOT/dev/pts
mkdir -p $LINUXROOT/var/lib/dbus
mkdir -p $LINUXROOT/android_storage/sdcard0
mkdir -p $LINUXROOT/android_storage/sdcard1
mkdir -p $LINUXROOT/system
mount -t proc proc $LINUXROOT/proc
mount -t sysfs sysfs $LINUXROOT/sys
mount -o bind /dev $LINUXROOT/dev
mount -t devpts devpts $LINUXROOT/dev/pts
mount -o bind /system $LINUXROOT/system
mount -o bind /storage/sdcard0 $LINUXROOT/android_storage/sdcard0
mount -o bind /storage/sdcard1 $LINUXROOT/android_storage/sdcard1
echo "******* everything mounted ********"
I think the mount.sh part works, at least I get no error and the mkdir
-created folders existing. So the next thing I tried was to run chroot
outside the script in many forms with the same error.
chroot /data/local/mnt /bin/bash
chroot /data/local/mnt /system/bin/sh
chroot /data/local/mnt /bin/sh
All having the same issue: tmp-mksh: chroot: not found
.
So what is wrong?
Is chroot even available on Android?
type chroot
orwhence -v chroot
, and tell us the result.type chroot /data/local/mnt /bin/bash
. Result (error): 1.chroot not found
, 2./data/local/mnt not found
(but it exists), 3./bin/bash not found
. I triedtype chroot /data/local/mnt /system/bin/sh
. Result (error): 1. same, 2. same, 3./system/bin/sh is /system/bin/sh
.... The results forwhence -v chroot
are equivalent.type
, with one and only argument for it, which waschroot
. Aside from that, you may need to install BusyBox, in order to be able to use chroot, since your device lacks it.type chroot
referschroot is /system/xbin/chroot
. But now I get the errorchroot: cant execute '/bin/bash': No such file or directory
or for /system/bin/shchroot: cant execute '/system/bin/sh': No such file or directory
. Well I checked the /system/bin/sh file. Like it is stated in this post it is exisitingtype sh
: this will tell you the location of the shell binary, which you'll need to replace any instance of /bin/bash with.