Sunday, January 8, 2012

How I Rooted my Samsung Galaxy Nexus

After seeing my battery in the "red" barely more than 24 hours after a full charge, I decided it was time to take action. I had previously rooted two phones and managed to significantly extend the battery life from 1-2 days to 5+ days. So, last night I sat down to root my Galaxy Nexus. Rooting the Nexus is a bit different from other phones I had rooted. Instead of running a special app (like Gingerbreak), the idea is to unlock the bootloader, then boot to a special image that gives you read/write access to /system, and install the su binary and Superuser app.

I used scary alien's HowTo as my guide. The first thing I did was to see whether I could run the adb utility. I downloaded the package, and made the linux versions of the tools executable. But, when I ran ./adb devices, I got "???????? no permissions". I found that I could make it work with "sudo", but searched for and found a better way---give myself USB permissions to the device. Information can be found under "Configuring USB Access" in the Initializing a Build Environment document. (After editing "<username>",) I copied the two "Galaxy Nexus" lines to /etc/udev/rules.d/51-android.rules (new file), disconnected and reconnected my phone, and was then able to detect my device with ./adb devices.

The next step for me was to unlock the bootloader. This was as easy as described by the HowTo guide. I booted my phone into "fastboot" mode by powering down my phone, then holding down the VOLUME UP, VOLUME DOWN, and POWER buttons. Once I was in "fastboot", I confirmed that the fastboot utility could "see" my device, then issued the ./fastboot oem unlock command from my computer. At the bottom of the phone's screen I could see that the bootloader had been unlocked. From there I had a decision to make---what method to use? After realizing that the essential file for the "manual" method was missing, I decided on the ClockworkMod method.

I downloaded the and recovery-clockwork-, then soft-booted into the ClockworkMod: ./fastboot boot recovery-clockwork- I followed the instructions to ensure that /sdcard was mounted, but kept getting the error message: "E:can't mount /sdcard/". I read that restarting might fix the problem, so I opted to reboot ClockworkMod (under "advanced" menu). Bad idea. I ended-up with my phone in a frozen state---a green robot on its back with its chest open with a red triangle with exclamation point floating above. I had to remove the battery and leave it out for appx. 60 seconds (until the screen went blank) before I could then restart the phone.

The restart took a while. As the HowTo describes, it goes through the startup sequence, then restarts and goes through the startup sequence again. When it was done, it led me through the new phone tutorial I got when I first turned-on the device. All my settings had been reset (as expected). After going through the tutorial, I tried the ClockworkMod method again. This time I did not get the /sdcard errors and the install appeared successful. But, when I restarted back into "normal" mode, I couldn't get root privileges.

My phone otherwise seemed to be fine, so I moved on to the Superboot method. After downloading the superboot package and unzipping it, I booted my phone into "fastboot" mode, checked that the fastboot utility recognized my phone, and ran (from my computer). My phone restarted and I checked that I had root privileges by trying to change settings via the Autostarts app. Yes! It worked!

I used Autostarts to turn off a ton of automatic startups, being careful to avoid things like "Contacts", "Phone", "Android System", "Calendar Storage", "Download Manager", "Media Storage", "SIM Toolkit", "System UI", "Google One Time Init" and "Google Services Framework". However, I may have turned-off too many services since I later lost my ability to get root (the error message was something like "Superuser has stopped running"). But, a fix wasn't difficult. From "Settings", I went to the "Apps" menu, selected the Superuser app, cleared its data, "Force Close"d, then restarted Superuser. After that, I was able to get root privileges via the Superuser app as usual.

P.S. In addition to modifying auto-start settings, I also removed a few apps using Titanium Backup: Music, MusicFX, Videos, YouTube, and Voice Search.

No comments:

Post a Comment