Ok, so you've got your bootloader unlocked, you were messing around with your ROM, you've recently updated to a patch system or who know's what you people do ( ), you derp something up, and now you're unrooted and SOL! Well, I'm gonna give you a rather simple, universal way to restore, re-flash recovery and re-root your phone without having to dig through all the different root methods (or lack thereof) to find the right one.
Ok, this is for intermediate/novice users only who have the basic understanding of ADB, Fastboot, RSD, Fastboot files, etc. If you don't know how to restore your phone to 100% clean stock with FB files on a command line yet, this MAY be too much to swallow. If you're a novice user or better, this may save you some time.
Ok, First Things First, Let's round up our files and get prepped.
Droid Razr HD Recoveries Unzip this file and place the folder on your desktop!
OR Droid Razr M Recoveries Unzip this file and place the folder on your desktop!
SuperSu Root Zip the latest can be found here. DO NOT unzip. Place this Zip on your SD card (pick one, I like external)
I'm assuming you have ADB/Fastboot installed on your computer and they are in your system path. PRO Tip: You need to replace the fastboot binary (from the AOSP SDK) with the Motorola specific ones in your C:\Android\SDK\Platform-Tools (or where ever you have it ) folder as it has the ability to split up larger images (such as system).
Ok, so I'm gonna assume you just used your method of preference for fastboot restoring your device OR you've just booted up on a newer system and lost root. So now you're unrooted, your recovery is now gone, your data is wiped, your system is restored to stock. Granted, you may have CWM or TWRP back-ups on your SD card, so that's good news, we can use them later to restore a safe point.
PRO TIP: If you're EVER LOOKING for Droid Razr M or Droid Razr HD fastboot files...err click those links. The Droid-Developers SBF repository has pretty much any Moto firmware you could EVER need
Ok, so here we are, virgin phone. Let's get it basically through the set up menu so we can turn on our Settings>Security>Unknown Sources and Settings>Developer Options>USB Debugging. Now, plug your phone into your PC. (I am assuming you've got your Motorola Drivers as you would not be at this point.) Open up a Windows CMD prompt. We're gonna do a couple things: First, we will kill any older running ADB daemons, then we'll start a fresh one, then we will ensure your device is being recognized. So
adb kill-server adb start-server adb devices
It should show you the new daemon starting and also report a device ID upon the adb devices command. If there is NO ID displayed after the devices command, your computer is not recognizing your phone. Double check your phone's screen unlocked, the proper settings are set up from the steps above, that the wire is plugged in securely to both your computer and your phone and that you're drivers are installed (they should be if you were able to fastboot restore the device, but who knows?) Ok, so all's well? Let's move on.
Like mentioned above, I'm assuming you've already placed the SuperSu Zip onto your SD Card (if not, do so now)...Now we're going to reboot into the bootloader and get the recovery of your choosing flashed (I had you download them all up top, well pick one...make sure the zip you d/l from me is unzipped on your desktop and you've settled on which one you're gonna flash CWM or TWRP. So here we go...
adb reboot bootloader
Your device will now reboot into the bootloader. Once it does so and settles down, we will confirm that your computer is seeing your device:
fastboot devices
It SHOULD return a device ID #. If it does not, check your wire and your drivers again (this is rare if ADB is recognizing, but not impossible as fastboot has a seperate driver.) If all it well, let's flash the recovery of our choosing. In order to do this easily, we're going to type the first half of the command below then (using your mouse) DRAG the cwmrecovery.img or twrprecovery.img FROM the folder on your desktop TO the CMD window. There MUST be a space BEFORE it. Like this
fastboot flash recovery [now drag and drop your image of choice and hit enter]
It should respond by saying sending, writing and complete. Finally, we're going to reboot your device (just briefly). Now, using the power button. Power your device down. We are now going to boot directly into your freshly flashed recovery. DO NOT BOOT INTO ANDROID. Motorola has files (we'll address this later) that instantly overwrites your custom recovery. So you gotta be on your A-Game here. So hold power to turn device off. Then, hold Power, Vol + and Vol - to get into the bootloader selection menu. Quickly, use Vol - to highlight "Recovery "and Vol + to select it. TWRP or CWM will now boot up.
From here, use your already taught skills to install a zip form your SD card. You're going to choose the SuperSu.zip that you put on your SD much earlier. Browse to it, and flash it. When it's complete, go ahead and REBOOT your device...the recovery MAY or MAY NOT give you certain warnings depending on the recovery of choice (one may say, you're not rooted, shall we fix this? Or another may ask you if you want to overwrite a script, ALWAYS SAY YES, YES, YES!!) We'll fix this later ANYWAY!
Once your device reboots from this first instance of recovery, you will be now rooted again! YAY!
Now, a few last steps! There is a possibility that your fresh new recovery DID NOT remove the weasel files on your phone that over-write your new recovery. (this is not a universal truth, but why mess with it?) You're rooted now, so it's very easy to fix. In all honest, the easiest method is to first download an app such as ES File Explorer or Root Browser. For this purpose, I find root browser to be simpler.
Open up either one of these explorer apps. Approve their Superuser permissions. You're going to now browse to 2 locations. Depending on what process you just did, one, both or neither of these files will be there, but you MUST check! GET RID OF THESE!:
Erase /system/etc/install-recovery.sh
and /system/recovery-from-boot.p
Get rid of em! No need! If you're the paranoid type, you can rename them to install-recovery.sh.bak and recovery-from-boot.p.bak (if it really makes you feel better).
Then (assuming you're phone is still plugged into your computer). We're gonna reboot back into fastboot mode ONE more time to be positive your recovery is safe and sound and hasn't been over-written by the most recent boot-up. So let's reboot to the bootloader.
adb reboot bootloader
Allow your phone to get into Fastboot mode. We'll ensure your device is recognized and then we will run the EXACT SAME PROCESS as above to reflash your recovery of your choice!
fastboot devices fastboot flash recovery [now drag and drop your image of choice once more and hit enter] fastboot continue
DONE!!
No more digging for the proper exploit method (or lack thereof) or anything like that. While this may seem harder at first, you will come to learn (as you become more comfortable with ADB and Fastboot) that this method of rooting is not only much simpler and faster, but also universal to ALL unlocked devices. This is the typical method for the Nexus devices. Now that your bootloader is unlocked, once you flash a custom recovery, these recoveries run with administrator permissions (as they run on their own kernel), so no matter what the case, if you're in custom recovery...all you need is that fancy little zip to regain root access, no more exploits!
Phew!
Thanks to Chianfire for the root.zip, Hashcode for the TWRP and CWM, mattlgroff for the CWM and the moto-fastboot binaries, djrbliss for the bootloader unlock and ME for being such a nice dude