I spent all day testing custom roms on Nexus 7 but finally decided to roll back everything and use stock rom with encryption. I will describe here how to unlock device, install recovery image, return to stock rom and root Nexus 7 (Android 4.2) using Ubuntu.


You don’t need to download full Android SDK to perform tasks described here.

All you need are adb and fastboot commands:

$ sudo apt-get install android-tools-adb android-tools-fastboot

How to turn on USB debugging mode

Android 4.2 makes it fun as you need to open Settings, then About tablet and tap seven times on Build number. Then you will see You are now a developer! message and can access Developer Options. USB debugging needs to be enabled if you want to use fastboot or adb.

How to install recovery mode

Visit Team Win Recovery Project and download recovery image. Alternatively you can use ClockworkMod Recovery. It doesn’t really matter which one choose so in doubt try one or another.

Boot into bootloader by hand or command:

$ adb reboot-bootloader

Flash downloaded recovery image:

$ sudo fastboot flash recovery openrecovery-twrp-
sending 'recovery' (7170 KB)...
OKAY [  1.074s]
writing 'recovery'...
OKAY [  0.804s]
finished. total time: 1.878s

Recovery mode can be accessed from bootloader.

How to unlock bootloader

Boot into bootloader by hand or command:

$ adb reboot-bootloader

Unlock bootloader:

$ sudo fastboot oem unlock
(bootloader) erasing userdata...
(bootloader) erasing userdata done
(bootloader) erasing cache...
(bootloader) erasing cache done
(bootloader) unlocking...
(bootloader) Bootloader is unlocked now.
OKAY [109.191s]
finished. total time: 109.191s

You can always lock it:

$ sudo fastboot oem lock
(bootloader) Bootloader is locked now.
OKAY [  1.437s]
finished. total time: 1.437s

How to flash stock rom

Download Factory image and unpack it.

Make sure that device is connected:

$ adb devices
List of devices attached
015d2564444eeeee        device

Reboot to bootloader:

$ adb reboot-bootloader

Assure that device is accessible:

$ sudo fastboot devices
015d2564444eeeee        fastboot

Unlock bootloader if it is locked:

$ sudo fastboot oem unlock
(bootloader) Bootloader is already unlocked
OKAY [  0.020s]
finished. total time: 0.020s

Wipe device:

$ sudo fastboot erase boot
erasing 'boot'...
OKAY [  0.134s]
finished. total time: 0.134s
$ sudo fastboot erase cache
erasing 'cache'...
OKAY [  0.275s]
finished. total time: 0.276s
$ sudo fastboot erase recovery
erasing 'recovery'...
OKAY [  0.135s]
finished. total time: 0.135s
$ sudo fastboot erase system
erasing 'system'...
OKAY [  0.392s]
finished. total time: 0.392s
$ sudo fastboot erase userdata
erasing 'userdata'...
OKAY [  0.531s]
finished. total time: 0.531s

Flash bootloader:

$ sudo fastboot flash bootloader bootloader-grouper-4.13.img
sending 'bootloader' (2096 KB)...
OKAY [  0.333s]
writing 'bootloader'...
OKAY [  1.966s]
finished. total time: 2.299s

Reboot it:

$ sudo fastboot reboot-bootloader
rebooting into bootloader...
OKAY [  0.020s]
finished. total time: 0.020s

Reflash device:

$ sudo fastboot -w update image-nakasi-jop40c.zip
archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
archive does not contain 'system.sig'
Bootloader Version...: 4.13
Baseband Version.....: N/A
Serial Number........: 015d2564444eeeee
checking product...
OKAY [  0.040s]
checking version-bootloader...
OKAY [  0.023s]
sending 'boot' (4942 KB)...
OKAY [  0.766s]
writing 'boot'...
OKAY [  0.660s]
sending 'recovery' (5444 KB)...
OKAY [  0.826s]
writing 'recovery'...
OKAY [  0.553s]
sending 'system' (477136 KB)...
OKAY [ 67.061s]
writing 'system'...
OKAY [ 37.041s]
erasing 'userdata'...
OKAY [  4.158s]
formatting 'userdata' partition...
Creating filesystem with parameters:
    Size: 14569963520
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 8160
    Inode size: 256
    Journal blocks: 32768
    Blocks: 3557120
    Block groups: 109
    Reserved block group size: 871
Created filesystem with 11/889440 inodes and 97309/3557120 blocks
sending 'userdata' (137563 KB)...
writing 'userdata'...
OKAY [ 31.846s]
erasing 'cache'...
OKAY [  0.188s]
formatting 'cache' partition...
Creating filesystem with parameters:
    Size: 464519168
    Block size: 4096
    Blocks per group: 32768
    Inodes per group: 7088
    Inode size: 256
    Journal blocks: 1772
    Blocks: 113408
    Block groups: 4
    Reserved block group size: 31
Created filesystem with 11/28352 inodes and 3654/113408 blocks
sending 'cache' (9052 KB)...
writing 'cache'...
OKAY [  2.523s]
finished. total time: 145.819s

How to root Nexus 7

Install recovery image and download CWM installable SuperSu.

Store it on “sdcard”:

$ adb push CWM-SuperSU-v0.98.zip /sdcard/
793 KB/s (685572 bytes in 0.843s)

Reboot into mode recovery and install it as update. That is all, nothing more.

Ending notes

Couple of times I said to “boot into bootloader by hand” and meant to turn on device by holding down power and volume down buttons.

If you want to read more then jump directly to xda-devolopers as it is best source for such information.

I enjoyed using Paranoid Android (xda-developers forum link) and I think that it is best ROM up to now at least for me.

If you need a shell script to do all work then look at n7root project.