Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

[GUIDE] Rooting the Nexus 4 Manually

Options
  • 05-09-2013 1:11am
    #1
    Registered Users Posts: 3,212 ✭✭✭


    Rooting the Nexus 4 Manually

    Rooting the Nexus 4 is very straightforward without using a toolkit, and you'll learn a thing or two by doing it yourself. It's much more fulfilling. Also, the toolkits will only work on Windows. I'm not aware, though I've never looked, of such toolkits on Mac OS X or Linux. Whatever method you use, you'll have to unlock the Bootloader, which will wipe everything as a security measure, including the SD card. See the bottom of this post for SD card backup instructions.

    I used a toolkit when I first got the Nexus 4 in April but have since then done it myself. It's so quick and it's the easiest phone I've ever rooted. So you can either go with a toolkit or continue reading for detailed instructions on doing it manually...

    The bulk of time it will take to perform these instructions will be taken up by small little inconveniences of rooting for the first time. It's a quick process nonetheless, much quicker than it looks, and quicker after the Bootloader is unlocked because you won't likely lock it again (I haven't, not once) and once the USB drivers are installed on your PC (unnecessary for Mac OS X or Linux). If you've rooted before using a toolkit or have just forgotten how to with the manual process, you may be able to skip the first, second, and/or sixth steps. If you don't know what these steps are, then it's advisable that you don't skip them.

    Any questions? Reply and ask.


    Rooting Instructions
    1. Download the USB drivers from Google for Windows, extract, and right-click android_winusb.inf for the context menu and click on Install. If you're using Windows 8, you'll have to disable Driving Signing (temporarily) before installing.

    2. Download and install the Fastboot/ADB zip from the attachment at the bottom of this post and extract it to a folder of your choice on your PC. If you're not using a PC, then you can go here for an easy method of obtaining it for Mac OS X or Linux.

    3. On the Nexus 4, enable "USB debugging" in Settings > Developer options. [Note 1]

    4. Turn off the Nexus 4 and boot into the Bootloader (hold Vol- and then press Power).

    5. Open up a Command Prompt/Terminal and go to the folder where you put Fastboot.

    6. Unlock the Bootloader using Fastboot. [Note 2]

    7. Boot into Android as normal.

    8. Download the latest TWRP custom recovery image, which you will need to put into your Fastboot folder.

    9. Download the latest flashable SuperSU (this link always goes to the latest version) and copy it onto the root of your Nexus 4's SD card.

    10. Power your Nexus 4 off and boot into the Bootloader again using the same key combo as above. From there boot into TWRP recovery. [Note 3]

    11. Flash the SuperSU zip by going into Install and selecting the SuperSU zip file that you have on your SD card.

    12. Install the BusyBox installer app from the Play Store and use it to install the BusyBox binaries (Smart Install).

    Your Nexus 4 is now rooted! Now whenever a specific app needs root access for the first time, SuperSU will pop up and ask you to either Grant or Deny access for then and whether you want what you've chosen to persist, so you won't be prompted for the same app again, unless the app updates (a feature called "Re-authentication," which can be disabled in SuperSU's settings).

    Warning:
    If you plan on flashing mods, be sure to take notes of what you're flashing and if said mods replace any existing files, to take a backup of the originals or know where to find the stock versions online for your Android version before going ahead. This will make the process of unrooting and reverting to stock possible without having to re-flash the firmware and wipe your phone in the process, for whatever reasons you may have for wanting to do so, like for an OTA update, for example. When you perform an OTA update, the update package hash-checks the system files and if even one of the files it checks is off, the OTA update will fail. This is done to ensure that the OTA update is compatible with the existing firmware, so you can understand why such checks are necessary. If you have no way of putting the stock file(s) back, then you'll have no other choice but to re-flash the stock firmware, which entails a full wipe (though the SD card isn't affected). I will be writing an unrooting guide and will make another mention of this alongside the other steps you'd need to take.

    For example, my last OTA failed at first because I had a circle battery mod flashed. This meant my SystemUI.apk in the /system/app/ folder was different and thus failed the hash check, which was made somewhat clear by the error message I got when the update failed, for I had completely forgotten about it. By putting the original one back that was specific to my firmware, it was no longer a problem. I had cleaned up everything else prior to attempting the OTA update so the circle battery mod was the final piece of the puzzle. Thankfully I didn't have any other mods installed, but if I had, so long as I kept a note and backups of every single one of the original files the mods may have replaced, it would have also been fine.


    Notes

    1. To enable visibility of the "Developer options" you'll have to to into Settings > About phone and tap the "Build number" seven times. It'll be visible as a menu above "About phone" thereafter.


    2. If you've rooted your Nexus 4 before, check that the Bootloader isn't already unlocked. At the Bootloader, look for "LOCK STATE" at the bottom and if it says "unlocked" then you can skip this step. Otherwise or for first-timers, please continue...

      Remember:
      Unlocking your Bootloader will wipe your entire Nexus 4, including the SD card. See the bottom of this post for SD card backup instructions.


      To unlock the Bootloader, type in the following command:
      fastboot oem unlock
      

      When you're prompted with a warning, use the volume keys to bring up "Yes" and then hit the power button to select it.


    3. You can at this point either flash the custom recovery or you can merely boot into it as a once-off without overwriting the stock recovery. The stock recovery is useless, it's only good for the unattended/automated installation of official OTA updates. If you think you'll need to flash custom zips often (such as mods, etc.), you should do the former. If you don't think you'll need any of that, then go with the latter. If you decide to flash the custom recovery, you can always flash back to stock at any time from the factory images that Google provides, so nothing is permanent unless you want it to be.

      Flashing:
      Use the following command while in the Bootloader:
      fastboot flash recovery filename_of_recovery.img
      

      Then use the volume keys to bring up "Recovery mode" and hit power to select it. From here on in, this is how you'll get into the custom recovery for whatever reasons you may have.

      Once-off Boot:
      On 4.3 and possibly above, while in the Bootloader:
      fastboot -c "lge.kcal=0|0|0|x" boot filename_of_recovery.img
      
      ("lge.kcal=0|0|0|x" is specific to the Nexus 4)

      On 4.2:
      fastboot boot filename_of_recovery.img
      

      If you opted for the once-off boot, you'll need to run the appropriate command every time you want to get into a custom recovery, as "Recovery mode" in the Bootloader will only get you into the bare stock recovery in that case.


    Remember to run the "fastboot" commands while the Nexus 4 is booted into the Bootloader and you're at the installed Fastboot folder in the Windows Command Prompt or Mac OS X/Linux Terminal.

    Sounds very convoluted, doesn't it? It really isn't and again, once you've done it for the first time, it should be a lot more streamlined in the future, if your Bootloader remains unlocked and you use the same computer. It would take an intermediate user about a minute or two after the first time as you should be able to tear through the relevant steps.


    Backup Instructions

    To backup your SD card, you can do it one of two ways. You will first need to enable "USB debugging" (see step 3, above). Then hook your phone up to the computer with your USB cable. Your Nexus 4 should ask for authorization to whitelist the computer, if you haven't previously done so. Therefore, be on the lookout for a pop-up.
    • Copy all the files from the SD card into a folder of your choice on your computer. If this gives you trouble, see the next option.

    • Use ADB to pull the files (see step 2, above) to an existing folder on your computer while the Nexus 4 is booted into Android.

    ADB Pull syntax and examples:
    adb pull <remote/phone folder> <local/computer folder>
    
    Example (Windows):
    adb pull /sdcard/ C:\Nexus4SDCard
    
    Example (Mac OS X/Linux):
    adb pull /sdcard/ /folder/on/your/computer/
    

    Note:
    If you're concerned about losing your apps, I'm afraid that your phone needs to be rooted to backup apps and their respective data, so unfortunately, at this point, the best you'll be able to do is to make a note what apps you have installed. There's an app for that! It uses the SD card to save a list and it'll assist you on re-installing all the apps on the list once you're back up and running. But as I said, it won't be able to backup or restore the data associated with your apps. You can also backup your SMS messages using this app, which also uses the SD card. So if you're using the suggested apps, wait until after you're finished before backing up your SD card.

    WhatsApp, if you're using it, saves all messages to the SD card every morning at 4am. You can also save them on-demand by going into the app and heading to Settings > Chat settings > Backup conversations.


Comments

  • Moderators, Category Moderators, Technology & Internet Moderators Posts: 6,265 CMod ✭✭✭✭MiCr0


    very helpful guide.
    Can you highlight the part about the full wipe, so that people don't loose everything by mistake?
    Also, could you suggest a backup method?

    I'll sticky this shortly.
    //MiCr0


  • Registered Users Posts: 3,212 ✭✭✭DECEiFER


    MiCr0 wrote: »
    very helpful guide.
    Can you highlight the part about the full wipe, so that people don't loose everything by mistake?
    Also, could you suggest a backup method?

    I'll sticky this shortly.
    //MiCr0
    Sure thing. Any suggestions/corrections are appreciated.

    Backup methods are limited when you're not rooted so I'll mention backing up the SD card using a computer (the standard way) or using "adb pull."


  • Registered Users Posts: 6,186 ✭✭✭emo72


    hiya, im not sure about rooting, i just got a nexus 4 and havent opened it yet. the obvious question is what benefits does rooting give you? im probably gonna leave it stock, but there may be a reason to have it rooted anyway. i have rooted previous phones but that was to get away from sense and touchwiz.

    since this is running vanilla android is there less of a reason to root it?

    and thanks for the great guide!


  • Registered Users Posts: 18,904 ✭✭✭✭Mimikyu


    This post has been deleted.


  • Registered Users Posts: 896 ✭✭✭geecee


    Thanks for the post... you metion the SD card a quite a bit in the above instructions...
    But I thought that the Nexus doesn't have an SD card?


  • Advertisement
  • Registered Users Posts: 51,054 ✭✭✭✭Professey Chin


    geecee wrote: »
    Thanks for the post... you metion the SD card a quite a bit in the above instructions...
    But I thought that the Nexus doesn't have an SD card?

    Internal storage is in the sdcard directory on the phone


  • Registered Users Posts: 19,018 ✭✭✭✭murphaph


    Thanks for this guide, gonna give it a try tomorrow. I intend flashing my N4 with the CM10.1 rom. Do I just work through your guide and then proceed from there?


  • Registered Users Posts: 18,904 ✭✭✭✭Mimikyu


    This post has been deleted.


  • Registered Users Posts: 2,343 ✭✭✭Kavrocks


    DECEiFER any particular reasons why you chose TWRP and SuperSu?

    Might also be helpful to add the
    fastboot devices
    
    command and some troubleshooting info if it doesn't show your device connected.

    Also I think you should add something about accepting the laptops signature when you first connect your Nexus 4, might scare a few people who don't know what they are looking at.


  • Registered Users Posts: 3,212 ✭✭✭DECEiFER


    geecee wrote: »
    Thanks for the post... you metion the SD card a quite a bit in the above instructions...
    But I thought that the Nexus doesn't have an SD card?
    I meant the internal one, as Chinpool mentioned. My apologies for the ambiguity.
    murphaph wrote: »
    Thanks for this guide, gonna give it a try tomorrow. I intend flashing my N4 with the CM10.1 rom. Do I just work through your guide and then proceed from there?
    Absolutely, you use the custom recovery to flash it. You can skip the steps of downloading/flashing SuperSU and installing BusyBox since you'll be using a different ROM.
    Kavrocks wrote: »
    DECEiFER any particular reasons why you chose TWRP and SuperSu?

    Might also be helpful to add the
    fastboot devices
    
    command and some troubleshooting info if it doesn't show your device connected.

    Also I think you should add something about accepting the laptops signature when you first connect your Nexus 4, might scare a few people who don't know what they are looking at.
    TWRP is like ClockworkMod, it has the same features, but it's a touch-based recovery. So is CWM, but CWM still uses old-fashioned menus and for the stubby-fingered, it's still too easy to touch off the wrong option. While it's not a big problem because of the fact that it does ask to confirm just about everything, TWRP doesn't have that issue as its layout is that of buttons. But anyone, feel free to use CWM if you prefer it, however.

    SuperSU is the app that most of the toolkits use and it seems to be what most guides direct people to use, also. I've tried Superuser also. There's nothing in it. They're both great but SuperSU comes with options to cleanup for unrooting or for installing another superuser app. To me, it just about has the edge. So that's what I chose it.

    I'll add stuff about "fastboot devices" and "adb devices" a bit later today or tomorrow, thanks for the suggestion.

    And lastly, I did mention the key, but not exactly in the main part of the post.
    To backup your SD card, you can do it one of two ways. You will first need to enable "USB debugging" (see step 3, above). Then hook your phone up to the computer with your USB cable. Your Nexus 4 should ask for authorization to whitelist the computer, if you haven't previously done so. Therefore, be on the lookout for a pop-up.

    I just figured if I put it in the backup section, it would the the pre-step that people take before going ahead with the guide itself. But not everyone will do it or read my backup instructions if they have a handle on it themselves, so I realize the problem now. I'll re-word it and I'll make sure the information is in a better place. Again thank you for the suggestion.

    Just so you're aware, I'm currently locked out from editing the post. It's gone too long since the date of posting so my access is expired. Any changes will have to be done through a moderator, I'd PM the edited post. I've been down this road before and it can take a few days before they check their PMs.


  • Advertisement
  • Registered Users Posts: 242 ✭✭HellboundIRL


    If I root and install an adblocker but nothing else, would this allow me to use OTA updates in future without wiping? or does the adblocker have some sort of an impact on the system files?

    Wasn't going to root this one but the ads are driving me crazy, at the same time though I don't want to wipe every time a new update comes out.


  • Registered Users Posts: 1,371 ✭✭✭jgbyr


    If I root and install an adblocker but nothing else, would this allow me to use OTA updates in future without wiping? or does the adblocker have some sort of an impact on the system files?

    Wasn't going to root this one but the ads are driving me crazy, at the same time though I don't want to wipe every time a new update comes out.
    Yep you can still receive ota updates as long as you don't change any system files. You'll have to unroot first of all but there's an option for that in supersu.


  • Registered Users Posts: 19,018 ✭✭✭✭murphaph


    So, I followed the HOWTO and went on to install CM10.1 on my N4. All went well but I hit a couple of stumbling blocks where I needed Google to help so I'll include them here in case any one else does too:

    I used Linux Mint (so should be similar for Ubuntu or other Debian based distro users) 64 Bit system.

    Problem:
    Problem starting adb. Error message:
    error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
    

    Resolution:
    Install missing libraries with
    sudo apt-get install ia32-libs
    

    Problem:
    fastboot oem unlock
    
    returns
    <waiting for device >
    
    and it just sits there.

    Resolution:
    Use
    sudo fastboot oem unlock
    

    Problem:
    Wasn’t clear how to copy supersudo to root of nexus SD card. Googling suggested using
    adb push
    
    but didn't work and
    adb devices
    
    returned nothing

    Resolution:
    Had to re-enable usb debugging as I had performed a factory reset by unlocking the bootloader! Obvious in hindsight.

    Problem flashing custom recovery:
    fastboot flash recovery openrecovery-twrp-2.6.2.0-mako.img
    
    returns
    < waiting for device >
    

    Resolution:
    use
    sudo
    
    as above.

    Thanks again for the HOWTO, helped a lot :)


  • Registered Users Posts: 3,212 ✭✭✭DECEiFER


    Ah yes, I forgot about re-enabling USB debbugging. That's certainly worth a mention.

    Also, I forgot about adding sudo for Linux users. I was supposed to do it as I'd read about it on a guide, but it escaped me. Excellent suggestions and I'll add all the information into an edit.


  • Registered Users Posts: 1,371 ✭✭✭jgbyr


    Deceifer, a quick question you may be able to help me with.
    I installed 4.4 using your guide, thanks. I removed the wipe element so as to keep my data.
    It all went fine & I then flashed the supersu zip file but when I rebooted it didn't take. I tried it a few times but no joy.
    I then tried superuser & this worked.
    I prefer the supersu interface so have you any idea as to why supersu wouldn't load.
    Thanks.


  • Registered Users Posts: 3,212 ✭✭✭DECEiFER


    jgbyr wrote: »
    Deceifer, a quick question you may be able to help me with.
    I installed 4.4 using your guide, thanks. I removed the wipe element so as to keep my data.
    It all went fine & I then flashed the supersu zip file but when I rebooted it didn't take. I tried it a few times but no joy.
    I then tried superuser & this worked.
    I prefer the supersu interface so have you any idea as to why supersu wouldn't load.
    Thanks.
    Hmmmm...

    I did the exact same thing myself and it worked fine. Did you flash the latest one? What exactly happened regarding it wouldn't take?


  • Registered Users Posts: 4,751 ✭✭✭Ste-


    make sure it's not corrupted download. Try to open the zip file and that should tell you.


  • Registered Users Posts: 1,371 ✭✭✭jgbyr


    DECEiFER wrote: »
    Hmmmm...

    I did the exact same thing myself and it worked fine. Did you flash the latest one? What exactly happened regarding it wouldn't take?

    Yea flashed 1.8. I use cwm & it stated everything unzipped fine. When I rebooted there's no supersu app though in the app folder & when I checked any apps that require root, I just get a 'not rooted' notification.

    As I've managed to get root back with superuser, what would happen if I reinstall the supersu app from the app store ?


  • Registered Users Posts: 3,212 ✭✭✭DECEiFER


    jgbyr wrote: »
    Yea flashed 1.8. I use cwm & it stated everything unzipped fine. When I rebooted there's no supersu app though in the app folder & when I checked any apps that require root, I just get a 'not rooted' notification.

    As I've managed to get root back with superuser, what would happen if I reinstall the supersu app from the app store ?
    If you got rid of Superuser you could try downloading SuperSU from the Play Store and see if it finds the binary. If not, flash it again with the app installed.


  • Registered Users Posts: 4,751 ✭✭✭Ste-


    Get the supersu app from the playstore leave yourself rooted with superuser and open the SuperSU app. Then try normal way in the app if that fails try the Twrp/CWM method which will download the SuperSU zip and flash it for you. Should work till you upgrade the rom again.


  • Advertisement
  • Registered Users Posts: 3,212 ✭✭✭DECEiFER


    Also, I flashed with TWRP. I downloaded the zip, put it on the internal SD, booted into TWRP, and flashed it as normal.


  • Registered Users Posts: 1,371 ✭✭✭jgbyr


    I loaded the supersu app from the play store & it asked to remove the other root app. Then supersu just crashed & kept on crashing.
    Will try again tonight & see what happens.
    I just checked Es file Explorer & I have root access but now there is no root app installed.


  • Registered Users Posts: 3,212 ✭✭✭DECEiFER


    If SuperSU is on the data partition, uninstall it. Then flash the system partition again and then flash the SuperSU zip. Try downloading it again beforehand as per Ste-'s suggestion that the zip might be corrupted.


  • Registered Users Posts: 494 ✭✭Sneachta


    Does this guide still work?

    Not sure what the following means

    Open up a Command Prompt/Terminal and go to the folder where you put Fastboot.

    Unlock the Bootloader using Fastboot. [Note 2]


  • Registered Users Posts: 1,414 ✭✭✭Fluffy88


    Sneachta wrote: »
    Does this guide still work?
    The steps outlined in the guide should still be all relevant. The only part of the guide that might be a little out of date is the links which point to certain versions. In most cases you should be able to instead download the latest version of the same software.
    Sneachta wrote: »
    Not sure what the following means

    Open up a Command Prompt/Terminal and go to the folder where you put Fastboot.

    Unlock the Bootloader using Fastboot. [Note 2]

    I assume your using a Windows PC?
    To open a Command Prompt in Windows there is a few options.
    • Open the start menu and type "cmd"
    • Browse to a folder, while holding the Shift key right click and select Open command prompt here

    In both cases to "go to the folder" you use the command "cd" followed by the directory you wish to go into.
    cd "\Users\Me\Desktop\Nexus 4\"
    
    You can use tab completion while typing the directory to help make it faster/easier.

    EDIT: This FAQ from Microsoft might be useful when using the Command Prompt for the first time.
    http://windows.microsoft.com/en-us/windows/command-prompt-faq#1TC=windows-8


Advertisement