How to setup a Debian GNU/Linux Chroot on LG G3 D855 CyanogenMod
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Paul Buetow (uranus) 7ef975956c add android 6 debroid 6 years ago
data/local add android 6 debroid 6 years ago
storage/sdcard1/Linux add android 6 debroid 6 years ago
Deboroid.png add screenshot 7 years ago
Makefile Anger is momentary madness. 7 years ago add android 6 debroid 6 years ago


Install a full blown Debian GNU/Linux Chroot on a LG G3 D855 CyanogenMod 13 (Android 6). Needs root and needs developer mode activated.

On Linux (tested on Fedora 23) prepare a Debian GNU/Linux Jessie base image.

First debootstrap stage, on the Fedora Linux machine

sudo dnf install debootstrap
# 5g
dd if=/dev/zero of=jessie.img bs=$[ 1024 * 1024 ] \
  count=$[ 1024 * 5 ]

# Show used loop devices
sudo losetup -f
# Store the next free one to $loop
sudo losetup /dev/$loop jessie.img

mkdir jessie
sudo mkfs.ext4 /dev/$loop
sudo mount /dev/$loop jessie
sudo debootstrap --foreign --variant=minbase \
  --arch armel jessie jessie/ \
sudo umount jessie

Initial (manual) setup on external SD card on the Phone via Android Debugger:

adb root && adb wait-for-device && adb shell
mkdir -p /storage/sdcard1/Linux/jessie

# Sparse image problem, may be too big for copying otherwise
gzip jessie.img
# Copy over
adb push jessie.img.gz /storage/sdcard1/Linux/jessie.img.gz
adb shell
cd /storage/sdcard1/Linux
gunzip jessie.img.gz

# Show used loop devices
losetup -f
# Store the next free one to $loop

# Use the next free one (replace the loop number)
losetup /dev/block/$loop $(pwd)/jessie.img
mount -t ext4 /dev/block/$loop $(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 -p $(pwd)/jessie/storage/sdcard{0,1}
busybox mount --bind /storage/emulated \
busybox mount --bind /storage/sdcard1 \

# Check mounts
mount | grep jessie

Second debootstrap stage, but inside the chroot on Android!

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 # Leave chroot
exit # Leave adb shell

Setup various scripts:

adb push storage/sdcard1/Linux/ /storage/sdcard/Linux/
adb shell
cd /storage/sdcard1/Linux
sh enter

# Bashrc
cat <<END >~/.bashrc
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
export EDITOR=vim
hostname $(cat /etc/hostname)

# Fixing an error message while loading the profile
sed -i s#id#/usr/bin/id# /etc/profile

# Setting the hostname
echo phobos > /etc/hostname
echo phobos > /etc/hosts
hostname phobos

# Apt-sources
cat <<END > sources.list
deb jessie main contrib non-free
deb-src jessie main contrib non-free
apt-get update
apt-get upgrade
apt-get dist-upgrade
exit # Exit chroot

Debroid services startup (we don't use the Debian runlevels yet)

sh enter

# Setup example serice uptimed
apt-get install uptimed
cat <<END > /etc/rc.debroid
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
service uptimed status &>/dev/null || service uptimed start
exit 0

chmod 0755 /etc/rc.debroid
exit # Exit chroot
exit # Exit adb shell

Include to Android startup:

adb push data/local/ /data/local/
adb shell
chmod +x /data/local/

Reboot & test!