Thursday, July 28, 2011

Install Ubuntu Linux on the HTC Inspire 4G

   Way before I got my first Android phone I would read about people running Debian and Ubuntu on their G1s and Nexus One phones. This can be done on the Inspire 4G as well, if you have a rooted phone and a kernel that supports mounting loopback devices, which CyanogenMod does. You can run a chrooted copy of Ubuntu Linux on top of Android. You could use this just to run command-line programs that haven't been ported from Linux to Android, but using VNC you can access the Gnome GUI and run desktop Linux apps.


   At first I couldn't get the instructions in this thread on XDA to work with my Inspire running Cyanogenmod 7, and I erroneously assumed that the kernel in CM7 didn't support loopback devices. It does, but I didn't bother to verify that until later. First I decided to try and install a kernel that I thought would help me get Ubuntu running on my phone. I found one that supported loopback and I thought it would work out ok. So I made a backup with ROM Manager, just to be safe, and then I screwed up big time because the kernel I installed using ClockworkMod Recovery was made for the Desire HD, not the Inspire 4G.

Oops!

   My Inspire wouldn't get past the boot screen, and I had to take off my cumbersome Otterbox case and pull out the battery. To fix this problem I had to plug the phone into the wall charger, hold down the volume button when I powered it back on, and that got it back into ClockworkMod Recovery and I was able to restore from my backup. Learn from my mistake and don't mess with things when you're too tired to notice important details, like what phone the random kernel you downloaded was made for.

   I finally got it all to work the next day by following the directions in this thread and creating a higher number loopback device, /dev/block/loop99 specifically, and then editing the bootubuntu script (I recommend using TouchQode to edit scripts on your phone, it's a nice programming editor for Android) to change all 3 instances of loop1 to loop99. Then I re-ran "sh ubuntu.sh" and then ran bootubuntu, and it finally got to the chrooted root prompt. After all that hassle it was real nice to see that prompt, since it meant I could move on to the next step. To clarify, you'll want to run "mknod /dev/block/loop99 b 7 99" in the terminal after you su and before you run "sh ubuntu.sh" and then run the edited bootubuntu script.

   Once the Ubuntu image was mounted and the chroot working properly, the next step in the thread was to get the GUI up and running. Not strictly neccassary if all you want to access are CLI apps, but part of the reason I wanted to do this was to see what graphical desktop Linux apps I could get to run on my measly little cell phone.

   You can access Gnome by running a VNC server in the chrooted Ubuntu image, and view it with android-vnc-viewer. Follow the directions in the XDA thread on the script you'll need to write inside the Ubuntu image, editing text with cat isn't nearly as nice as using nano but this is a quick edit. The trackpad mouse mode in android vnc viewer can be helpful for clicking on small menu items. If you bought a bluetooth keyboard to use with your Inspire like I did, it works fine for this use, although keep in mind that the arrow keys might not work correctly in landscape orientation. This issue is known in Cyanogenmod, currently the arrows move in different directions than they are labeled when the phone is in landscape mode. For example, the up key moves the cursor left.

   Cyanogenmod 7 should support Bluetooth mice as well, so I ordered this mouse to use with VNC on my Inspire. Hopefully it'll work well, and I can use it when remotely accessing other computers as well as for the local Ubuntu image.

   A copy of Ubuntu for ARM complete with the Gnome GUI running locally on smartphone hardware is a nifty thing to show off to other geeks, but running Linux on your Inspire does have practical uses. You can run desktop apps like LibreOffice or GIMP, but server stuff might make more sense. Imagine holding a LAMP server in your hand! Maybe network security stuff? I know getting the wifi on these phones into promiscuous mode isn't an option, but other network stuff can be done. It'll take a while for all the potential of this to settle in my mind, I'll write a new post if I stumble on some especially neat use for this.

No comments:

Post a Comment