Copyright Notice

Protected by Copyscape Duplicate Content Penalty Protection

Tuesday, January 1, 2013

Blog has moved to ----> mgw.dumatics.com


This post can now be read at HERE


Having a rooted phone and then going to one that does not have root access is like getting used to driving a luxury car but then being forced to drive a tractor. So with arrival of my shining new nexus 4 once the novelty worn of in 8 hours or so, I sat down and rooted the device. Now there are plenty of guides out there but not many specific to Linux just yet. One reason might just be the fact the Linux Users are really smart and know how to figure it out but what about users who are new ...well at least for them I am sure this post will be useful and while we are at it, I felt I will install the touch version of CWM...



Pre-requisite:
  1. For purpose of this tutorial, I will assume that adb set-up is in place using steps explained in my last post specifically up to Step 5. It is totally worth doing it before you proceed but if you would prefer a shorter route, please refer some guide on how to install just adb. Though I would not recommend any other approach. (Not because they will not work but because this approach will ensure clean system and something I have tested 4 times already to work and if you will follow this post, it makes sense to do it the way I did)
  2. Clockwork Recovery Mod (Touch Version)
  3. Super User App 
  4. Fastboot
  5. This process will wipe out all user data and apps. Appropriate back-ups should be taken and restoring those is beyond the scope of this post.
2 and 3 can be downloaded directly from http://www.clockworkmod.com/rommanager and http://download.chainfire.eu/282/SuperSU/ or as before I have uploaded them in mediafire. I downloaded fastboot few months back from xda using this link and am not sure if it is still there or not so I have uploaded it to mediafire as well. 

All these files can be downloaded from mediafire here.










Step 1: Prepare Nexus 4 and Linux Mint 13
Step 2: Unblock bootloader for Nexus 4
Step 3: Root Nexus 4
Step 4: Make Clockwork Mod Permanent
Step 5: Mount and Un-Mount Nexus 4 to access files from Linux Mint


Step 1: Prepare Nexus 4 and Linux Mint 13

1.1. Check if fastboot is already there in the the /android-sdks/platform-tools directory. If yes skip the next step.

1.2. Extract the fastboot from downloaded zip file and place it in the /android-sdks/platform-tools directory if it is not already there and make it executable (Right Click, Select properties, Go To permissions tab and select the checkbox in front of "Execute")

1.3. Copy the downloaded Clock Work Mod file (recovery-clockwork-touch-6.0.2.3-mako.img) in the /android-sdks/platform-tools directory.

1.4.Activate debug mode in nexus 4 - to do this go to settings > About Phone and then click 7 to 8 times on "Build Number". This will activate developer mode.

1.5. Now click back and got to {} Developer Options and Click the checkbox against USB debugging.

1.6. Set up udev on linux mint:
          a. Assuming that you have followed last post you would already have a "51-android.rules" file created.
          b. Open the file with Gedit using following command
     sudo gedit /etc/udev/rules.d/51-android.rules 
    c. Add following lines:
    #LG - Nexus 4
    SUBSYSTEM=="usb", ATTR{idVendor}=="1004", MODE="0666"
    
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="4ee1", MODE="0660", OWNER="ankit" #Normal nexus 4
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="4ee2", MODE="0660", OWNER="ankit" #Debug & Recovery nexus 4
    SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="4ee0", MODE="0660", OWNER="ankit" #Fastboot nexus 4


    I got the Vendor ID and Product ID by connecting the phone in different states (USB debug checked, unchecked and also after the phone was connected and rebooted into bootloader using command "adb reboot bootloader") as per the guidance given here.
    d. Now Save the file, then chmod to all read using following command:
         
 sudo chmod +x /etc/udev/rules.d/51-android.rules 



Step 2: Unblock bootloader for Nexus 4

2.1. Plug your phone into the computer and type the following command in terminal:
 adb reboot bootloader

2.2. Once Nexus 4 has rebooted in recovery mode, type the following command in terminal:
 fastboot oem unlock

If terminal displays the message "waiting for device" 51-android.rules file is not set correctly and you might need to check vendor ID and product id using lsusb command in different modes and update it with appropriate data.

2.3. Phone will display a long message and ask for confirmation to unlock bootloader. Select "Yes" by using the volume keys and use power to select it.

2.4. Now, using volume keys navigate to "Recovery Mode" and select it using "Power" key.

2.5. After a while Android with blue progress bar should appear and phone should reboot but if it does not and instead shows a screen with "Android" on it's back with an exclamation mark on it's tummy, don't panic. Just press "Power" and "Volume Up" till it shows recovery menu and then select "reboot".

The phone is now bootloader unlocked.

Step 3: Root Nexus 4

OK now when the phone boots, it will be fresh with factory reset, no data or apps whatsoever other than those that are there by default and when the phone boots, it will ask all details like selecting country etc. Just enter quickly without bothering to enter gmail, wifi etc. Once done:

3.1. Install mtpfs from synaptics.

3.2. Plug the phone to computer.

3.3. Type the following commands:
 sudo mkdir /media/nexus4 

followed by 
 sudo chmod 755 /media/nexus4 

3.4. Now mount the nexus 4 using following command so we can transfer files:
 sudo mtpfs -o allow_other /media/nexus4 

3.5. Copy the downloaded file "CWM-SuperSU-v0.98.zip" on Nexus 4.

3.6. Type the following command to unmount nexus 4:
sudo umount /media/nexus4

3.7. Reactivate the debug mode using Step 1.4 and Step 1.5 above.

3.8.  On terminal type the command:
adb reboot bootloader 

followed by:
fastboot flash recovery /android-sdks/platform-tools/recovery-clockwork-touch-6.0.2.3-mako.img

Make sure in above command you replace PATH_TO with the actual path to the file. An easy way can be to right click on "recovery-clockwork-touch-6.0.2.3-mako.img" file and click on properties thene select the path and paste in this command.





















3.9. Once completed, on the phone navigate to "Recover Mode" using volume keys and select using power key.

3.10 The new recovery menu will be presented. Select "install zip from sd card" and "choose zip from sd card." and select the file we had put in step 3.5 - "CWM-SuperSU-v0.98.zip".

3.11 Once done, go back to reboot and "Reboot" the phone.

At this point your phone is rooted,however, you will get a message suggesting the recovery will not be permanent or something to that effect which is fine if you aren't bothered about it but if you would rather want to keep this CWM we need to move to next step.

Step 4: Make Clockwork Mod Permanent

4.1. On your phone install ES File Explorer.

4.2. Select Settings.

4.3. Select "Root Settings".

4.4. Select all checkboxes. You will be asked for superuser access, say Yes..
4.5. Now go back to main screen of ES File Explorer and select the third tab with an icon of Folder with up arrow and text Up. This should bring you to root.

4.6 Now using ES File Explorer navigate on your phone to /system/etc, find the file named "install-recovery.sh" and rename it to "install-recovery.bak"

4.7 Repeat Steps 3.7 to 3.11.

Now your clockwork mod is permanent.

Step 5: Mount and Un-Mount Nexus 4 to access files from Linux Mint

Now, with the steps 3.1 to 3.6 we have laid the foundation for being able to connect Nexus 4 and transfer files using USB. Something earlier was possible using USB Mass storage mode but is not present jelly bean onwards. 

The commands in 3.4 and 3.6 are key to achieve this but rather than remembering these and typing each time, I have made a menu entries for each of these (Mount Nexus 4, Unmount Nexus 4) and after connecting phone via USB, I simply click on these, system asks root password and then connects nexus 4 as mass storage (see screenshot below):



In order to get these you will follow the steps below:

5.1 Right Click on Menu and select "edit Menu".
5.2 Now click on "New Menu" and Enter a menu entry "Phone".
5.3. Select the checkbox next to the new menu entry "Phone" in middle pane.
5.4. Select new menu entry "Phone" in left pane.
5.5. Click on "New Item" in right Pane and in the dialogue box fill the fields as below and save:
              Type:             Application in terminal
              Name:            Mount Nexus 4
              Command:     sudo mtpfs -o allow_other /media/nexus4
5.6 Again click on "New Item" in right Pane and in the dialogue box fill the fields as below and save:
              Type:             Application in terminal
              Name:            Unmount Nexus 4
              Command:     sudo umount /media/nexus4
5.7 Make sure checkbox next to these new items is ticked. Save and Close.

That's it !!! All Done.

Hope some will find this post useful.
-Ankit.


5 comments:

  1. Hi Ankit,
    great post! :)

    Now I just need to buy myself Nexus 4... but here in Slovenia is too expensive... ;) .. +400€ ... I am still running my goodie oldie Desire with CM10.1 (need to flash it today :))))

    Where did you buy Nexus 4, directly from google ? (no carrier commitment or contract). If possible to get it cheaper, please contact me privately :)))

    Otherwise I also switched to Linux Mint (14) using Cinnamon.. it's really awesome :))) usability/flexibility and so on and on..
    I don't wanna mention to you how painful it was to to switch from Win7 to Linux... to convince IT admin to allow me to swap to Linux.. (all company is using M$ win shit... :/). Okay, I virtualized my physical machine to virtual machine because of some apps, but I don't start VM more than 3 times peer week :)

    Here is list of apps I use at my everyday work...
    - guake (must have :))
    - Shutter
    - gnome-do
    - linphone
    - kepass2
    - pac manager (ssh, console access.. must have :))
    - remmina
    - browsers (chrome, firefox)
    - thunderbird for reading corporate email (thanks again for you tutorial..)
    - libre office
    - other simple / useful programs and some scripts... :)

    Thanks again for great post.

    Looking forward for new posts... :)

    Regards
    Damjan

    ReplyDelete
  2. Hi Damjan,

    Thanks for the kind words. :)
    I got nexus 4 directly from Google and it is indeed contract free and unlocked. It is in my opinion one of the best you can get and its cost is really the icing on the cake.

    I am so glad that you have not only taken the decision to embrace Linux but even convince your IT to support which really is no small feat...

    What is your profession? I am a project manager and to be fair and give devil his due, Microsoft project is a very accomplished product with no open source alternative nearly as good. That does force me to take the bitter pill and get on with windows in office but home is all Linux :).

    You also mentioned in comments about conky...I have a modified conky which I initially got from some forum.

    I can share it with you perhaps over the weekend or might as well make a blog post :).

    Once again thanks for encouraging words.

    Ankit.

    ReplyDelete
  3. It took a while, but I just rooted my Nexus 4 following the instructions on this post and on the earlier one to set up adb. The instructions here worked almost perfectly. I'm very pleased with the results.

    I had three or four minor problems, but nothing to worry about.

    Thank you for the instructions. They contained just the amount of detail I needed.

    Dan

    ReplyDelete
    Replies
    1. Hi Dan,

      I am glad it helped. What were the issues your faced and how did you overcome them?

      Regards,
      Ankit.

      Delete
    2. Here were my small issues on the two web sites.

      I. Prepare Linux Mint 13 for Android Development

      Installing Oracle Java:

      Somehow I managed to end up with java version 1.7.0_07 instead of 1.7.0_09 as shown in the png images. It didn't seem to make any difference.

      Installing eclipse:

      I followed the instructions saying to "open Synaptic package manager and type 'eclipse'." This gave me a conflict between 32-bit and 64-bit libraries. I uninstalled eclipse and installed it again from the mediafire website which you linked. This worked fine.

      Final Configuration:

      Somehow I managed to install android-sdks under /root so much of the configuration didn't help too much. My work-around was just to work as superuser from the /root/android-sdks directory.

      II. Root Nexus 4 on Linux Mint 13

      Root Nexus 4:

      Step 13. Going back to reboot I got a question, "ROM may flash stock recovery on reboot. Fix?" I answered yes as this seemed to be the correct reply. Everything seemed to be fine.

      [I got a second similar question today when I updated to 4.2.2. I think the question was, "Root may be lost. Fix" Again I answered yes and I was fine.]

      Mount and Un-Mount Nexus 4 to access files from Lnux MInt:

      Installation into the menu didn't work. But sudo mtpfs -o allow-other /media/nexus4 works fine from the command line.

      Thanks again for the help. Sorry I don't have an account and have to be "Anonymous."

      Dan

      Delete

Search This Blog