The definitive guide on hacking the Nexus 4, part 2: How to unlock, root and install a custom recovery on a Nexus 4

rollingquasar

The definitive guide on hacking the Nexus 4, part 2
This is part 2 of an 8 part series of articles on the Nexus 4. This guide assumes that you have already successfully installed the ADB drivers for the Nexus 4. This guide will describe how to unlock the bootloader, root and install ClockworkMod custom recovery.

Legal disclaimer: We are not responsible for any damage or loss to your device or computer system. Therefore, should you decide to follow these steps, you do so at your own risk and peril and agree to hold us harmless from any damage or loss you may experience. Should you disagree with the foregoing, please do not read any further.

Why do I want to unlock the bootloader of my device?
To avoid any confusion, this has nothing to do with unlocking your phone so that it can work on another carrier (the Nexus 4 is carrier unlocked by default anyways). When we mention unlocking, we mean unlocking the bootloader. This is usually the first step that is required before attempting to do any modification to an Android phone. A bootloader is a piece of software that runs before an operating system. When you turn on your device, the bootloader loads and then it instructs the phone to load the kernel and the Android OS. If the bootloader is locked, it is very difficult (nigh impossible) to install a custom ROM or Kernel. Please note that once you unlock the bootloader, it usually voids your warranty and wipes your device. However, you can always re-lock the bootloader should you need to send it back for repairs. As far as we know, all Android smartphones are shipped with a locked bootloader. The only difference between handsets is how easy the manufacturer allows its users to unlock the bootloader. Google/LG makes it incredibly easy to unlock the bootloader on a Nexus 4. In contrast, Motorola has a reputation for making it very difficult for users to unlock the bootloader on its phone (although they are becoming less stringent). You can read more about Android bootloaders here.

bootloader

Can I unlock the bootloader without wiping the device?
Sort of. If you unlock the bootloader using traditional methods (i.e. Fastboot, the method that we will use), your device will be wiped. However, there is a relatively new app that will do a quasi-unlock of your bootloader without wiping your device (or requiring Fastboot). It’s free, it requires root and it’s called BootUnlocker for Nexus Devices. In general, a device with an unlocked bootloader is less secure than a device with a locked bootloader (in regards to malware or physical forced extraction of the data in your phone). When you unlock your phone using Fastboot, all of the partitions in the phone are exposed. BootUnlocker exploits a bug in the bootloader to keep the bootloader locked, but modifies a certain partition in order to allow users to install a custom recovery–all without wiping your phone. We won’t be using the BootUnlocker app in our example below, but we wanted to mention that it was an option. You can read more about BootUnlocker here, here and here.

What is Fastboot?
Fastboot is a protocol that allows users to flash a new file system in an Android phone over a USB connection. Typically, when someone mentions fastboot, they are referring to a mode that an Android phone is in. If you turn off your Nexus 4, push and hold volume up, volume down and the power button (all at the same time), you will enter “fastboot mode”. For more information, please read this.

How-to-Root-Android-Phone

What is root?
Root is the most powerful user in a linux environment. “Root” is to Linux as “Administrator” is to Windows. The primary difference between root and a regular user is that root has more file permissions. Root can read, write or execute certain files that regular users cannot touch or access. Root is all powerful, therefore some Root users have unfortunately developed god complexes.

superusercomic1

Why do I want to root my device?
Rooting allows you to install powerful software that otherwise wouldn’t be possible. For example, it allows you to flash custom ROMs, you can make better backups of your phone, you can disable most ads in Android apps (by modifying the HOST file), you can tweak the kernel, the voltages and set the processor speeds for your phone. Rooting your device usually voids your warranty, however you can unroot your device at anytime. For more reasons why you may want to root your device, read thisthis and this.

Why do I need a custom recovery, such as ClockworkMod?
Typically, if you intend to install a custom ROM or a kernel, you would do so in the custom recovery. You enter custom recovery mode by entering into fastboot mode and then loading the custom recovery. There are many different custom recoveries (such as TWRP), but ClockworkMod is by far the most popular. That’s what we’ll be using in this tutorial. Android comes with its own recovery method, but you can’t install custom software with it.

cwm

What is busybox?
We will also be installing busy box below. Busy box is a set of basic Linux command line tools. The scripts that we will be using are dependent on these commands to work. Android is based on Linux, but it doesn’t come with many of the common Linux commands, such as chmod (change file permissions), wget (download command), cp (copy), mv (move), ls (list contents of a directory), gzip (uncompress archives), etc.

busybox

Why aren’t you using WugFresh’s Nexus Toolkit that you made us install in part1?
I hear great things about WugFresh’s GUI toolkit, but I’m used to using mskip’s command line toolkit (as it has been around for years), so I’m just going to go with what I’m familiar with. Feel free to use WugFresh’s toolkit if you like.

4

Step-by-step guide on how to unlock, root and install a custom recovery on a Nexus 4
1) Download the latest version of the Nexus 4 Toolkit from here. The current version is v.1.3.0 (direct link). Install the Toolkit at the default location (i.e. C:\Google Nexus 4 ToolKit)

toolkit

2) Download this patch (direct link) and extract it to any folder. Copy all of the extracted files and paste them in this directory “C:\Google Nexus 4 ToolKit\”. We’ll be overwriting 4 files in step 1 with the newer files in the patch. Click “Yes” when Windows asks you if you wish to replace and overwrite the files.

patch

3) Turn off the Nexus 4 and enter Fastboot mode. To enter into Fastboot mode (while the phone is off), push and hold volume up and volume down and the power button (hold all three together) for a few seconds. Once the phone vibrates and you see a little android man, as seen below, you can let go of all 3 buttons. You can tell from the image below that we’re in Fastboot mode and that the bootloader is LOCKED (for now).

photo

4) Now that your phone is in Fastboot mode, you can connect the Nexus 4 to your PC with a mini USB to standard USB cable.

5) Execute Toolkit.exe found in  ”C:\Google Nexus 4 ToolKit\”

exe

6) When it asks you to check for an Update, type “No” (it won’t let you update anyways as that’s a paid feature). When it asks for your device version, type “1″ for Android 4.2 (it’s the only option in any event). You should now see the screen below. Type “8” and it will run a script to automatically unlock the bootloader, root, install busy box and a custom recovery.

2

7) It will now ask you which Superuser method you would like to use. Type “2“ for SuperSU. Afterwards, it will ask you select your choice of Custom Recovery, type “1” for ClockworkMod.

superuser2

8) Read the warning below. The Toolkit will now attempt to Unlock the bootloader. This will wipe your phone (even the internal SD card). If you agree with this, type “yes” and it will be begin.

2x

9) The following screen should now appear on your phone. Navigate toYes” with the volume buttons and select it by pushing the power button. Your phone will now reboot and start Android OS.

photo3

10) While your phone is starting, you will see the following in the toolkit. The Toolkit says that it is waiting for you to enable USB debugging. You can skip through the Android OS setup (e.g. Wifi, Google Account, etc.), it’s not necessary at this point. Just go enable USB debugging. If you don’t remember how to enable USB debugging, please see steps 9 to 12 in part 1 here.

3

11) Once you enable USB debugging, the Toolkit should start running again by itself. It will now attempt to root your device, install busybox and ClockworkMod. Your phone will reboot a few times. You’ll see the following screens.

6

7

8

14) Once the Toolkit is finished installing everything, you should see a SuperSU icon in your app drawer. Congratulations, you should have root now!

Screenshot_2013-02-24-02-22-55

Once you’re ready, move on to part 3 to install a custom ROM.

  • thedonj77

    Is it necessary for me to download the patch files or can i donate to developer and then upgrade to have the latest software?

    • Hippowise

      Hi, you can either download the patch and overwrite the files or you can donate to get the latest software. Both methods will work, so it’s up to you!

      • ravishankar mantha

        hi just a question , i am on factory image 4.2.2 JDQ39, have a sleep wake issue, now can i directly install Fraco kernel via google market by rooting the phone?

  • thedonj77

    Cool. Thanks for the quick response. Once again, your articles are great and very very helpful

  • http://www.facebook.com/josef.izchaki Josef Izchaki

    And again just perfect!

  • John

    What an excellent guide! Thanks for making this idiot-proof for us non-techies.

  • octavio

    I’ve succesfuly rooted my nexus but now muy car stereo cant find The music when connected via USB

  • confusedone

    Im using the toolkit but keep getting 6 failed attempts saying “no root files are present on your system”, what does this mean

    • confusedone

      nevermind, i fixed it

  • jetscreamer

    Does unlocking my bootloader also delete the data on my SIM card?

  • Muhammad Amin

    hye, i followed this part using the nexus root toolkit, and succeeded in part 1, but theres no superSU apps installed in my nexus. only busybox. i tried to download it manually from playstore, but it keeps crashing as soon as i open the app(superSU). i then later check at the apps “undelete” (which is the main reason i want to root my nexus) but it says im still not rooted. pls help me.

  • Olivia Medina

    Thanks for the post. I will certainly return. But a smiling visitant here to share the really like (:, btw great style and style .
    duplicate music remover

  • jamshad

    really nice site and data … i appriciate you for this wordpress blog ,, well done . keep it up