Interesting Things To Do With An HTC Desire Z
My Zaurus 3100 having been stolen, I sought something that could replace it. I considered the Nokia N900 phone (too small to be a tablet, unlike the N800 I had before), and whilst the keyboard and camera appealed, the small screen didn't, and the whole trainwreck of Maemo+Moblin=Meego process deterred me. I'd played with Apple products but they are a one-size-fits-all, and I refuse to be locked in. A long time later, I bought a Fujitsu U2010 (also known as the U820 when sold in Japan), which is a bit like a super-sized version of the Zaurus, or, a super-tiny netbook.
However, whilst the U2010 is somewhat of the ultimate ultra-portable x86 device, it's too big to be pocketable. In the meanwhile I'd been using a Nokia E71 phone which has a very similar form to a Blackberry, so I was still keen on a phone with a keyboard.
I'd passed on the original Google phone, the G1 aka Dream, as I'd not had the E71, and android was still an unknown quantity. Quite a while later along came the G2 aka the Vision, sold in the UK as the Desire Z. About five months after the DZ was on sale, I happened to take a job which required me to be on call to support the computer systems, so was loaned a Desire Z.
The Desire Z has a medium-level specification, a reasonable amount of internal flash memory, 3.7" capacitive touch screen at 800x600, 3G & 2G radios, 802.11b/g/n wifi, bluetooth, micro SDHC slot, but the most important feature is the keyboard. Just as the HTC Universal could once be considered as a phone version of the Zaurus, so the Vision could be considered its grandchild.
Another key aspect of the fact that it runs Android, means there is a linux kernel at its core, so although Android doesn't provide an X11 based system, you can fire up a terminal emulator, or, connect using the android debugger "adb" over USB and get a shell. You don't get root by default with Android, but it is possible to get root on the device (see cyanogenmod wiki). You can make this root permanent and flash custom firmware if you wish.
Once you've gained root, you quickly realise the android command line is very basic. Most people install a more complete version of busybox, I put a newer busybox into /data/local/bin and the associated links in there too. I then modify the environment from a file called /data/local/profile (at the command line run ". /data/local/profile") which looks like this:
TERM=linux
export TERM
HOME=/data/local
export HOME
PATH=/data/local/bin:/system/xbin:/system/xbin/bb:/sbin:/system/sbin:/system/bin
export PATH
alias psg='ps -w | egrep -i'
alias ll='ls -l'
alias debmnt='/data/local/bin/mounts-for-debian'
alias debsh='chroot /data/local/linux/debian /bin/bash'
PS1="bbsh# "
But wait, what's those debmnt and debsh aliases? Well, it is possible to create a relatively full arm linux installation, copy it onto the DesireZ, mount it, and then use chroot to get a shell in that installation, and thus enjoy a full linux experience.
I mostly followed the instructions here to create the image. I partitioned my SDHC card so that p1 is FAT for the benefit of android, p2 is a modest ext2 partition for apps2SD, p3 is a 2.5GB partition for the android installation under discussion, and p4 is a 512MB swap partition. If you aren't in a position to repartition, simply store the image as a file (4GB max with a FAT32 file system) and use loopback mount. The script below contains the relevant loopback bits.
Here's the script which mounts the debian image:
#!/system/bin/sh
#!/system/xbin/sh
# mounts-for-debian - script by PM - released under GPL
#DEBDEV=/dev/loop20
DEBDEV=/dev/block/mmcblk1p3
DEBMNT=/data/local/linux/debian
#ls -la /dev/loop20 2>&1 > /dev/null
#if [ $? -ne 0 ] ; then
# mknod /dev/loop20 b 7 20
#fi
#losetup -f | grep loop20 > /dev/null
#if [ $? -ne 0 ] ; then
# losetup /dev/loop20 $DEBMNT/debian.img
#else
# echo "loop20 already exists"
#fi
mount | grep "$DEBMNT" > /dev/null
if [ $? -ne -0 ] ; then
#mount /dev/loop20 $DEBMNT
mount $DEBDEV $DEBMNT
else
echo "$DEBMNT already mounted"
fi
mount | grep "$DEBMNT/dev " > /dev/null
if [ $? -ne 0 ] ; then
mount -o bind /dev $DEBMNT/dev
else
echo "$DEBMNT/dev already mounted"
fi
mount | grep "$DEBMNT/dev/pts" > /dev/null
if [ $? -ne 0 ] ; then
mount -o bind /dev/pts $DEBMNT/dev/pts
else
echo "$DEBMNT/dev/pts already mounted"
fi
mount | grep "$DEBMNT/proc" > /dev/null
if [ $? -ne 0 ] ; then
mount -o bind /proc $DEBMNT/proc
else
echo "$DEBMNT/proc already mounted"
fi
mount | grep "$DEBMNT/sys" > /dev/null
if [ $? -ne 0 ] ; then
mount -o bind /sys $DEBMNT/sys
else
echo "$DEBMNT/sys already mounted"
fi
mount | grep "$DEBMNT/mnt/sdcard" > /dev/null
if [ $? -ne 0 ] ; then
mount -o bind /mnt/sdcard $DEBMNT/mnt/sdcard
else
echo "$DEBMNT/mnt/sdcard already bound to /mnt/sdcard"
fi
cd /data/local/linux/debian/dev/pts
ls -la 0 || mknod 0 c 136 0
ls -la 1 || mknod 1 c 136 1
ls -la 2 || mknod 2 c 136 2
# end mounts-for-debian
You will have to tweak the script to suit your requirements. You could have used Ubuntu instead.
Then just use the command/alias debsh to get a shell. Within the debian install, you need to create /root/.profile as follows to fix the environment:
TH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/root/bin
export PATH
HOME=/root
export HOME
HOSTNAME=`cat /etc/hostname`
export HOSTNAME
USER=root
export USER
PAGER=more
export PAGER
DISPLAY=:1
export DISPLAY
TERM=vt100
export TERM
To unmount the partitions, here's my /data/local/bin/umountdeb script:
#!/system/bin/sh
DEBMNT=/data/local/linux/debian
umount $DEBMNT/sys
umount $DEBMNT/proc
umount $DEBMNT/dev/pts
umount $DEBMNT/dev
umount $DEBMNT/mnt/sdcard
umount $DEBMNT/home/cryptvol
umount $DEBMNT
This is under construction - please give feedback if you try this and
I'll try and help and use it to improve this page
This site currently under construction
|