I have done something horrible…
I maintain a custom ROM, that is, firmware for a phone that is modified from what you get straight out of the box. This one isn’t all that different, some apps replaced, several more removed altogether. That isn’t the problem though.
I received a request from one of the users to have the ROM use the external storage (or MicroSD card) for user data (since the internal storage options are limited – 1.3GB doesn’t give you a lot to play around with). That doesn’t seem to be a problem either, after doing a lot of research into how to trick the device into doing such. I created a special version of the boot image, and then ROM to house it in, and then went to prepare my MicroSD for the install.
I backed up my special second partition on the external storage, using the dd command. Essentially:
dd if=/dev/block/mmcblk1p2 of=/external_sd/mmcblk1p2.img
I then went to format mmcblk1p2. I was saying to myself “don’t format internal storage” over and over as a reminder, then I went on to “flash” the test ROM. Everything looked good, wiped dalvik cache, and rebooted. Nothing came up. Held down the power button for a few seconds, no response. So I checked my terminal screen, cause I had a sinking feeling. Turns out, I just formatted mmcblk0p2 (which works out to be the bootloader of the internal storage)!
I am in it deep. Device won’t turn on, not even for Download Mode (it’s an LG phone). I plugged it into a Windows machine, and I do get USB activity (a device by the name of “QHSUSB_DLOAD” comes up). Nothing I can do with it though (no Android Debug Bridge, no LG Emergency software connection). Turns out, it is for only QPST, and what I am looking to restore can’t really seem to be done with that tool.
I then found a forum thread, that if you load the first 80MB of a working device onto a 16GB (or larger) MicroSD, the failed boot will “cascade” or fall back to the MicroSD, and hopefully start up.
So I found another user with the same device, and asked him to run a command to get the beginning partitions of his block device. He uploaded it for me, I loaded the debrick file onto a 4GB MicroSD (using dd of course). The guide says it doesn’t work for less than 16GB, but the guide was made for a device that had 16GB of internal storage – since my device has only 4GB, I think the rationale is that the partitions will still point to an appropriate address, even if the device doesn’t call that information. Anyway, I inserted the loaded MicroSD, inserted the USB cable (while holding down the Vol-Down button), and I got recovery mode!
I then used Android Debug Bridge to start a shell into the device, and dd’ed the second partition on the MicroSD into the second partition in internal storage. Seems as though I am ready to boot my test ROM. So I turned the device off, replaced the SD cards, booted up, and normal boot. Except…
Halfway through start-up, I get a single tone, and shutdown. Could not power up again. Thinking something was still wrong, I inserted the USB cable (while holding down Volume down button), and got into Download Mode. I restored back to factory defaults with the LG Emergency tool, rebooted, and off again. When I managed to get it started, I get a message along the lines of “Battery too low. Please charge before starting.” Makes sense as to why I got a shutdown earlier (as I wasn’t charging at the time), and needlessly put everything back to scratch. This ordeal took several days, so no wonder for the time the device was powered on, the battery was discharging that whole time.
Oh well, at least the device is working, and I can leave the test for another day.
Epilogue (since I wrote this before I had WordPress set up):
I have since reformatted the blk1p2 partition and reloaded the ROM, all looks good. I then turned the device off, backed up the entire MicroSD, and then re-partitioned (I had a third, unused partition at the end of the drive, that I removed and then grew the second – essentially a no-format combine). I popped the MicroSD back in, booted up the F3Q, and had no issue either…
…and now I have 2GB to play with for userdata, instead of the initial 1.3GB. Tight, I know, but for the time being it saves having to shrink my already-full first partition.