This is a minimalistic how-to to get a Debian environment running on almost any (rooted) android phone. I adopted the method here: http://www.saurik.com/id/10 to be more universal and added some new features.
Preparing the Debian Image
You will need access to a computer dunning a Debian based distribution to create the image for you phone. I used Ubuntu 10.04. To create the image you need to install a program called debootstrap. debootstrap will allow you to create a mini Debian install in your image.
After installing debootstrap you will need to create a filesystem image for android to use and for debootstrap to install Debian to. You can use the dd command to create the image. In my example below I made a 800MB image. Once the image is made you need to format it to a Linux file system.
Once your image it formatted you should mount it and then run debbootstrap.
Below are my example commands, you may want/need to change them to fit your environment. Such as the Debian mirror, file size, etc.
sudo -s apt-get install debootstrap dd if=/dev/zero of=debian.img seek=838860800 bs=1 count=1 mke2fs -F debian.img mkdir debian mount -o loop debian.img debian/ debootstrap --verbose --arch armel --foreign lenny debian http://ftp.us.debian.org/debian umount debian/ rm -r debian/
Preparing the Debian boot script
Below is my Debian boot script (named bootdebian). I created it off the boot Ubuntu script for the HTC Droid Incredible, but modified it. My script includes the ability to become root if you are not already root, and it will mount your Incredible’s SD card and internal memory inside Debian so that you can easily move files in and out of your Chrooted environment. I also fixed some small errors on the other script. If you are not using the HTC Incredible you will want to change lines 38-47 to reflect your phone’s memory mount points.
Not everybody’s phone will use
/dev/block/mtdblock3 for the
/system mount point. Type the mount command to see what the proper mount point is on your device. The one used in this guide is for the HTC Incredible.
if [[ $EUID -ne 0 ]] then echo "Becoming ROOT!" su -c bootdebian exit 1 fi echo "Mounting system as R/W" mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system echo "Setting some stuff up.." export bin=/system/bin export img=/mnt/sdcard/debian.img export mnt=/data/local/debian export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH export TERM=linux export HOME=/root if [ ! -d $mnt ] then mkdir $mnt fi echo "Mounting the Linux Image" mknod /dev/block/loop5 b 7 0 #may already exist losetup /dev/block/loop5 $img mount -t ext2 -o noatime,nodiratime /dev/block/loop5 $mnt mount -t devpts devpts $mnt/dev/pts mount -t proc proc $mnt/proc mount -t sysfs sysfs $mnt/sys echo "Setting Up Networking" sysctl -w net.ipv4.ip_forward=1 echo "nameserver 126.96.36.199" > $mnt/etc/resolv.conf echo "nameserver 188.8.131.52" >> $mnt/etc/resolv.conf echo "127.0.0.1 localhost" > $mnt/etc/hosts echo "Mounting sdcard and emmc in /mnt" if [ ! -d $mnt/mnt/emmc ] then mkdir $mnt/mnt/emmc fi busybox mount --bind /mnt/emmc/ $mnt/mnt/emmc if [ ! -d $mnt/mnt/sdcard ] then mkdir $mnt/mnt/sdcard fi busybox mount --bind /mnt/sdcard/ $mnt/mnt/sdcard echo "Entering CHROOT " echo " " chroot $mnt /bin/bash echo " " echo "Shutting down CHROOT" umount $mnt/mnt/emmc umount $mnt/mnt/sdcard sysctl -w net.ipv4.ip_forward=0 umount $mnt/dev/pts umount $mnt/proc umount $mnt/sys umount $mnt losetup -d /dev/block/loop5 mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system
Now move both the above script and the debian.img file you made to your phone’s memory card.
Finishing up the Image
Now we need to finish up the install on your phone. Open the terminal app you plan to use on your phone, I recommend ConnectBot. First we will re-mount the system partition as Read/Write, them move out bootdebian script over, make it executable, then remove it from the SD card. Then we run the bootdebian script and run the second stage of debootstrap.The second stage of debootstap will take a while, it took me 15 minutes, let it run. Once debootstrap has finished we will add the official Debian repository into the system, then use apt-get to remove the files left over by debootstap. Here are the commands:
su mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system cat /sdcard/bootdebian > /system/xbin/bootdebian rm /sdcard/bootdebian chmod 777 /system/xbin/bootdebian bootdebian /debootstrap/debootstrap --second-stage echo 'deb http://ftp.us.debian.org/debian lenny main' > /etc/apt/sources.list apt-get autoclean apt-get update exit
You are done!
Now you can run “bootdebian” anytime from your phone’s terminal to enter a full Debian system. You can apt-get install any Debian package that has been compiled to armel. 🙂
If you want to go further you can install X, and a VNC server. This would allow you to VNC into the Debian system from your phone giving you a full X environment.
Now go enjoy your full Linux distribution on your phone!