Search

Nexus 7 - Root your tablet with Ubuntu Linux

Contents[Hide]

dropcap-android-rooted

If you want to root your Google Nexus 7, a lot of stuff is available on the net from different sites and forums.

nexus7-front-panel

But most of the guides you get are using some tools running under Windows.

Obviously, you can do the same from an Ubuntu workstation, but all the steps are not trivial.

So, this article will explain all the steps needed to :
 * have your Nexus 7 tablet properly recognised by udev
 * OEM unlock it
 * install TWRP touch recovery
 * root it
 * protect your recovery image from removal

 

The complete procedure has been tested with a Google Nexus 7 running ICS 4.0.3, Jelly Bean 4.1.1, 4.2 and 4.2.1 from a Ubuntu Precise LTS 12.04 computer.

As a pre-requisite, you need to Install latest Android tools on your Ubuntu box.

You have to understand that rooting your tablet is always a little bit risky.
So, if you go further, do it at your own risk !

1. Create Udev rule for Nexus 7

To be able to detect the Nexus 7 tablet under Ubuntu, first thing is to create the proper udev rules that will allow the system to detect the tablet.

These udev rules should be able to handle 4 different cases:

  • tablet connected in MTP mode (USB debug on or off)
  • tablet connected in PTP mode (USB debug on or off)
  • tablet connected in Fastboot mode
  • tablet connected in Recovery mode

They will be declared in /etc/udev/rules.d/99-android.rules. If file already exists, just append the content at the end of it.

# sudo gedit /etc/udev/rules.d/99-android.rules

/etc/udev/rules.d/99-android.rules

# Google Nexus 7 16 Gb
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e41", MODE="0666", OWNER="your-login" # MTP media (multimedia device)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e42", MODE="0666", OWNER="your-login" # MTP media with USB debug on(multimedia device)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e43", MODE="0666", OWNER="your-login" # PTP media (camera)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e44", MODE="0666", OWNER="your-login" # PTP media with USB debug on (camera)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e40", MODE="0666", OWNER="your-login" # Bootloader
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="d001", MODE="0666", OWNER="your-login" # Recovery

Once done, udev service has to be restarted.

# sudo service udev restart

2. OEM Unlock your Tablet

nexus7-bootloader-lockedNext step suppose that you are using android-tools package.
If you are using Android SDK, you should be in ./android-sdk-linux/platform-tools directory.
You also have to issue commands from local directory ( fastboot becomes ./fastboot ).

First main step it to unlock your boot loader.

This standard process, as a safety feature, will wipe all your data.

To do so, you need to enter bootloader mode either :

  • swtiching off your tablet and pressing Vol Down and Power buttons at the same time while restarting it
  • by enabling USB Debug on your tablet and running the following command :

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

Once you get the bootloader screen, if not already done, connect your tablet to your computer with a USB cable.

To unlock your Nexus 7, type this command :

# fastboot oem unlock

Your tablet will be fully erased.
All your data will be lost.

Your phone will ask for a confirmation. Hit the Volume Up button once to select Yes and then the Power button to validate and unlock your Nexus 7.

nexus7-bootloader-oem-unlock    nexus7-bootloader-unlocking    nexus7-bootloader-unlocked

Your screen should go back to bootloader, display a unlocking now ... progress and finally display LOCK STATE – UNLOCKED.

You can now switch off the tablet.

3. Install TWRP recovery

android-twrp22-mainTWRP is a new generation of recovery, which main advantage over ClockworkMod Recovery is to be usable straight from the touch screen.

You don't need anymore to use Volume or Power keys. You can do all the job from the comfort of your touch screen !

Latest version of TWRP recovery image for Nexus 7 is available from TeamWin Recovery Project site.

Get it and place it in your current console directory.

The tablet being still connected, boot into bootloader mode by holding Vol Down and Power till the bootloader menu appears.

We can now flash TWRP recovery into the tablet :

# wget http://techerrata.com/file/twrp2/grouper/openrecovery-twrp-2.3.3.0-grouper.img
# fastboot flash recovery openrecovery-twrp-2.3.3.0-grouper.img
sending 'recovery' (7006 KB)...
OKAY [ 0.880s]
writing 'recovery'...
OKAY [ 0.527s]
finished. total time: 1.407s

After the flash, you need to reboot again in bootloader mode for TWRP Recovery to be recognised and accessible.

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

From bootloader menu, select Recovery mode with Vol down and hit Power.

You will reboot and enter TWRP Recovery.

4. Flash Superuser

You will have to download latest SuperSU files. These are the file that will be flashed on your phone to allow the super user privilege elevation.

At the time of this article the latest file is  http://download.chainfire.eu/282/SuperSU/CWM-SuperSU-v0.98.zip.

We will need to download the archive and to copy it to the Nexus 7.

From TWRP recovery, select Mount menu.

# adb devices
List of devices attached
xxxxxxxxxxxxxxxx recovery
# wget http://download.chainfire.eu/282/SuperSU/CWM-SuperSU-v0.98.zip
# adb push 'CWM-SuperSU-v0.98.zip' /sdcard
1322 KB/s (1324669 bytes in 0.977s)

From TWRP recovery follow these steps :

  1. select Install
  2. move thru directory structure to sdcard
  3. select CWM-SuperSU-v0.98.zip
  4. confirm the operation

nexus7-twrp-superuser

You're done, your Nexus 7 is rooted !

5. Protect TWRP Recovery

By default, stock ROM removes any recovery ROM at every boot. That means that at next boot your newly flashed TWRP recovey will be gone !

This removal is done at boot by a specific file named /system/recovery-from-boot.p.

The good news is that you just need to rename that file to block the recovery removal mecanism. We will do it straight from TWRP Recovery.

Make sure your tablet is connected to your computer, select the Mount menu and configure it as follow :

 nexus7-twrp-mount

Now, from your computer, using adb, we  will open a shell on the tablet and rename the file :

# adb shell
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
# cd /system
# ls
app                       fonts                     recovery-from-boot.p
bin                       framework                 usr
build.prop                lib                       vendor
etc                       media                     xbin
# mv recovery-from-boot.p recovery-from-boot.p.bak
# ls
app                       fonts                     recovery-from-boot.p.bak
bin                       framework                 usr
build.prop                lib                       vendor
etc                       media                     xbin
# exit

The recovery removal process is broken. We can reboot.

From TWRP Recovery, select Reboot and System.

6. Install applications for rooted devices

android-supersu-iconOnce you've rebooted, you should get the Superuser icon in your applications list.

Now that your Nexus 7 is rooted, first thing to do is to install some very interesting applications from Google Play market.

  • BusyBox : BusyBox combines tiny versions of many common UNIX utilities into a single small executable.
    It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc.
  • Root Browser Lite : File manager
  • Quick Boot : Shortcut to directly boot into bootloader or recovery
  • Ad Away : Remove the add banners you get with more and more applications.
    As it work at the /etc/hosts level, it is a real add killer.

 

You now have a fully rooted Nexus 7 with TWRP Recovery that you can call anytime you need it.

Hope it helps !

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus