diff options
| author | Paul Buetow (europa) <paul@buetow.org> | 2015-06-18 21:14:04 +0100 |
|---|---|---|
| committer | Paul Buetow (europa) <paul@buetow.org> | 2015-06-18 21:14:04 +0100 |
| commit | 61516ec343af580b5cfed0f324b729fbebee4948 (patch) | |
| tree | ff48591dbe40b3569f926bee77d81df1e60b2cfa | |
Initial Commit
| -rw-r--r-- | README.md | 86 | ||||
| -rw-r--r-- | jessie.sh | 64 |
2 files changed, 150 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..63fd6dc --- /dev/null +++ b/README.md @@ -0,0 +1,86 @@ +DEBRIOD +======= + +Install a full blown Debian GNU/Linux Chroot on a LG G3 D855 CyanogenMod 12. Needs root and needs developer mode activated. + +On Linux (tested on Fedora 22) prepare a Debian GNU/Linux Jessie base image. + +```code +sudo yum install debootstrap +# 5g +dd if=/dev/zero of=jessie.img bs=$[ 1024 * 1024 ] count=$[ 1024 * 5 ] + +# Show used loop devices +losetup -f +# Use the next free one (replace the loop number) +losetup /dev/loop0 jessie.img + +mkdir jessie +sudo mkfs.ext4 /dev/loop0 +sudo mount /dev/loop0 jessie +sudo debootstrap --foreign --variant=minibase --arch armel jessie jessie/ http://http.debian.net/debian +sudo umount jessie +``` + +Initial (manual) setup on external SD card on the Phone via Android Debugger + +``` +adb root +adb shell +mkdir -p /storage/sdcard1/Linux/jessie +exit +adb push jessie.img /storage/sdcard1/Linux +adb shell +cd /storage/sdcard1/Linux +# Show used loop devices +losetup -f +# Use the next free one (replace the loop number) +losetup /dev/block/loop1 $(pwd)/jessie.img +mount -t ext4 /dev/block/loop1 $(pwd)/jessie +# Bind-Mound proc, dev, sys` +busybox mount --bind /proc $(pwd)/jessie/proc +busybox mount --bind /dev $(pwd)/jessie/dev +busybox mount --bind /dev/pts $(pwd)/jessie/dev/pts +busybox mount --bind /sys $(pwd)/jessie/sys +# Bind-Mound the rest of Android +mkdir -l $(pwd)/jessie/storage/sdcard{0,1} +busybox mount --bind /mnt/shell/emulated $(pwd)/jessie/storage/sdcard0 +busybox mount --bind /storage/sdcard1 $(pwd)/jessie/storage/sdcard1 +# Check mounts +mount | grep jessie +``` + +Second debootstrap stage, but inside the chroot on android! +``` +LD_PRELOAD='' chroot $(pwd)/jessie /bin/bash -l +export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin +/debootstrap/debootstrap --second-stage +exit +``` + +Last setup steps + +``` +export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ + >> $(pwd)/jessie/root/.bashrc + +# Fixing an error messages while loading the profile +sed -i s#id#/usr/bin/id# /etc/profile + +# Setting the hostname +echo phobos > /etc/hostname +echo 127.0.0.1 phobos > /etc/hosts +hostname phobos + +# Apt-sources +cat <<END > sources.list +deb http://ftp.uk.debian.org/debian/ jessie main contrib non-free +deb-src http://ftp.uk.debian.org/debian/ jessie main contrib non-free +END +apt-get update +``` + +Here we go! + + + diff --git a/jessie.sh b/jessie.sh new file mode 100644 index 0000000..5e9826c --- /dev/null +++ b/jessie.sh @@ -0,0 +1,64 @@ +#!/bin/sh + +set -x + +export ARG=$1 +export ROOT=$(pwd)/jessie +export LOOP_DEVICE=/dev/block/loop1 +export SHELL=/bin/bash + +function enter_chroot { + HOME=/root LD_PRELOAD='' chroot $ROOT $SHELL -l +} + +function mount_chroot { + mountpoint $ROOT + if [ $? -ne 0 ]; then + losetup $LOOP_DEVICE $ROOT.img + busybox mount -t ext4 $LOOP_DEVICE $ROOT + fi + for mountpoint in proc dev sys dev/pts; do + mountpoint $ROOT/$mountpoint + if [ $? -ne 0 ]; then + busybox mount --bind /$mountpoint $ROOT/$mountpoint + fi + done + #busybox mount --bind /mnt/shell/emulated $ROOT/storage/sdcard0 + mountpoint $ROOT/storage/sdcard1 + if [ $? -ne 0 ]; then + busybox mount --bind /storage/sdcard1 $ROOT/storage/sdcard1 + fi +} + +function umount_chroot { + #busybox umount -f $ROOT/storage/sdcard0 + busybox umount -f $ROOT/storage/sdcard1 + for mountpoint in dev/pts proc dev sys; do + busybox umount -f $ROOT/$mountpoint + done + busybox umount -f $ROOT + losetup -d $LOOP_DEVICE +} + +case $ARG in + enter) + mount_chroot + enter_chroot + ;; + mount) + mount_chroot + ;; + umount) + umount_chroot + ;; + session) + mount_chroot + enter_chroot + umount_chroot + ;; + *) + echo "Usage: $0 session|mount|umount|enter" + exit 1 + ;; +esac + |
