Well, after having ran Cyanogenmod 7.1RC for a few weeks, I though it was fit to see about getting some unix tools since I can ssh into my phone.

While this isn’t too impressive or useful half the time, with just messing around it’s pretty fun, so I found a bunch of unix tools such as f/e/grep and wget and vim that people had compiled for android. All fine and dandy, but what about a chrooted unix environment? I had seen several things on hack a day and what not about running debian inside of a chroot on android, and thought “what about Arch linux?” I use Arch on my netbook, and while yes, the VPS hosting this website is running Debian, theres nothing quite like running a pacman command on a phone, so I set out in search to see if someone had done this before.

The results:
A single forum post which had instructions that didn’t work for me on CM7. So I set to work modifying them. Not much was needed but heres the procedure for installing and running Arch in a chrooted environment on android:

Heres my hardware so you know:

Droid Incredible by HTC, 4GB sdcard with 2.5GB open. Cyanogenmod 7 RC1.

I used Irssi-Connectbot to get a terminal on my phone then started dropbear and did all of these commands through ssh (sometimes a full keyboard is just better than a small virtual on screen one).

bash #gives us auto complete and possibly nice colors depending on your .bashrc and what not
cd /sdcard
mkdir arch
dd if=/dev/zero of=archarm.img seek=749999999 bs=1 count=1 #you can change the size if you want, I just wouldn't go any smaller than 750mb. I did a 2gb file since I had the space.
mke2fs -F archarm.img
mknod /dev/block/loop256 b 7 256
losetup /dev/block/loop256 archarm.img
mount -t ext2 /dev/block/loop256 arch/
cd arch
tar xzf ArchLinuxARM*.tar.gz
rm ArchLinuxARM*.tar.gz
mount -o bind /dev/ /sdcard/arch/dev
#mkdir media/sdcard #held off on this but you can do it
#mkdir media/emmc #place to mount the incredibles internal memory
#mount -o /sdcard/ /sdcard/arch/media/sdcard #mount the sdcard
#mount -o /emmc/ /sdcard/arch/media/emmc #mount the internal storage
chroot . /bin/bash #enter the chroot, your now in the Arch install.
#next we need to set some stuff up to make sure everything works well:
echo "nameserver" > /etc/resolv.conf
mount -t proc proc /proc
mount -t sysfs sysfs /sys
source /etc/profile
export TERM=xterm
export HOME=/root
mount /dev/pts
pacman -Syu #and update to make sure we're good to go...

Now you should have a working Arch linux install on your phone. Next we’ll do some bash hacking to make it nicer.

To exit the chroot:

exit #get back to android's bash and not the Arch bash (ie: exit the chroot)

I placed the following into /data/opt/arch and chmod 755 /data/opt/arch

This makes it easier to start the chroot

#quick hack to mount and start the chroot...
if [ "mount | grep arch" ]; then
        cd /sdcard/arch/
        chroot . /bin/bash
        mknod /dev/block/loop256 b 7 256
        losetup /dev/block/loop256 /sdcard/archarm.img
        mount -t ext2 /dev/block/loop256 /sdcard/arch/
        cd /sdcard/arch/
        mount -o bind /dev/ /sdcard/arch/dev
        chroot . /bin/bash

I also did:

echo "export TERM=xterm" >> /etc/profile
echo "export HOME=/root" >> /etc/profile

To make sure this all happens properly

In the chroot I made this file and placed it in the root as file: start
Again, chmod 755 start

#quick hack to start up everything for the chrooted Arch
if [ "mount | grep proc" ]; then
        echo "Proc already mounted, skipping..."
        mount -t proc proc /proc
if [ "mount | grep sysfs" ]; then
        echo "Sysfs already mounted, skipping..."
        mount -t sysfs sysfs /sys
if [ "mount | grep devpts" ]; then
        echo "Sysfs already mounted, skipping..."
        mount /dev/pts

Simply run:

./start; source /etc/profile

Finally: X11
Some people don’t like just having the cmd line, so you might want to do a X11 VNC thing like so:

pacman -S xvfb x11vnc icewm

Which will install the xvfb which is needed to make a virtual frame buffer, the x11vnc vnc server to serve the vnc connect and the desktop icewm.

Xvfb :1 -extension GLX -fp /usr/share/fonts/misc -screen 0 800x480x16&
DISPLAY=:1 /usr/bin/icewm& #change this line to the wm of your choice
x11vnc -display :1 -forever -noshm -bg -nopw -xkb

Goes into vnc in /root/ of the chroot for starting the VNC.
Simply use androidvnc to connect to localhost:5900 to get yto your new arch chroot.

Hope you all enjoy and get this working as well as I did!