Howto create a Debian chroot on an Android phone

Howto create a Debian chroot on an Android phone (HTC Desire and Motorola Milestone)

This page will grow once I have everything running, but this is a starting point:http://www.android-hilfe.de/anleitungen-fuer-motorola-milestone/26870-ho…

  1. [HTC Desire, unbranded, European version]: Flashed (pre-rooted and with busybox included) firmware from http://android.modaco.com/content/htc-desire-desire-modaco-com/315108/04…, taking file 2.09.405.8-update-bravo-stock-rooted-busybox-withradio-signed.zip
  2. On a Debian squeeze (amd64, but with i386 it will be similar) box:
    1. sudo apt-get install debchroot qemu-user
    2. Download qemu-arm-static from http://packages.ubuntu.com/lucid/qemu-arm-static (and its dependency) to get the build-arm-chroot script
    3. dd if=/dev/zero of=debian.img bs=1024 count=1950000
    4. sudo mkfs.ext2 -F debian.img
    5. sudo tune2fs -c0 debian.img
    6. mkdir debian
    7. sudo mount -o loop debian.img debian/
    8. sudo build-arm-chroot –verbose –arch=armel –foreign squeeze debian http://ftp.de.debian.org/debian
    9. sudo mkdir debian/sdcard
    10. sudo mount -t proc none debian/proc/
    11. sudo mount -t sysfs sysfs debian/sys/
    12. sudo mount -t devpts devpts debian/dev/pts
    13. sudo chroot debian/ /bin/bash
    14. export HOME=/root
    15. export USER=root
    16. export LC_ALL=C
    17. echo ‘deb http://ftp.de.debian.org/debian squeeze main contrib non-free’ > /etc/apt/sources.list
    18. aptitude update
    19. aptitude install –without-recommends lxde tightvncserver xfonts-base
    20. [optional, this is my personal package selection]: aptitude install psmisc nmap aircrack-ng ruby1.8 rubygems driftnet wireshark tshark subversion openssh-client openssh-server git
    21. aptitude clean
    22. echo localhost > /etc/hostname
    23. echo ’nameserver 4.2.2.2’ > /etc/resolv.conf
    24. to create VNC server startup files (setting connect password, I used password ‘debian’):
      [for HTC Desire]: vncserver -geometry 800x480
      [for Motorola Milestone]: vncserver -geometry 854x480
    25. sed -i ’s/\/etc\/X11\/Xsession/lxsession/’ /root/.vnc/xstartup
    26. echo > /usr/sbin/lxde <<EOF
      #!bin/sh
      export USER=root
      vncserver -geometry 800x480
      EOF
    27. chmod +x /usr/sbin/lxde
    28. echo > /usr/sbin/klxde <<EOF
      #!/bin/sh
      killall Xtightvnc && killall lxsession
      EOF
    29. chmod +x /usr/sbin/klxde
    30. killall /usr/bin/qemu-arm-static
    31. exit
    32. sudo umount debian/proc
    33. sudo umount debian/dev/pts
    34. sudo umount debian/sys
    35. sudo umount debian/
  3. Copy this debian.img file to the SD card under a newly created folder “debian”.
  4. Copy the startdeb and stopdeb scripts to the same “debian” folder.
  5. Deactivate the hard disk mode so that the SD card is again available to Android running on the phone.
  6. On the mobile phone (e.g. via a “local” shell with ConnectBot or with “adb shell” from the connected Debian box):
    1. mkdir data/local/debian
    2. mkdir data/local/debian/mnt
    3. sh /sdcard/debian/startdeb
    4. lxde
    5. Use any local VNC client to connect to localhost, port 5091 using the password set previously
    6. klxde
    7. sh /sdcard/debian/stopdeb
René Mayrhofer
René Mayrhofer
Professor of Networks and Security & Director of Engineering at Android Platform Security; pacifist, privacy fan, recovering hypocrite; generally here to question and learn