1

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.

  1. chroot /data/local/mnt /bin/bash

  2. chroot /data/local/mnt /system/bin/sh

  3. 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?

7
  • Try issuing type chroot or whence -v chroot, and tell us the result.
    – Grimoire
    Commented Jul 5, 2016 at 6:56
  • So I tried 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 tried type chroot /data/local/mnt /system/bin/sh. Result (error): 1. same, 2. same, 3. /system/bin/sh is /system/bin/sh.... The results for whence -v chroot are equivalent. Commented Jul 5, 2016 at 7:20
  • First and foremost, I said type, with one and only argument for it, which was chroot. Aside from that, you may need to install BusyBox, in order to be able to use chroot, since your device lacks it.
    – Grimoire
    Commented Jul 5, 2016 at 7:33
  • Thanks. I am a step forward. Now type chroot refers chroot is /system/xbin/chroot. But now I get the error chroot: cant execute '/bin/bash': No such file or directory or for /system/bin/sh chroot: 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 exisiting Commented Jul 5, 2016 at 8:04
  • As before, issue type sh: this will tell you the location of the shell binary, which you'll need to replace any instance of /bin/bash with.
    – Grimoire
    Commented Jul 5, 2016 at 8:25

1 Answer 1

2

The Reason for this failure is that Android blocked chroot for som reason. Like Death Mask Salesman pointed out, it is possible to get information about the command type via type commandName e.g. in this case type chroot.

To solve the tmp-mksh: chroot: not found-error it is only required to install BusyBox.

2
  • i installed the busyBox but still the problem appear !!!
    – user197885
    Commented Nov 24, 2016 at 19:56
  • @user197885 With installed you mean that you installed busyBox out of the app store then started busyBox and installed a version of busyBox to /system/xbin ? Commented Nov 24, 2016 at 22:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .