Installing a full Debian Linux distribution on your rooted Droid Incredible

Installing a full Debian Linux distribution on your rooted Droid Incredible

You first need access to a full Debian environment on a PC. I did all of this in my VirtualBox Debian installation. You just need to make sure you have the VirtualBox USB drivers installed (download VirtualBox 4.1.2 Oracle VM VirtualBox Extension Pack on their Downloads page) so you can read the SDCard in the Virtual Machine.

Most online tutorials use Debootstrap, which I have used successfully several times, but I decided to try Multistrap, which works much faster (assuming there are no snags). Multistrap does most of the package installation in the PC environment, before your SDCard is transferred over to the Droid.

You can choose the packages you want in the packages variable of the multistrap.conf. There’s probably some stuff there you don’t need so you can tailor it to your own installation.

On your PC, create a new file, $HOME/multistrap.conf:

[General]
arch=armel
unpack=true
debootstrap=Debian
aptsources=Debian
noauth=true
cleanup=true

[Debian]
packages=debian-archive-keyring openssh-server xserver-xorg-video-dummy xterm screen default-jdk geany iverilog openssh-client apt wget makedev dialog apt-utils aptitude xauth vim iputils-ping iceweasel aptitude gcc iproute iptables net-tools tcpd rsync telnet traceroute
source=http://http.us.debian.org/debian
keyring=debian-archive-keyring
suite=sid
components=main contrib non-free

On PC, assuming /dev/sdb is the SDCard. First, Partition your SDCard to make it a dual partition card, with a FAT32 and EXT2 filesystem.

apt-get install multistrap

mkdir /media/sdb2
mount /dev/sdb2 /media/sdb2

cd /media/sdb2
multistrap -a armel -d . -f $HOME/multistrap.conf

If something goes wrong when running multistrap, you need to delete everything (except lost+found) from your destination folder — in this case /media/sdb2 — fix your $HOME/multistrap.conf file, and try again.

This should install your environment. When its done,

umount /dev/sdb2
umount /dev/sdb1 ## (if it's mounted)

Eject the SDCard and put it in your Incredible.

You may also need BusyBox on your DINC (I don’t remember what commands are installed on the DINC by default). You can install it from the Market or find instructions on the Internet.

Now, on your phone (using a local shell; through ADB or ConnectBot):

#remount your root filesystem with write access
su
mount -o rw,remount -t rootfs rootfs /
mkdir /debian
mount /dev/mmcblk1p2 /debian

cd /debian
chroot .
export PATH=/bin:/sbin:/usr/sbin:/usr/bin
bash
mount -t sysfs sysfs /sys
mount -t proc proc /proc
mkdir /dev/pts
mknod /dev/ptmx c 5 2
mount -t devpts devpts /dev/pts



## This is needed to prevent problems with the configuration
/var/lib/dpkg/info/dash.preinst install
dpkg --configure --pending

## I got the following error message, so I had to run configure
## again to finish configuring.
## Errors were encountered while processing:
## keyboard-configuration
## xserver-xorg-core
## xserver-xorg-video-dummy

dpkg --configure --pending

passwd ##Change the root password

echo nameserver 8.8.8.8 > /etc/resolv.conf  ## Point to Google nameserver

That should be all you need. Now:

/etc/init.d/ssh start

Should bring up your SSH server. Now get on Wifi and you can connect through a shell.

Note: As of Sept, 2011 I had trouble connecting to secure websites with the Sid version of Iceweasel, so I downgraded the package libnss3-1d and it seems to work fine now:

aptitude install libnss3-1d=3.12.8-1+squeeze1

Startup and Stop Scripts

I put the debian script in /system/xbin/ on the Android phone, and the chroot.sh script in the root folder of my Debian installation.

debian:

#!/system/bin/sh


isDebianMounted () {
        if [ "$(mount | grep /debian)" != "" ]; then
                echo 1
        else
                echo 0
        fi
}

remount () {
        mount -o rw,remount /
        if [ ! -e /debian ]; then
                mkdir /debian
        fi
        
        if [ "$(mount | grep /debian)" == "" ]; then
                mount /dev/block/mmcblk1p2 /debian
        fi
}

case "$1" in

recopy)
        cp /debian/debian /system/xbin/debian
;;

link)
        rm /system/xbin/debian
        ln -s /debian/debian /system/xbin/debian
;;

debug)
        if [ $(isDebianMounted) == "1" ]; then
                echo "ok"
        fi;
        
;;

start)
        if [ $(isDebianMounted) != "1" ]; then
                remount
        else
                echo "Debian appears to be mounted."
                echo
        fi
        
        export PATH=/bin:/sbin:/usr/bin:/usr/sbin
        /system/xbin/chroot /debian /chroot.sh start
        
        ;;

stop)
        export PATH=/bin:/sbin:/usr/bin:/usr/sbin
        /system/xbin/chroot /debian /chroot.sh stop
        umount -l /debian
        ;;

chroot)
        export PATH=/bin:/sbin:/usr/bin:/usr/sbin
        /system/xbin/chroot /debian /bin/bash 
        ;;


*)
        echo "Usage: $0 (start|stop|chroot)"
        ;;

esac

chroot.sh:

#!/bin/sh

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

case "$1" in
start)
        mount -t proc proc /proc
        mount -t sysfs sysfs /sys
        mount -t devpts devpts /dev/pts
        /etc/init.d/xrdp start
;;      
stop)
        /etc/init.d/xrdp stop
        killall Xvnc 2> /dev/null
        umount /dev/pts
        umount /sys
        umount /proc
;;
esac

Notes

These packages are currently installed and take up only 37% of a 4GB sdcard:

adduser apt apt-utils aspell aspell-en base-files base-passwd bash binfmt-support binutils bsdmainutils bsdutils build-essential bzip2 ca-certificates ca-certificates-java coreutils cpp cpp-4.6 dash dbus dbus-x11 dconf-gsettings-backend debconf debconf-i18n debian-archive-keyring debianutils defoma dialog dictionaries-common diffutils dillo dos2unix dpkg dpkg-dev dropbear dselect e2fslibs e2fsprogs esound-common fakeroot file findutils fontconfig fontconfig-config g++ g++-4.6 gcc gcc-4.4-base gcc-4.5-base gcc-4.6 gcc-4.6-base gconf2 gconf2-common geany glib-networking gnome-icon-theme gnupg gpgv grep groff-base gsettings-desktop-schemas gzip hicolor-icon-theme hostname hunspell-en-us icedtea-6-jre-cacao icedtea-6-jre-jamvm icedtea-netx icedtea-netx-common icewm icewm-common icewm-themes initscripts insserv iso-codes java-common keyboard-configuration less libaccess-bridge-java libaccess-bridge-java-jni libacl1 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasound2 libaspell15 libasyncns0 libatk1.0-0 libatk1.0-data libattr1 libaudiofile0 libaudit0 libavahi-client3 libavahi-common-data libavahi-common3 libblkid1 libbsd0 libbz2-1.0 libc-bin libc-dev-bin libc6 libc6-dev libcairo-gobject2 libcairo2 libcanberra-gtk3-0 libcanberra-gtk3-module libcanberra0 libcap2 libcomerr2 libcroco3 libcups2 libdatrie1 libdb4.8 libdb5.1 libdbus-1-3 libdbus-glib-1-2 libdpkg-perl libdrm-radeon1 libdrm2 libedit2 libenchant1c2a libesd0 libexpat1 libflac8 libfltk1.3 libfont-freetype-perl libfontconfig1 libfontenc1 libfreetype6 libgail18 libgc1c2 libgcc1 libgconf2-4 libgcrypt11 libgdbm3 libgdk-pixbuf2.0-0 libgeoclue0 libgif4 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libglib2.0-0 libglib2.0-data libgmp10 libgnutls26 libgomp1 libgpg-error0 libgpm2 libgssapi-krb5-2 libgstreamer-plugins-base0.10-0 libgstreamer0.10-0 libgtk-3-0 libgtk-3-bin libgtk-3-common libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libhunspell-1.3-0 libice-dev libice6 libicu44 libidl0 libidn11 libjasper1 libjpeg62 libjpeg8 libjson0 libk5crypto3 libkeyutils1 libkrb5-3 libkrb5support0 liblcms1 libldap-2.4-2 liblocale-gettext-perl libltdl7 liblzma2 liblzma5 libmagic1 libmount1 libmpc2 libmpfr4 libncurses5 libncursesw5 libnotify4 libnspr4-0d libnss3-1d libogg0 liborbit2 libp11-kit0 libpam-modules libpam-modules-bin libpam-runtime libpam0g libpango1.0-0 libpci3 libpciaccess0 libpcre3 libpipeline1 libpixman-1-0 libpng12-0 libproxy0 libpthread-stubs0 libpthread-stubs0-dev libpulse0 libreadline5 libreadline6 librsvg2-2 librsvg2-common libsamplerate0 libsasl2-2 libsasl2-modules libselinux1 libsepol1 libslang2 libsm-dev libsm6 libsndfile1 libsoup2.4-1 libsqlite3-0 libss2 libssl1.0.0 libstdc++6 libstdc++6-4.6-dev libtasn1-3 libtdb1 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libthai-data libthai0 libtiff4 libtimedate-perl libtinfo5 libudev0 libunique-1.0-0 libusb-0.1-4 libusb-1.0-0 libutempter0 libuuid1 libvorbis0a libvorbisenc2 libvorbisfile3 libvte-common libvte9 libwebkitgtk-1.0-0 libwebkitgtk-1.0-common libwrap0 libx11-6 libx11-data libx11-dev libx11-xcb1 libxau-dev libxau6 libxaw7 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb1 libxcb1-dev libxcomposite1 libxcursor1 libxdamage1 libxdmcp-dev libxdmcp6 libxext6 libxfixes3 libxfont1 libxft2 libxi6 libxinerama1 libxkbfile1 libxml2 libxmu6 libxmuu1 libxpm4 libxrandr2 libxrender1 libxslt1.1 libxss1 libxt-dev libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 linux-libc-dev login lsb-base lsof lxterminal make man-db manpages manpages-dev mawk menu midori mime-support mount multiarch-support ncurses-base ncurses-bin net-tools netcat netcat-traditional notification-daemon openjdk-6-jdk openjdk-6-jre openjdk-6-jre-headless openjdk-6-jre-lib openssh-blacklist openssh-blacklist-extra openssh-client openssl passwd patch pciutils perl perl-base perl-modules procps psmisc python python-minimal python2.7 python2.7-minimal qemu-user-static readline-common screen sed sensible-utils sgml-base shared-mime-info socat sqlite3 sysv-rc sysvinit sysvinit-utils tar tcpd tightvncserver ttf-bitstream-vera ttf-dejavu-core ttf-dejavu-extra tzdata tzdata-java ucf udev usbutils util-linux vim-common vim-tiny w3m wget x-ttcidfont-conf x11-common x11-utils x11-xkb-utils x11-xserver-utils x11proto-core-dev x11proto-input-dev x11proto-kb-dev xauth xbitmaps xfonts-100dpi xfonts-75dpi xfonts-base xfonts-encodings xfonts-scalable xfonts-utils xkb-data xml-core xorg-sgml-doctools xrdp xserver-common xserver-xorg-core xserver-xorg-video-dummy xterm xtrans-dev xz-utils zlib1g