Debian with Popobox v1.0

Step 1: Make a Debian image

dd if=/dev/zero of=./debian1g.img count=1024 bs=1M
mkfs.ext4 ./debian1g.img 
tune2fs -O ^huge_file debian1g.img
mount -o loop ./debian1g.img /tmp/mnt/debian1g
cd /tmp/mnt/debian1g; 
sudo debootstrap --foreign --arch=armel squeeze debian http://ftp.debian.org/debian

Step 2: Copy image to popobox

On host:

cat debian1g.img |pv - |nc -l 3333

On popobox:

mkdir /mnt/flash/sandbox/
nc host_ip 3333 > /mnt/flash/sandbox/debian1g.img

Step 3: Create follow two scripts

cat > /mnt/flash/sandbox/debian_start.sh
flash_2_path=/mnt/flash/sandbox
debian_img=$flash_2_path/debian1g.img
debian_root=$flash_2_path/debian

mkdir -p $debian_root

mount -o loop -t ext4 $debian_img $debian_root
mount -o bind /proc $debian_root/proc 
mount -o bind /dev $debian_root/dev
mount -o bind /sys $debian_root/sys
mount -o bind /dev/pts $debian_root/dev/pts
EOF(Press ctrl+D)
cat > /mnt/flash/sandbox/deb.sh
chroot /mnt/flash/sandbox/debian /bin/bash
EOF(Press ctrl+D)

Step 4: Run /mnt/flash/sandbox/debian_start.sh, then run /mnt/flash/sandbox/deb.sh

Step 5: Now you should in the debian root, there are some extra works to be done

export LD_LIBRARY_PATH=/lib/arm-linux-gnueabi
/debootstrap/debootstrap --second-stage

cat > /etc/apt/sources.list
deb http://ftp.cn.debian.org/debian squeeze main non-free contrib
deb-src http://ftp.cn.debian.org/debian squeeze main non-free contrib

deb http://ftp.cn.debian.org/debian squeeze-updates main non-free contrib
deb-src http://ftp.cn.debian.org/debian squeeze-updates main non-free contrib
EOF(Ctrl+D again)

apt-get update

dpkg-reconfigure tzdata

aptitude install locales
dpkg-reconfigure locales  (choose zh_CN.utf8 and en_US.utf8)

cat > /etc/mtab
/dev/loop0 / ext4 rw,relatime,barrier=1,data=ordered 0 0
EOF

Step 6: final step, add /mnt/flash/sandbox/debian_start.sh in /etc/rc.local, make it run at boot time

Or customize debian_start.sh to make it run your own service in debian