By moinakg on Oct 20, 2007
While having a general discussion on smartphones Nagki suggested utilizing a phone's USB storage mode and putting a USB-bootable OpenSolaris on the SD card. Since I own a Motorola Ming Linux smartphone with a 2GB SD card this immediately got me interested. After experimenting a couple of days I managed to get the Indiana LiveCD (Slim Install) booting on my home PC (Dell Dimension E521) from the phone in USB storage mode. The Motoming is a great hacker's phone.
It was quite fun to watch and also make calls from the phone while OpenSolaris was happily booting from it. I can now carry my Motoming as around as a Slim Install demo piece with the ability to even install off it. Here are some pictures followed by more details on how I did it and what problem I faced, so that you don't think I am bluffing
First a full view of my home desktop booted into Indiana LiveCD preview release from the phone, red arrow pointing to the phone:
Here is a bad Digicam shot of a dmesg snippet showing the USB storage on the phone being recognized (click to see larger size):
A Screenshot showing /.cdrom and /usr (via lofi) mounted off the USB storage from the phone (click to see larger size):
Finally here is another pic of the phone taking a call while OpenSolaris is running of it's USB storage. Fun eh. Rather good for demos as well (click to see larger image):
It took a couple of days of experimentation to work this out. Firstly I had to put the Slim Install LiveCD onto the SD card. I have a 2GB SD card which I decided to split up into 2 1GB partitions. So first I took a backup of all existing stuff on the card, not much, mostly some useful apps and a few pictures. Then I booted into Solaris and inserted the phone which promptly got mounted. I unmounted it and used fdisk to create 2 partitions on the phone's SD card. First one being a DOS-BIG partition because that's what was present on the card originally. The other was obviously Solaris2. Then I ran devfsadm to refresh the devices and used format -e to create one big root slice in the Solaris2 partition. Finally I used newfs to put a UFS filesystem on that. It will be uber-cool to have this as ZFS on the phone but the LiveCD mechanism can't yet handle that; should be a relatively simple enhancement.
Now I lofi-mounted the LiveCD ISO image and used cpio to transfer all it's contents to the newly created UFS filesystem on USB storage. I then manually updated the microroot on the USB storage to indicate that we want a LiveUSB boot. Finally an installgrub onto the phone's USB storage completed the steps. Thus I manually performed all the steps that usbdump/usbcopy would have performed to put the LiveCD on a USB pendrive. This was required since usbdump uses the whole USB device whereas I wanted to use one partition. It should not be too difficult to enhance the usbdump script to allow for partitioning.
Now I needed to recover my original phone data and apps back. So I unmounted everything and pulled out the USB cable. Then I opened the File Manager app and browsed to the TransFlash directory via which you can access the SD card. the phone said that the card is not formatted and asked whether to format it. Doubtfully I hit on Yes and it completed formatting. Then I re-inserted the phone's USB cable and thankfully the phone has only formatted the FAT-16 partition leaving the Solaris2 partition intact - cool. Now while in Solaris I recovered all backed-up data/apps onto the phone's FAT-16 partition and pulled out the USB cable. I was able to see all my data in the File Manager's TransFlash directory but unfortunately none of the apps showed up. Pondering a bit I booted into WinXP and used WinRAR to once again uncompress the backup (tar.gz) onto the Phone's FAT partition. This time it worked and I was able to access all the apps. Probably looks like some weirdo problem with PCFS and FAT-16.
So I had the phone working properly and having 2 partitions one with an OpenSolaris LiveUSB image. All I had to do was boot it on my laptop. This is where another unfortunate problem came up. The Ferrari 3400 BIOS would hang if rebooted with the phone plugged in and a Ferrari 4000 would simply not recognize the phone even though it had switched into USB Mass-Storage mode. I tried on a few other desktops with the same result. It appears that there is some problem with the way the phone switched into USB Mass-Storage mode. It takes a while to switch and it switches when the BIOS comes up. So this might be causing the phone to not respond properly to the BIOS probe and the BIOS probably does not retry and ignores the device. Hum, so much of effort wasted! Not quite.
There are some boxes whose BIOS is unable to boot off USB. It is possible to use OpenSolaris on USB even on those. All one needed to do was to get the USB microroot booted from some other media like a CDROM and it will scan and mount the USB. So I mounted the phone and copied the directories: boot, platform dev and devices to another directory. Then I used mkisofs to create a small bootable 30MB ISO of this directory. I burned this onto a DVD-R/W. I then inserted the phone's USB cable into my home PC and inserted the CDROM and rebooted the machine from the CDROM. Once the kernel messages came up I ejected the CDROM and at last the system continued upto JDS desktop from the phone Only glitch being the phone is recognized as a USB 1.x device so it is kinda slow. But it works just fine.
This is one cool Indiana demo that I will be carrying around. I will next try to install off the phone.