[G1 Android Development] ChrisDos:
Debian on it's own partition

It looks like Cyanogenmod 4.2.15.1 has problems with mounting loop devices. Since I'm a long time Linux and Debian user (since '93), I wanted to get Debian and X11 working.

I should mention that these instructions are not for neophytes but for advanced Linux users.

So I made some changes to my phone and the Debian install to get this to work:

I have 4 partitions on my Class 6 8GB micro sdhc card now:

Part 1: 5GB FAT32 - For the /sdcard mount

Part 2: 512MB Ext4 - For apps2sd

Part 3: 512MB Swap (I can't stress enough how much this has improved the response and usability of my phone)

Part 4: 2GB Ext4 - For Debian

I used my laptop running Linux to copy the files from the debian.img loopback file to the partition. You could probably use a Linux LiveCD such as Knoppix, SysRescCD, or Finnix if you don't have access to a Linux machine.

I copied the debian.img file to /tmp/

mkdir /tmp/debloop

mkdir /tmp/debpart

mount -o loop /tmp/debian.img /tmp/debloop

mount /dev/mmcblk0p4 /tmp/debpart

rsync -av --progress /tmp/debloop/* /tmp/debpart/

umount /tmp/debloop

umount /tmp/debpart

I updated the installer.sh file to use the partition instead of the loop device:

# New installer.sh

mount -o rw,remount -t yaffs2 /dev/block/mtdblock3;

echo "Filesytem remounted as read/write";

rm /system/bin/fsrw;

rm /system/bin/bootdeb;

rm /system/bin/unionfs;

rm /system/bin/installer.sh;

rm /system/bin/mountonly;

echo "Removed old Installation Files"

sleep 1;

mkdir /data/local/mnt;

echo "Made /data/local/mnt";

sleep 1;

cp /sdcard/debian/fsrw /system/bin;

cp /sdcard/debian/bootdeb /system/bin;

cp /sdcard/debian/unionfs /system/bin;

cp /sdcard/debian/installer.sh /system/bin;

cp /sdcard/debian/mountonly /system/bin;

echo "Copied new Installation Files";

echo " ";

echo "VERSION 2.2";

echo "Custom Debian Bootloader is now installed!";

echo "This process does NO damage to your Android OS!";

echo " ";

echo "Courtesy of http://www.myhangoutonline.com";

echo "Installer by WhiteMonster84";

echo " ";

echo "To enter the Debian Linux console just type 'sh bootdeb'";

echo "PS: Be sure to run 'sh /scripts/onetime.sh' as root from the shell after your FIRST 'boot'.";

Here is the updated bootdeb:

# Based on Saurik's remount.sh - modified by WhiteMonster84 of http://www.myhangoutonline.com

# Email whitemonster84@gmail.com

mount -o rw,remount -t yaffs2 /dev/block/mtdblock3;

echo "Android Filesytem remounted as read/write"

export bin=/system/bin;

export mnt=/data/local/mnt;

echo "Exported Path set #1"

export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH;

export TERM=linux;

export HOME=/root;

echo "Exported Path set #2"

echo " "

echo " a888a "

echo " d888888b "

echo " 8P YP Y88 "

echo " 8|o||o|88 "

echo " 8. .88 "

echo " 8 ._. Y8. "

echo " d/ 8b. "

echo " .dP . Y8b. "

echo " d8: ::88b. "

echo " d8 Y88b "

echo " :8P :888 "

echo " 8a. : _a88P "

echo " ._/ Yaa_ : .| 88P| "

echo " \ YP | 8P \. "

echo " / \._____.d| .| "

echo " --..__)888888P ._.|"

echo " "

echo " THE PENGUIN IS ALIVE "

mount /dev/block/mmcblk0p4 $mnt;

mount -t devpts devpts $mnt/dev/pts;

mount -t proc proc $mnt/proc;

mount -t sysfs sysfs $mnt/sys;

echo "Custom Linux Pseudo Bootstrapper V2.2 - by WhiteMonster84"

echo "WEB: http://www.myhangoutonline.com"

echo " "

sleep 1

echo "Starting init process"

sleep 1

echo "INIT: Debian booting....."

sleep 1

echo "Running Linux Kernel"

sysctl -w net.ipv4.ip_forward=1;

sleep 1

echo "AutoMounter started"

sleep 1

echo "Type EXIT to end session"

echo "Make sure you do a proper EXIT for a clean kill of Debian!"

echo " "

sleep 1

chroot $mnt /bin/bash;

After you run /scripts/onetime.sh (Choose a good password, you don't want to get rooted when the ssh daemon is running) once logging in for the first time, you might want to change your /etc/apt/sources.list to:

deb http://ftp.us.debian.org/debian lenny main contrib non-free

deb http://security.debian.org/ lenny/updates main contrib non-free

I modified /root/.bashrc to the following:

# ~/.bashrc: executed by bash(1) for non-login shells.

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:~/bin"

export SHELL=/bin/bash

hostname yourhostname

export PS1='\h:\w\$ '

umask 022

# You may uncomment the following lines if you want `ls' to be colorized:

export LS_OPTIONS='--color=auto'

eval "`dircolors`"

alias ls='ls $LS_OPTIONS'

alias ll='ls $LS_OPTIONS -l'

alias l='ls $LS_OPTIONS -lA'

export USER=root

You should now probably update the phone and install some apps. But you might want to do this from a ssh shell first.

So run: /etc/init.d/ssh start

Look up your ip address with: ifconfig

ssh to your phone (Windows users can use putty)

Now update your phone:

apt-get update

apt-get -u upgrade

apt-get install vim lxde tightvncserver locales tsclient pptp-linux

Locales might still be broken, so choose your locale by running:

dpkg-reconfigure locales

I set up a init file that I run after logging each time called myinit.sh that I placed in /root/bin/

#!/bin/bash

rm -fr /tmp

mkdir /tmp

chmod 777 /tmp

/usr/local/bin/vncstart

/etc/init.d/ssh start

I created a vncstart script at /usr/local/bin:

#!/bin/bash

vncserver -kill :0

sleep 2

kill -9 $(ps ax | grep vnc | grep -v grep | grep -v vncstart | awk {'print $1'})

sleep 2

rm -fr /tmp/.X0-lock /tmp/.X11-unix/X0

vncserver :0 -geometry 1024x768

Note that I made the vncserver screen larger than the display of the phone. I primarily use the Debian to run security tools and to take control of other servers. The tiny 320x480 screen isn't enough. The open source android-vnc has excellent scaling and panning.

I'm also running PPTP connection from the command line inside of Debian just fine. If there is enough interest, I'll post instructions on how to do that.

So I know have Debian running on my phone. Everything runs great and the Android system still responds perfectly fine with the large swap file. I think you could drop the swap file down to 256MB though without any issues. Iceweasel (firefox) is very slow though. I guess I'll just have to wait for the mobile version.