Steven Hale Photography Rotating Header Image

SATA plug melted!

SATA fire

 

So I was making ISOs from some BD discs when I noticed a rather odd smell coming from my living room. Further investigation revealed that it was coming from my mediacentre PC that drives my projector.

The PC had shut down, and I assumed the PSU had died. But it turned out to be a Molex to SATA adapter that had caught fire and melted. Unfortunately it also wrote off the hard disk to which it was attached, since it destroyed the power socket. The PC had been running fine for the past three years without a hiccup.

A quick Google search revealed that this is actually quite common. It’s quite worrying that a little connector adaptor could have potentially burned my house down! Luckily the PSU had good short-circuit and overload protection and managed to shutdown before the whole PC burst into flames. Amazingly the PSU, motherboard, and all other components were perfectly fine once the hard disk had been replaced. I had to strip out everything from the case and clean out the bits of melted plastic and soot, and then rebuild the whole PC.

I certainly wont be using one of those Molex converters again. In fact I’m not even sure I trust SATA power connectors any more. They have always looked flimsy and had poor electrical contact areas. Not to mention they easily fall out if you so much as nudge a cable while putting the cover back on. Is this seriously the best they could come up with? But what else can you do?

Can I flash CWM recovery permanently?

In previous blog posts I’ve talked about booting the Samsung Galaxy Nexus from ClockworkMod recovery. This is a third-party open-source application that is very useful for performing system maintenance on an Android phone.

Personally I just manually boot the phone from a CWM image whenever I need to, but a few people have asked me if it’s possible to overwrite the stock Android recovery partition with CWM.

The answer is yes you can, but by default Android is set to automatically flash the stock-recovery on every boot. So as soon as you reboot CWM will be overwritten. We need to stop that happening, which luckily is easy enough to do. We just need to move two files out of the way.

As usual you’ll need the adb and fastboot commands from the Android SDK. At the time of writing, the most recent version of CWM for the GSM Galaxy Nexus is here.

First, from the bootloader flash CWM to the recovery partition and then boot into CWM.

# fastboot flash recovery recovery-clockwork-5.5.0.2-maguro.img
# fastboot boot recovery-clockwork-5.5.0.2-maguro.img

Now move both /system/recovery-from-boot.p and /system/etc/install-recovery.sh to a different location so they do not get executed. I recommend just renaming them to .bak. Some people say to delete them, but I prefer to make non-destructive modifications that I can undo.

$ adb shell mount /system
$ adb shell mv /system/recovery-from-boot.p /system/recovery-from-boot.p.bak
$ adb shell mv /system/etc/install-recovery.sh /system/etc/install-recovery.sh.bak
$ adb shell umount /system
$ adb reboot

And that’s it. You now have CWM installed permanently. Do bear in mind if you are running an otherwise-stock release of Android you will now no longer be able to install OTA updates since they require the stock recovery system in order to be installed.

If you decide you want to go back to the stock recovery system, then just rename those two files back again (remove the .bak) and reboot the phone.

Does an OTA update mean I lose root?

Do you “lose root” if you install an over-the-air update on a stock Android phone? No! All that happens is that the permissions on the “su” file get changed so it is no longer executable. Those l33t haxors will have you thinking you need to do something terribly complicated in order to “get root” but it’s really quite simple. As usual you’ll need the adb and fastboot commands from the Android SDK.

The easiest way to fix this is to boot into ClockworkMod recovery. At the time of writing, the most recent version for the GSM Galaxy Nexus is here. From the bootloader, run

# fastboot boot recovery-clockwork-5.5.0.2-maguro.img

Note, we are not flashing anything to the phone here. We are not flashing a custom recovery image or a custom ROM. We are not changing anything in any way. All we are doing is a one-time boot from a different image. If you turn your phone off and on again it will boot back into Android just as it has always done.

Once CWM is running, type the following commands

$ adb shell mount /system
$ adb shell chmod 06755 /system/bin/su
$ adb shell umount /system
$ adb reboot

All we are doing is mounting the /system partition, changing the “su” file to be executable, unmounting the filesystem, and rebooting the phone. You now “have root” again. Don’t you feel like a l33t haxor?

Obtaining root privileges on the Galaxy Nexus – the easy way!

Many people refer to “rooting” an Android phone, and almost seem to make out that you have to be some sort of l33t haxor in order to do it. Indeed, they provide “simple 1-click methods” so that the poor simple users can do it for themselves, because it would be far too difficult for them otherwise.

The truth is, for anyone even vaguely familiar with the Linux command line it is incredibly easy. And I’m going to tell you how to do it. Under Linux, there is a command called “su” for “superuser” that can be typed in order to raise the privileges of the current terminal session to “root” or “administrator”. This command is missing from Android phones. All you need to do to “root” an Android phone is copy a suitably-compiled “su” binary to /system/bin and chmod it to be executable. There. Was that so hard?

Unfortunately the /system partition is, by default, mounted read-only and so you can’t copy “su” to it. No problem, you say, we’ll just remount it read/write. But that needs root-privileges. Ah.

The easiest way to get around this is to boot into “ClockworkMod Recovery” a sort of “linux rescue” mode for Android. Since this is a third-party open-source application we need to unlock the bootloader of the Galaxy Nexus before the phone will allow us to boot from the image. This is just a one-step process, but you’ll need the adb and fastboot commands to do it. The simplest way to get these is to download the Android SDK. The current version for Linux at the time of writing is here.

Once the SDK is setup, reboot your Galaxy Nexus into the bootloader by turning the phone off, and then back on again while holding down both vol-up and vol-down at the same time. Once at the bootloader you can unlock it by simply running

# fastboot oem unlock

WARNING: This will completely wipe your phone. So please ensure you have a backup of your photos etc.

Now we can boot the phone using ClockworkMod recovery. At the time of writing, the most recent version for the GSM Galaxy Nexus is here. From the bootloader, run

# fastboot boot recovery-clockwork-5.5.0.2-maguro.img

Note, we are not flashing anything to the phone here. We are not flashing a custom recovery image or a custom ROM. We are not changing anything in any way. All we are doing is a one-time boot from a different image. If you turn your phone off and on again it will boot back into Android just as it has always done.

Now you need to download the su binary file. At the time of writing the latest release for every version of Android from Eclair onwards is here. Unzip that file, and run the following commands

$ adb shell mount /system
$ adb push su /system/bin
$ adb shell chmod 06755 /system/bin/su
$ adb shell umount /system
$ adb reboot

Wasn’t that easy? All we did was mount the /system partition, copy the “su” file to /system/bin, changed the permissions to make it executable, and then unmounted the filesystem and rebooted the phone. Congratulations, you now “have root” as those l33t haxors like to say. How simple was that? Do you really need a “1-click method” that does God knows what behind your back to do it for you? Everything we’ve used here is open-source so if you’re really paranoid you can even compile CWM and su from source to be sure there’s nothing nasty hidden within.

There’s only one last step. At the moment any application on your phone can gain elevated permissions since su does not require a root-password. To prevent this it’s best to install the Superuser app from the market since this allows you to accept or deny when an application requests root privileges. The .apk will have been included in the zip file you downloaded earlier, but there’s really no reason not to just install it direct from the market.

Happy New Year!

Happy New Year everyone!

2011 December 31

Part of the 365 Days project.

No New Year’s Eve would be complete with out a curry takeaway. Nom nom nom. Happy new year everyone!

20111231

2011 December 30

Part of the 365 Days project.

More Android development. Getting the hang of it now.

20111230

2011 December 29

Part of the 365 Days project.

Stopping for a quick bite after a day out geocaching.

20111229

2011 December 28

Part of the 365 Days project.

Now that I’ve got an Android phone, time for start learning Java! Got the Android Emulator up and running, and the first “Hello World” application working.

20111228

2011 December 27

Part of the 365 Days project.

Unfortunately most of my Christmas holiday has been reliant on these. Boo!

20111227