This probably the 40th millionth time, since owning this phone, that I've needed to root my device. Because I keep doing it over and over, while also referring to past commands and notes, it's high time I blogged the steps. If I can benefit myself from my own blog post, then chances are someone else can. So, with that said, here's what we're going to do:
- Grab the latest Nexus factory images from Google.
- Update the phone by flashing all the images (without wiping user data).
- Flash the recovery with the latest TWRP image.
- Get root on the device with Chainfire's "system-less root" SuperSU package.
- Enable USB tethering and the wireless hotspot functionality.
Before beginning, I should mention that if the title isn't immediately clear, this post is specific to the Motorola Nexus 6, which is the phone I currently own. It's probably generic enough, however, to be applied to a few Nexus devices. Minus getting the factory Nexus images from Google, this might even be generic enough for non-Nexus devices, but you're on your own there. Proceed at your own risk. With that said, it's fairly hard to brick an Android phone these days.
Also, you need to make sure you have an unlocked bootloader. Google ships with the bootloader locked by default. Unlocking it, will wipe your user partition, meaning you will lose any and all user data (images, videos, text messages, application data, etc.). I'm going to assume that you've already unlocked the bootloader, and are ready to proceed.
TL;DR
If you don't want to read the post, and know what you're doing, here's the short of it:
$ tar -xf shamu-mmb29k-factory-9a76896b.tgz $ cd shamu-mmb29k $ adb reboot bootloader $ fastboot flash bootloader bootloader-shamu-moto-apq8084-71.15.img $ fastboot reboot-bootloader $ fastboot flash radio radio-shamu-d4.01-9625-05.32+fsg-9625-02.109.img $ fastboot reboot-bootloader $ fastboot update image-shamu-mmb29k.zip $ fastboot flash recovery twrp-2.8.7.1-shamu.img $ fastboot reboot recovery (reboot normally) $ adb push UPDATE-SuperSU-v2.46.zip /sdcard/supersu.zip $ adb reboot recovery (install /sdcard/supersu.zip from TWRP) (do not install TWRP root) (reboot normally) (install build.prop editor from Google Play) (set "net.tethering.noprovisioning" to "true")
Otherwise ...
Getting the Google Nexus factory images
Navigate to https://developers.google.com/android/nexus/images#shamu and grab the version you are looking for. For example, I recently wanted to flash 6.0.1, so I grabbed the "MMB29K" image. Before flashing, I find it critical to verify the checksums. They are "27dde1258ccbcbdd3451d7751ab0259d" for MD5 and "9a76896bed0a0145dc71ff14c55f0a590b83525d" for SHA-1. So, after downloading, I pulled up a terminal, and verified them:
$ md5sum shamu-mmb29k-factory-9a76896b.tgz 27dde1258ccbcbdd3451d7751ab0259d shamu-mmb29k-factory-9a76896b.tgz $ sha1sum shamu-mmb29k-factory-9a76896b.tgz 9a76896bed0a0145dc71ff14c55f0a590b83525d shamu-mmb29k-factory-9a76896b.tgz
After examination, it's clear these checksums match, so I'm ready to flash.
Flashing the images
This step does not require root on your device. I'll need to connect my phone to my computer via USB, and verify that I can talk to it via adb(1). This means installing the Debian "android-tools-adb" and "android-tools-fastboot" packages if they're not already. After installed, I should be able to verify that I can talk to the phone:
$ sudo apt-get install android-tools-adb android-tools-fastboot (...snip...) $ adb devices List of devices attached [serial number] device
If your device is visible, we are ready to rock-n-roll. First, extract the tarball, and enter the directory:
$ tar -xf shamu-mmb29k-factory-9a76896b.tgz $ cd shamu-mmb29k $ ls -lh total 2.3G -rw-r--r-- 1 atoponce atoponce 124 Jan 1 2009 android-info.txt -rw-r--r-- 1 atoponce atoponce 8.1M Jan 1 2009 boot.img -rw-r----- 1 atoponce atoponce 11M Nov 18 16:59 bootloader-shamu-moto-apq8084-71.15.img -rw-r--r-- 1 atoponce atoponce 6.2M Jan 1 2009 cache.img -rw-r----- 1 atoponce atoponce 985 Nov 18 16:59 flash-all.bat -rwxr-x--x 1 atoponce atoponce 856 Nov 18 16:59 flash-all.sh* -rwxr-x--x 1 atoponce atoponce 814 Nov 18 16:59 flash-base.sh* -rw-r----- 1 atoponce atoponce 964M Nov 18 16:59 image-shamu-mmb29k.zip -rw-r----- 1 atoponce atoponce 113M Nov 18 16:59 radio-shamu-d4.01-9625-05.32+fsg-9625-02.109.img -rw-r--r-- 1 atoponce atoponce 8.8M Jan 1 2009 recovery.img -rw-r--r-- 1 atoponce atoponce 2.0G Jan 1 2009 system.img -rw-r--r-- 1 atoponce atoponce 136M Jan 1 2009 userdata.img
Notice a couple of things- first, there are shell scripts "flash-all.sh" and "flash-base.sh" for Unix-like systems. Also, notice the "bootloader-shamu-moto-apq8084-71.15.img" & "radio-shamu-d4.01-9625-05.32+fsg-9625-02.109.img" raw images, as well as the "image-shamu-mmb29k.zip". These are the only files we're going to concern ourselves with when flashing the phone.
However, we want to be careful that we don't flash "userdata.img". This will format your user partition and all user data will be wiped (see above). What we're going to do, is basically the same execution as the "flash-all.sh" shell script. However, we're going to make just one small modification. Further, we need our phone already booted into the bootloader. As such, here's what we're going to do:
$ adb reboot bootloader $ fastboot flash bootloader bootloader-shamu-moto-apq8084-71.15.img $ fastboot reboot-bootloader $ fastboot flash radio radio-shamu-d4.01-9625-05.32+fsg-9625-02.109.img $ fastboot reboot-bootloader $ fastboot update image-shamu-mmb29k.zip
Notice that I removed -w from that last command (if you looked in the "flash-all.sh" shell script). That option wipes user data, which would be necessary if we wanted to return the phone back to factory state. We don't- we're just upgrading. Also, I don't see the need for "sleep 5". Just wait for the phone to successfully reboot before running the next command.
At this point, the phone is successfully updated. If you were to reboot the phone, it would be perfectly operational as if you did an OTA update, or purchased it from the store. However, we want root, so we have a few more steps to accomplish.
Getting and flashing TWRP
This step also does not require root on your phone. I prefer TWRP for my recovery on Android. It's touch-based, which sets the UI apart from the other recoveries, and it's Free Software, unlike ClockworkMod. Both of these are big wins for me. Grab the latest image at https://twrp.me/devices/motorolanexus6.html. I downloaded twrp-2.8.1.7-shamu.img. Unfortunately, I couldn't find any checksums to check to verify the download. So, I installed it anyway, knowing I could flash the stock "recovery.img" if something goes wrong. So far, things have been great, so I calculated the checksums for you:
$ md5sum twrp-2.8.7.1-shamu.img f040c3a26f71dfce2f04339f62e162b8 twrp-2.8.7.1-shamu.img $ sha1sum twrp-2.8.7.1-shamu.img 40017e584879fad2be4043c397067fe4d2d76c88 twrp-2.8.7.1-shamu.img $ sha256sum twrp-2.8.7.1-shamu.img ebe5af833e8b626e478b11feb99a566445d5686671dcbade17fe39c5ce8517c7 twrp-2.8.7.1-shamu.img
If those checkout, you should be safe in flashing. Currently, the phone should already be booted into the bootloader. If not, make sure it is. Once in the bootloader, we can flash TWRP then reboot normally:
$ fastboot flash recovery twrp-2.8.7.1-shamu.img
Now, it's critical that we don't normally reboot the phone. If we do, recovery will be overwritten, and we'll have to reflash. So, while your phone is still booted into the bootloader, reboot it into recovery. You can do this by pressing the volume up/down arrows, until rebooting into recovery is available, and pressing the power button. This should boot you into TWRP. Now that you're there, you can reboot the phone normally.
WARNING
It is possible that while booting, your phone will notify you that the system cannot be verified. One of two things will happen: either the boot will pause, and not go further, or will boot without despite the warning. If you flashed these exact versions, my phone boots without the warning at all. However, don't panic if you see it. Remember, you have the factory images. Just reflash the recovery.img, and you will be just fine.
More info can be found at http://www.xda-developers.com/a-look-at-marshmallow-root-verity-complications/.
Getting and flashing SuperSU (getting root)
WARNING
At this point, the phone should be booted into its regular state. We are now ready to root the phone. This means getting the latest SuperSU package, and installing it through TWRP. However, I need to throw out another caution. We'll be installing a beta version of SuperSU to do something called "system-less root". This means that the package will only be modifying the bootloader image to get root, and will not be touching the system partition. This is both good, and bad. It's good in that we only need to reflash the bootloader to remove root. It's bad in that this is experimental software, and really not ready for production. Further, unlike TWRP, SuperSU is proprietary software, which sucks. It does make me a bit nervous, to be honest, to rely on non-free closed-source proprietary software, on such a critical piece of my life. Proceed at your own risk.
As of this writing, you'll need to get the SuperSU package from the XDA forums at http://forum.xda-developers.com/showpost.php?p=64161125&postcount;=3. I grabbed version "BETA-SuperSU-v2.64-20151220185127.zip". There may be updates since this post was published.
Unfortunately, again, I did not see any published checksums. So, I've installed it, with the knowledge of how to reflash my bootloader should I encounter problems.
$ md5sum UPDATE-SuperSU-v2.46.zip 332de336aee7337954202475eeaea453 UPDATE-SuperSU-v2.46.zip $ sha1sum UPDATE-SuperSU-v2.46.zip 6135f9d0af28e02f4292c324bf5983998e7ae006 UPDATE-SuperSU-v2.46.zip $ sha256sum UPDATE-SuperSU-v2.46.zip d44cdd09e99561132b2a4cd19d707f7126722a9c051dc23f065a948c7248dc4e UPDATE-SuperSU-v2.46.zip
Provided these checksums match, we're good to go. We need to push the ZIP to our phone with the Android debugger, and reboot into the TWRP recovery:
$ adb push UPDATE-SuperSU-v2.46.zip /sdcard/supersu.zip $ adb reboot recovery
From the TWRP interface, tap "Install" and install the /sdcard/supersu.zip package. When it finishes, tap "Reboot". TWRP will ask if you would like to install the root provided by the image. You do NOT want to install this root- you just flashed one.
The phone should boot normally.
Enable USB tethering and the wireless hotspot
This step requires root. Finally, we want to enable the hotspot and tethering. Google is bending to wireless carriers, forcing the user to prove that they are subscribing to a cellular service that allows them to use USB tethering or the wireless hotspot. Personally, I find this dirty, and unfortunate. Even worse, is the fact that cellular providers think they can get away by charging double for using your own data. Data is data; it shouldn't matter if it comes from your phone, or your laptop connected to your phone. If they want to charge for overages on caps, whatever. But charging double, just because you connected your phone via USB? Or setting up a hotspot in your grandma's house, because she doesn't have WiFi but you have cellular coverage? Please. This is clearly grandfathered from the days of feature phones, where you couldn't tether or hotspot. So, you purchased a USB dongle to enable the hotspot. Even then, it was dirty, but it's clear that this is a byproduct of days gone by.
To enable tethering and the hotspot, you just need to add one line to /system/build.prop config file. Unfortunately, /system/ is mounted read-only. So, you'll have to remount it as read-write and edit the file. However, every attempt I have made at modifying it has ended up with an empty file- IE: losing all its contents. So, rather than editing it manually, there is an app for that.
Install https://play.google.com/store/apps/details?id=com.jrummy.apps.build.prop.editor&hl=en. Add "net.tethering.noprovisioning" and set the property to "true", then reboot your phone. At that point, you should be able to USB tether and setup a wireless hotspot.
Conclusion
This wasn't for the faint of heart or for someone who doesn't care about gaining the necessary control over their Android phone that root would give them (setting up firewalls, ad blockers, tethering/hotspot, etc.). However, as mentioned earlier, it's getting fairly difficult to hard brick and Android phone these days. Even better, the steps are getting somewhat standardized. IE: flash factory images, flash custom recovery, install SuperSU, & optionally enable tethering/hotspot.
{ 4 } Comments