Unlocking / Rooting the Samsung Galaxy Nexus

Update: This guide was updated August 2013 to reflect some minor changes since Jelly Bean.
Update #2: This guide was updated November 2013 to clear up confusion with the international build names. Thanks commenters!

After my HTC Wildfire and Motorola Atrix, I’m now on my 3rd Android phone in 3 years: the Samsung Galaxy Nexus. You’d think they break easy, I’m superclumsy or Android phones have a very short lifespan. None of that is true: both old phones I’ve rooted/unlocked now serve family members very well! The main reason behind buying the Nexus is development: I got fed up with having no Tegra 2 drivers for the Atrix, which was seriously hampering its upgrade path. Motorola has been quite uncommunicative about the issue, so I’d probably think twice about buying  Motorola phone again.

The Nexus (GSM version) gets its updates straight from the Google servers (there are even drivers available here): so no delay while any manufacturer pumps billions of dollars into its own crappy UI shell replacement, its own crappy social network and its own apps to do all the stuff the standard apps do, but worse. For once, I’d like a manufacturer/service marketing its goods with the slogan: Fuck Your Social Network. This is our product, it does what it says on the box, and there’s no need to embrace our <brand name here>-lifestyle.

On my Wildfire/Atrix, I worked happily (and hackily) around this fact by unlocking the bootloader and flashing custom ROMs (Cyanogenmod forever), but not having immediate driver support and having to wait for the manufacturer to barf out their own bastard child of a new Android version, hack it apart and build it back up again the way you like – after a while the patience wears thin.

Cyanogenmod Powaaaah

0. Why unlock/root? Where to get help?

One would say: ‘You’ve got a Google phone now! Why is there still the need to unlock it / root it?’. The answers are simple:

  • In order to use handy tools like Titanium Backup, setting up an sshd server, blocking ads, … and to unlock the full potential of that little Linux-Embedded device in your pocket, you need root.
  • To flash custom kernels, little tweaks to the official build or custom ROM’s, you need a custom recovery image (ClockWorkMod is the de facto standard). In order to write and run a custom recovery image, you need to be unlocked.
  • Because it’s fun and you might learn something.

That last point is also the aim of this article: there are toolkits around which can unlock/root your phone for you (like the excellent Gnex Toolkit), but if you want to understand what is happening and do it yourself, you’re better off using the standard tools. You will basically perform the actions any toolkit does, step by step and with more control!

I’ve learned everything I’ll write down here from the excellent XDA Developer forums. The information was spread out over multiple threads, and it’s easy to get confused when you’re looking at something that might be outdated info – that’s why I’m writing it down in a way it makes sense for me – hope it helps.

1. Enabling developer mode and setting up the tools: ADB / Fastboot + Drivers

This is by far the most ‘difficult’ part of this article: the actual unlocking and rooting of the Galaxy Nexus is trivial, since the phone is very developer-friendly. I recommend running the official distribution at least once and let it update to the latest official version.

Some codenames you will read a lot when looking up Galaxy Nexus guides on the internet:

The codename referring to the Galaxy Nexus in general is “Tuna”. “Takju/Maguro” refers to US GSM variants, “Yakju/Maguro” for International GSM phones (and as pointed out, the difference between Yakju and Takju are software so these are interchangeable) , “Mysid/Toro” for the LTE/CDMA variants on Verizon, and “ToroPlus” for the Sprint LTE/CDMA version.

Enabling Developer mode: In newer versions of Android (since 4.2), Google really hid the Developer options we’ll be using. This is the (unnecessarily complicated way) to enable them: On your Galaxy Nexus, go to Settings -> About Phone, scroll down to Build Number, then tap this area about 7 times. Not joking, it will tell you that Developer mode is now activated and you should see an extra option in the main settings menu. Phew!

First, make sure USB Debugging is enabled on your device: go to Settings -> Development and enable the checkbox. There might be a warning, but ignore it. We know what we’re doing, we’re learning shit!

In order to unlock/root the phone, we need to use two utilities, both official part of the Android SDK:

  • ADB, or Android Debug Bridge, which is a tool that lets you communicate with your Android device.  It allows you to run commands, exchange files, setup port forwarding, … It’s the swiss army knife of any Android developer.
  • Fastboot: The tool you use to communicate with your Android device when it is in its bootloader stage. This is the first stage of booting the device: the section that actually says: “the operating system you should boot is there!” You can put the Galaxy Nexus in fastboot mode by powering it off, and powering it back on again holding both volume buttons and the power button – more about this later!

In order to get these tools, both on Windows and Linux, just download the Android SDK. This is actually a bare-bones installation, to get you started. When it is installed, browse to the folder where you installed it and run SDK Manager.exe (Windows) or android (Linux). This will launch an updater which allows you to select which parts of the SDK you’d like to download additionally. Both ADB and Fastboot are in the platform-tools package, so download and install that.

If you open the created platform-tools folder, located within the Android SDK folder, you will find the ADB and fastboot utilities. If you open a command window in that folder, you can run adb and fastboot commands! Hurray! In order to be able to run these commands from any command window, you’ve got to add them to your system path – the place where windows goes looking for executables. This is optional, but will make using these tools a lot easier.

 To add something to your system path in Windows:

  1. Go to the Control Panel, and select the System Properties (Windows XP) or System(Windows Vista/7).
  2. Select the Advanced settings. (On Windows XP: Click on the Advanced tab. On Windows Vista/7: Click on Advanced system settings on the left.)
  3. Click on Environment Variables.
  4. Under the “System variable” section, you will look for “Path”. Double-click on it.
  5. In the “Variable values” section, add at the very end the location of the tools & package-tools folder, with a semicolon separating these two paths from the rest. (e.g. %SystemRoot%;(path to SDK here)/platform-tools;(path to SDK here)\tools) – for example: C:\android-sdk-windows\platform-tools;C:\android-sdk-windows\tools

If you’re uncomfortable with all the previous steps, there is also a pretty nifty environment editor called Rapid Environment Editor. Very handy if you have a lengthy system path, you can manage it like a list of directories instead of just one long unmaintainable line.

To add something to your system path in Linux, run the following commands (of course replace /opt/android-sdk-linux/ with the folder where you installed the Android SDK:

export PATH=${PATH}:/opt/android-sdk-linux/tools
PATH=${PATH}:/opt/android-sdk-linux/tools

Now you’ve got the tools, you’d think the work is over – think again! Your system needs drivers to be able to communicate with the Android Device!

For Windows, it’s easiest if you download the Universal Naked Driver. This is a zip file containing only the strictly necessary files: no frills, and no trouble with driver conflicts when you’ve got multiple Android devices. There are two types of devices Windows should recognize: Samsung Android ADB interface (our phone when it’s in ADB mode) and Samsung Android Fastboot Interface (our phone when it’s in Fastboot mode)

In order to install them correctly, follow these steps:

  • Unzip the file to a location you remember easily.
  • Turn your phone in, wait until it’s fully booted, and plug it in.
  • When you plug your phone in, Windows will start looking for drivers. Cancel this and go for the “look for device drivers on this computer” option. Point to the location you used in the first step.
  • If all goes well, you will see your device in device manager as Samsung Android Phone -> Samsung Android ADB interface.
  • If this failed, go to device manager, remove the drivers for the device, unplug it, and start over at step 1.
To install the Fastboot Drivers, we will follow the same procedure, but this time, we’re going to put the phone in Fastboot mode.
  • Turn the phone off
  • Turn it back on holding the power off and both volume buttons.
  • An android lying down with info text in the left bottom corner should appear. You can navigate this bootloader by using the volume keys for up/down, and power button to accept. For now, however, no interaction is needed.
  • Plug the phone into the computer.
  • Windows will start looking for drivers. Cancel this and go for the “look for device drivers on this computer” option. Point to the location you used in the first step.
  • If all goes well, you will see your device in device manager as Samsung Android Phone -> Samsung Android Fastboot Interface (or something similar)
  • If this failed, go to device manager, remove the drivers for the device, unplug it, and start over at step 1.
  • To exit Fastboot mode on your phone, navigate with the volume keys until the big arrow points at “start” and accept with power button : the phone will boot normally.
On Linux (Ubuntu / Mint), you don’t need to install additional drivers, but you might need to add udev rules to specify the new device you’ll be using. Before doing this, skip to the next step, in which you will learn how to test ADB.
  • Boot the phone and connect it to the system using the USB cable.
  • Using lsusb in a terminal, find out the ID of your device. It’s a alphanumeric combination in the form of XXXX:XXXX
    As a root user (use sudo/gksudo), edit the file /etc/udev/rules.d/99-android.rules, and add the following:
    SUBSYSTEM=="usb", ATTRS{idVendor}=="XXXX:XXXX", SYMLINK+="android_adb", MODE="0666" GROUP="plugdev"
    TEST=="/var/run/ConsoleKit/database", \
    RUN+="udev-acl --action=$env{action} --device=$env{DEVNAME}"

    Replacing the XXXX:XXXX with your ID, of course.

  • Save the file and restart the udev service using 
    sudo service udev restart
To check whether or not the driver installation worked, the steps are the same on Windows and Linux: both adb and fastboot have a command devices, which simply lists the connected devices on your system. If your output looks like this, the driver installation worked!
jeroen@Coruscant ~
$ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
XXXXALPHANUMERICHEREXXX        device

2. Unlocking

From here on, we’ll only be working with the adb and fastboot commands, so all the following should work the same on Windows and Linux, given that your drivers are installed correctly.

  • Connect your phone.
  • Put your phone in fastboot mode. You can do this easily using the volume up+powerbutton method explained previously, or now that you have the power of adb, by connecting your powered on phone and sending the command
    adb reboot bootloader
  • Your phone should now enter fastboot mode. On screen, this is an android robot lying down with it’s belly open, to suggest we’re doing surgery! To check, use the command
    fastboot devices

    If your phone is not listed here, either you’re not booted into fastboot mode, or something is wrong with the fastboot driver installation – see section 1.

  • To unlock your phone, simply issue the command
    fastboot oem unlock
  • Have a look at your phone’s screen: a warning will be displayed. Press the power button to accept.
  • Your phone is now unlocked, and it should say so at the bottom of the screen in red. When you boot your phone again, you will also notice an unlocked padlock under the Google logo.
  • That was pretty easy, no? It’s an officially supported unlock. You’re not using any exploit to ‘trick’ your phone into unlocking. This easy process is one of the main reasons people buy Nexus devices.

3. Rooting / Custom Recovery

In order to root your device, you need to simple install a “su” binary, which is a standard Linux tool to gain superuser rights. Remember: android is basicly linux, so as long as some brainiac compiled the binary for your device (spoiler alert: someone has), you can gain root easily.

Getting the binary on there is done by flashing a zip file through a custom recovery image. A recovery image is basicly a small OS that you can (temporarily) load from your bootloader, which allows you to do a lot: backup your current ROM, flash new applications, system modifications, … The de facto standard is ClockWorkMod Recovery. The latest images for the Galaxy Nexus can be found on this page. Please make sure you pick the right version: GSM or CDMA. Picking a wrong image will probably not harm your phone, but the image simply won’t boot. Also, they’ve got a nice ClockWorkMod Recovery Touch version now, which is a lot easier to use than fiddling around with the volume buttons. I’d recommend that.

Anyhow, you’ve got two options:

  1. Permanently install this recovery image, replacing Google’s standard recovery, which is very limited compared to ClockWorkMod, but is necessary to receive official updates, if you decide to keep running the standard distribution.
  2. Booting into it without installing it, effectively just using it once.

The command to permanently install the recovery is – executed from the directory where you downloaded the image to, of course (also, replace the file name with the name of the recovery you downloaded):

fastboot flash recovery recovery-clockwork-versiongoeshere.img

In order to just boot into the recovery once, use

fastboot boot recovery-clockwork-5.5.0.2-maguro.img

Your phone will boot into the recovery, no interaction needed.

When the flash is complete, use the volume buttons to navigate to “recovery”, and use the power button to select. Or use your fingers if you downloaded the Touch version.

Now, we need to flash a zip file that establishes root. A popular app which contains a su binary is SuperSU. You can download the zip file here: http://download.chainfire.eu/345/SuperSU  The zip file contains the following:

  • The linux “su” binary, to be able to gain root access.
  • An .apk file containing an Android application (SuperSU) to control root access.
  • A little script to install this.

By flashing this zip in Clockworkmod recovery, we run that little script and thus modify our main operating system, rooting it!

There are two ways of getting the zip file on your phone:

  • Booting into the main operating system and just transfer it the normal way, like you would with music and photo’s (windows explorer, …)
  • Push it using adb: when you’re in clockworkmod recovery, the ADB bridge still works – it’s pretty easy to transfer files this way. To push the file you downloaded to the virtual sdcard, use the following command
    adb push filename.zip /data/media

data/media is the virtual sd card folder of the Galaxy Nexus

When the file is in place, navigate in Clockworkmod to install zip from sdcard -> choose zip from sdcard. Navigate to the zip file and select it. Confirm that you want to install this. You should see the following output on the phone screen (or similar):

"***************************"
SuperSU installer ZIP
***************************
- Mounting /system and rootfs
- Removing old files
- Creating space
- Extracting files
- Restoring files
- Setting permissions
- Unmounting /system
- Done !

Done – navigate back to the main menu and hit reboot – your phone is now rooted! I recommend installing the excellent Rom Manager as well, which allows you to manage your recovery and do a lot of useful things (backup, …) from within the Android OS itself.

4. Flashing custom ROMs, radio firmware, kernels, …

This guide will not go into detail on how to do this, but it all usually boils down to:

  • Booting in ClockWorkMod recovery (whether permanent or just booting it once, see previous section). The easy ADB command for this is
    adb reboot recovery
  • (optional, but you’re being reckless if you don’t) Backing up current data
  • Select a zip file to flash
  • Reboot!
Thousands of ROM’s (Loving Cyanogenmod), tweaks can be found in the XDA Galaxy Nexus developer forums. For GSM users, a good thread with all released radio firmwares can be found here.

5. A note on the Galaxy Nexus transfer method

For Ice Cream Sandwich, Google switched from standard USB Mass Storage mode to MTP (Media Transfer Protocol) for file transfer from your computer to your PC. This was done for the reason of having one volume to store everything on, that can be mounted by multiple users (so no more inaccessible sd card from your phone when you’re transferring files from your computer, no more ‘moving to sd card’ fiddling …)

The downside however, is that MTP is slow, often unreliable (compared to USB mass storage) and unsupported on some operating systems. It also doesn’t act like normal file system: you can’t search within a file without having MTP totally download it behind the scenes to a temporary directory. This is because MTP is responsible for implementing filesystem access itself – so the base filesystem is EXT3, with a layer of crap over it to make it compatible.

If you’re using Windows, your Galaxy Nexus will mount as a “media device”, which uses its own transfer dialogs and generally works slow but okay. For Mac, Google released a tool.

On Linux, there’s standard support for MTP through Ubuntu’s gphoto2:// implementation, which works in the Nautilus file browser. I found this method flimsy and often giving me errors when copying/cutting files. Using MTPFs, a Fuse filesystem that allows mounting of MTP devices to a directoy, it works a bit better, but only when used from the command line. Check out the wikipedia page for more Linux implementations. jMTPFs looks promising too.

I personally prefer just pushing files over ADB when I’m on Linux, which is even slower but more reliable. It’s so silly: this is an USB 2.0 connection, and I’m getting transfer speeds of 1 or 2 MB/s at best.

Another option is just transferring the files over wireless using QuickSSHd or Airdroid.

6. Closing remarks

Have fun with your Nexus!

http://download.chainfire.eu/345/SuperSU

Comments are closed.