Skip to content

Instantly share code, notes, and snippets.

@neagix
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neagix/bbfed4f91f8821bed7e7 to your computer and use it in GitHub Desktop.
Save neagix/bbfed4f91f8821bed7e7 to your computer and use it in GitHub Desktop.
my scripts to manage Debian chroot environments on Android 4.2+
cd /dev/block/vold/
for D in `ls`; do fdisk -l $D | grep ^`echo $D | awk '{ print substr($1, 1, 3) }'`; done | grep '*' | awk '{ print substr($1, 1, length($1)-2) }' > /data/local/boot-device.txt
clear && echo -e "**********************\nThe individuated device of your external SD is: $PWD/`ls | grep -v $(</data/local/boot-device.txt )`\nPlease double check with output of fdisk -l before proceeding!!!\n**********************\n" && rm /data/local/boot-device.txt
VOLD=$1
DEBROOT=$2
mount -o rw,noatime,nodiratime,user_xattr,acl,barrier=0,data=ordered,noauto_da_alloc -t ext4 $VOLD $DEBROOT/ || exit $?
[[ "$(mount | grep $DEBROOT/rootfs/dev/pts)" == "" ]] && mount -t devpts devpts $DEBROOT/rootfs/dev/pts
[[ "$(mount | grep $DEBROOT/rootfs/proc)" == "" ]] && mount -t proc proc $DEBROOT/rootfs/proc
[[ "$(mount | grep $DEBROOT/rootfs/sys)" == "" ]] && mount -t sysfs sysfs $DEBROOT/rootfs/sys
mount | grep $DEBROOT | grep ^/dev/block | awk '$2 { $2 = "/"; print }' > $DEBROOT/rootfs/etc/mtab
echo "$DEBROOT mounted successfully"
DEBROOT=$1
shift
PATH=/usr/bin:/usr/sbin:/bin:$PATH TERM=linux HOME=/root USER=root busybox chroot $DEBROOT/rootfs/ $@
deb http://http.debian.net/debian wheezy main
deb-src http://http.debian.net/debian wheezy main
deb http://http.debian.net/debian wheezy-updates main
deb-src http://http.debian.net/debian wheezy-updates main
deb http://security.debian.org/ wheezy/updates main
deb-src http://security.debian.org/ wheezy/updates main
DEBROOT=$1
umount $DEBROOT/rootfs/dev/pts && \
umount $DEBROOT/rootfs/proc && \
umount $DEBROOT/rootfs/sys && \
umount $DEBROOT && \
echo "$DEBROOT unmounted successfully"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment