Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Fedora chroot for Android device
# Don't add a trailing slash, the script is fragile
echo '*** ' $1 ' ***'
exit 1;
if cut -f 2 -d " " /proc/mounts | grep -q $4 ; then return ; fi
mount $1 $2 $3 $4 || error "Failed to mount $3"
if [ ! -d $ROOT ] ; then error "Wrong mount point" ; fi
# Verify that we'll be able to mount /dev in the chroot
if ! grep -q devtmpfs /proc/filesystems ; then error "Your kernel doesn't have devtmpfs support" ; fi
# Mount everything
mountfs -t ext4 /dev/block/mmcblk1 $ROOT
mountfs -t proc none $ROOT/proc
mountfs -t sysfs none $ROOT/sys
mountfs -t devtmpfs none $ROOT/dev
if [ ! -d $ROOT/dev/pts ] ; then mkdir $ROOT/dev/pts; fi
mountfs -t devpts none $ROOT/dev/pts
mountfs -t tmpfs none $ROOT/run
# Last minute fixes
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/sbin:/usr/local/sbin:/usr/games"
export PS1="$USER@$HOSTNAME:${PWD:-?} # "
# Set up internet using Google's DNS servers
if [ ! -f $ROOT/etc/resolv.conf ] ; then
echo "nameserver" > $ROOT/etc/resolv.conf
echo "nameserver" >> $ROOT/etc/resolv.conf
# And the chroot is ready
/system/xbin/chroot /mnt/sdcard/ /bin/bash || error "Failed to setup chroot"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.