[Optimus One, P500 Original Android Development] Tasssadar:
This tutorial is based on this one for G1: http://www.saurik.com/id/10

Hi,

I'll show you how to run debian in chroot on our optimus one. It wont affect android in any way, and they can run simultaneously, side by side. You are only running bash from debian, not its kernel or any other low-level part. But you can use debian's programs.

Requirements

* Linux on your pc or in virtual machine

You need debootstrap to make debian image, so you need debian distro (maybe in *buntu it is too, but I am not sure). You dont need GUI, bash is all you need.

* Busybox(-> rooted phone)

Most custom roms comes with busybox, I am not sure how about store ROM.

* Terminal emulator on phone and/or ADB

I suggest you to make sure you have adb, because you dont wanna write it all on small touch keyboard.

Some knowledge about linux systems

If you are following this tutorial only because you want to /flex on your friends and you dont know anything about linux, then you really _should_ stop reading this tutorial.

I also recommend you to have a2sd, so we can put debian image on its partition, when it is on sdcard main partition, it _may_ cause some problems with usb mass storage.

So, lets start.

1. Getting debian image

Boot into debian and get bootstrap tool:

apt-get install debootstrap

Now, create an empty disk image, I'd say minimum size is about 150mb, but I recommend you use more:

dd if=/dev/zero of=debian.img seek=*size_in_bytes* bs=1 count=1

You need to create ext filesystem in image with this tool(you can try it with "sudo" if you have problems):

mke2fs -F debian.img

Image is ready now, now lets mount it so we can install debian into it:

mkdir debian
mount -o loop debian.img debian

Debootstrap tool will do all the work for us. You can try to use squeeze instead of lenny or download it from your country's mirror. "--variant=minbase" argument will install just base system with apt-get and only few other packages. (This also may need sudo)

debootstrap --verbose --arch armel --foreign lenny debian http://ftp.cz.debian.org/debian
umount debian

2. Mount the image

Now, we will use ADB shell to mount the image and finish debian installation. Do not forget to write "su" before you start, we need root for this.

You need to decide where to put debian.img. I suggest you to put it on a2sd partition, which is system/sd, so :

cp /sdcard/debian.img /system/sd
export kit=/system/sd

Our mount point will be /data/local/mnt, so lets make some variable to make it easier:

export mnt=/data/local/mnt
busybox mkdir -p $mnt

We also need to set these enviroment variables, and we can also make alias for busybox so we dont have to write busybox all the time.

export PATH=/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/root
alias _=busybox

Now we need to create loop device for image:

_ mknod /dev/loop0 b 7 0

And if nothing went wrong, you should be able to mount image now ("mount: no /etc/mtab" is normal) :

_ mount -o loop,noatime $kit/debian.img $mnt

3. Finalizing installation of debian

With mounted image, we can proceed to second stage of debian bootstrap:

_ chroot $mnt /debootstrap/debootstrap --second-stage

If you want install some packages with apt-get, you also need to add repo to sources.list. Of course, if you downloaded squeeze instead of lenny, you need to change "lenny" to "squeeze"

echo 'deb http://ftp.cz.debian.org/debian lenny main' >$mnt/etc/apt/sources.list

Set correct DNS servers - debian can't take them from Android.

echo 'nameserver 4.2.2.2' >$mnt/etc/resolv.conf

Done, installation over.

4. Running debian bash

To get to debian bash, use this command. You can try "cat /etc/issue.net" or "uname -a" so you can see its really debian.

_ chroot $mnt /bin/bash

But its not all yet, you need to mount some things for debian:

mount -t devpts devpts /dev/pts
mount -t proc proc /proc
mount -t sysfs sysfs /sys

Now link mtab to /proc/mounts. You need to do this only once.

rm -f /etc/mtab
ln -s /proc/mounts /etc/mtab

And if you want to use ssh server to log in into debian, you also should set root pass:

passwd root

5. Installing packages

First, you need to update packages list:

apt-get update

and now you can install whatever you want with "apt-get install"!

6. Finishing

I suggest you to write some .sh script so you can mount it all with one command, for example something like this: http://pastebin.com/VT6272d5

What packages have you tested?

sshd - works great, you can connect to phone via putty or ssh

mc - works, but phone screen is to small

gcc-avr - if you are programming for avr microcontrollers, you can compile it on your phone :)

netcat - telnet connection

git-core - works great

htop - you can see this on screnshot below

apache2 - works like a charm

xfce4, Xorg server and tightvncserver - working but slow, see screenshots

gnash - working but slow, see screenshots. This is the only option how to run flash content on optimus one xD

Iceweasel - if you are using vnc server, you can browse web pages

gcc, g++, autoreconf, cmake and whatever else is needed to build mangos - working

mysql-server - you have to set "user = root" in /etc/mysql/my.conf, but works

MaNGOS - http://getmangos.com/ takes long to build, but works! See this post and also this one.

..and maybe some more which I dont remember.

Hope this tutorial helped you :)