Google has just released the factory images for its newest iteration of Android, the Android M (aka Marshmallow), for a spate of Nexus devices including Nexus 5, Nexus 6, Nexus 9 and Nexus Player.

The Android 6.0 aka Android M build MPA44G is now available for download and manual installation via Google's Developer page. Nexus users who have already installed the latest Android offering from Google may go ahead and root the same, using the step-by-step guide provided below.

Key Points to Remember

  • Rooting Android M is no longer an easy task as Google has introduced some major changes to the kernel. Hence users are required to flash a custom kernel such as Despair Kernel in order to gain root access on Android 6.0 MPA44G stock firmware.
  • Back up important data and settings before you proceed with the rooting
  • Ensure that you have installed the correct USB drivers for your Nexus device
  • Your Nexus device's bootloader must be unlocked and it should be running Android M MPA44G stock firmware

Steps to root Nexus 5 on Android 6.0 aka Android M (MPA44G) Developer Preview 3

Step 1 – Download Android SDK from Android Developers website and install the same. Then set it up with downloading platform-tools and USB drivers package in SDK.

Step 2 – Enable USB Debugging mode on your Nexus 5.

Step 3 – Download Fastboot file for your specific OS from the links below and extract it to android-sdk-windowsplatform-tools directory. Create the directory if it does not exist.

Step 4 – Download custom Kernel (specific for your Nexus device) and SuperSU v2.49 ( your computer, via the following download links:

Nexus 5 Despair custom kernel

Nexus 6 Despair custom kernel

Nexus 9 ElementalX custom kernel

Step 5 – Connect and mount your Nexus device's USB memory on computer via USB cable.

Step 6 – Now copy/paste the downloaded kernel zip and files to the root folder on your phone's SD card.

Step 7 – Power off the phone.

Step 8 – Download custom recovery tool specific for your device and save it to the android-sdk-windowsplatform-tools directory on the computer:

CWM for Nexus 5 (hammerhead)

TWRP for Nexus 6 (shamu)

TWRP for Nexus 9 (flounder)

NOTE: You can use any of the two custom recoveries – CWM or TWRP. If one fails to work, try installing the other one and use that.

Step 9 – Now go into Fastboot/Bootloader Mode on your Nexus device: Press and hold Volume Down and Power keys for a few seconds till you see some text on the screen, which confirms entry into Bootloader Mode.

Step 10 – Navigate to android-sdk-windowsplatform-tools directory and open Command Prompt (hold Shift and Right-click > Open Command Prompt).

Step 11 – Type in the following command and press Enter:

For Nexus 5: fastboot flash recovery recovery-clockwork-touch-

For Nexus 6: fastboot flash recovery openrecovery-twrp-

For Nexus 9: fastboot flash recovery twrp-

Step 12 – After executing the command, choose RECOVERY from the Fastboot menu and enter Recovery Mode.

Step 13 – In CWM recovery, scroll down to "flash zip from SD card" and hit Power button to select it.

Step 14 – Press the Power button again and select "choose zip from sdcard".

Step 15 – Now using your volume keys, navigate to the kernel zip file you downloaded earlierand select it using the Power button. Confirm the installation on the next screen and the installation procedure should start now.

Step 16 – Repeat Step 15 for installing file as well.

Step 17 – After the installation completes, select "+++++Go Back" and reboot the phone by selecting "reboot system now" from the Recovery menu. The phone will reboot and it might take about 5 minutes for the first boot to complete.

That's it. Your Nexus device is now rooted on Android M Developer Preview 3 firmware. Check for the SuperSU app in your apps list to verify if the device has been rooted successfully.

[Source: Team Android – Nexus 5 / Nexus 6 / Nexus 9]