[Galaxy Tab 10.1 Android Development] maniac3389:
I've been experimenting and gathering information all day on how to build a Debian image to run on the Tab (and any other ARM Android devices, for that matter). I've found all the stuff on how to use the Ubuntu images posted, but I really wanted to know how to build a minimal system that I could have complete control over. (I used the latest version of Debian available, Squeeze, when building this, so anything that references "Squeeze" in the commands is because of that. You can easily substitute in a more generic name for files.)

I am going to break this down into a few sections.

Requirements:

Debian or Ubuntu machine (I used a VM with Ubuntu 11.04 installed on it)

Rooted Tab with BusyBox installed

Create the Image:

On the Linux machine you will need to install debootstrap

sudo apt-get install debootstrap

Create a blank image, format it and then mount it

dd if=/dev/zero of=squeeze.img bs=1M count=512

mkfs.ext4 -F squeeze.img

sudo mkdir /mnt/squeeze/
sudo mount -t ext4 -o loop squeeze.img /mnt/squeeze/

Note: The image file above is for 512MB, change it to "count=1024" for 1GB, I tried 512MB and it was very limited in space once X was installed.

Run debootstrap and install the system into the image

sudo debootstrap --verbose --arch armel --foreign squeeze /mnt/squeeze/ http://ftp.debian.org/debian

Unmount the image

sudo umount /mnt/squeeze/

Install the Image

Create a folder on the Tab, I used /sdcard/debian/ as my storage for my Debian files. Copy your newly created image over into the folder.

Installation will involve the following:

Creating a mount point and mounting the image

Chrooting into the Debian system

Setting some variables

Running the debootstrap installation

Either in a terminal on the device or using adb, do the following to install the system. (The code is commented to better explain how things are working.)

# Gain root access
su

# Create a mount point and mount the image file into it
#	You can substitute any folder instead /data/local/debian/
mkdir /data/local/debian/
mount -o loop,noatime -t ext4 /sdcard/debian/squeeze.img /data/local/debian/

# Chroot into the Debian system
chroot /data/local/debian/ /bin/sh

# Set some required variables
export PATH=$bin:/usr/bin:/usr/sbin:/bin:$PATH
export TERM=linux
export HOME=/
export USER=root

# Set the shell prompt just in case it got overwritten by something else
export PS1='$USER@$HOSTNAME:${PWD-?} # '

# Run debootstrap
sh /debootstrap/debootstrap --second-stage

# Start a bash shell
/bin/bash

DO NOT EXIT THE SHELL BEFORE MOVING ON TO THE NEXT SECTION

First Boot

Technically the system is running, but if you start to use it you will quickly notice some things just aren't right. There are a few things that I've found that I've needed to do in order to get things running right. You should only need to do these the first time the system is run.

In the Debian shell that is still running on the Tab, do the following

# This is for working DNS
echo "nameserver 8.8.8.8" > /data/local/debian/etc/resolv.conf
echo "nameserver 8.8.4.4" >> /data/local/debian/etc/resolv.conf

echo "127.0.0.1 localhost" > /data/local/debian/etc/hosts

# Needed to install packages from the repository
echo "deb http://ftp.debian.org/debian/ squeeze main contrib non-free" > /etc/apt/sources.list
echo "deb-src http://ftp.debian.org/debian/ squeeze main contrib non-free" > /etc/apt/sources.list

# Do the initial update of the package repository
apt-get update

Once that is complete return to the Android system by running the exit command

exit

So that's a fully running system right there. But we haven't addressed starting and shutting down the system.

Here is what a simple boot script would look like to both run and stop the system:

clear

echo "Mounting Debian Squeeze..."
mount -t ext4 -o loop squeeze.img /mnt/squeeze/

echo "Setting environmental variables..."
export PATH=$bin:/usr/bin:/usr/sbin:/bin:/sbin:$PATH
export TERM=linux
export HOME=/
export USER=root
export PS1='USER@HOSTNAME:${PWD-?} # '

echo "Mounting devpts/proc/sysfs..."
mount -t devpts devpts /data/local/debian/dev/pts
mount -t proc proc /data/local/debian/proc
mount -t sysfs sysfs /data/local/debian/sys

echo "Chrooting into Debian Squeeze..."
chroot /data/local/debian/ /bin/bash

echo "Unmounting devpts/proc/sysfs..."
umount /data/local/debian/dev/pts
umount /data/local/debian/proc
umount /data/local/debian/sys

echo "Unmounting Debian Squeeze..."
umount /mnt/squeeze/

You will notice that the script also mounts and unmounts additional system filesystems. Also, the script basically pauses right after the chroot command waiting for the process to end, which occurs when you type exit inside of the Debian system. In effect, the script queues up the umount commands for whenever the Debian system is exited.

I use a script similar to that (without the mount/umount because I prefer to do that myself) to start my system. I have it saved to /sdcard/debian/debian and I start the system with the following command:

su
sh /sdcard/debian/debian

Issues:

The following issues have been encountered:

If the image file is mounted then unmounted, if you try to remount the image again it will error out. (Reboot to solve)

Optional Installation:

Of course the steps above leave you with a working system, but no doubt you will want more functionality.

I've installed TightVNC using the following command:

apt-get install tightvncserver

To start it:

vncserver -geometry 1280×752

After that you can connect to it using any VNC software, either local or over the network. If you connect local, be sure to use 127.0.0.1:5901.

Note: This does not install a window manager, if you VNC into the Tab you will get a blank desktop.

I also found that the less command was missing. Turns out the easy fix was to do the following:

apt-get install less

Finally...

All of this has just been what I've encountered so far today, haven't done much more than set up the system. Please let me know if I'm missing any key parts of the system or if there are any ways that this could be more streamlined.

Hope this helps someone :)