[LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flashing

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Let me say this first:
I AM NOT A UNLOCKING, ROOTING, ROM'ing, LINUX EXPERT. WHAT YOU DO TOO YOUR PHONE IS YOUR PROBLEM.

This guide is for Linux users that want to use their favorite OS to work with their phone. The information found here can be found elsewhere on the Internet, but it did take a little work to dig it up so I figured I would put together a guide that that a noob should be able to follow. Please keep in mind, that I'm a noob also. I am a programmer by trade and I have used Linux for several years now, but I don't claim to be an expert. I should be able to help with minor problems, but you need to follow the steps here exactly as I'm just compiling the best sources I could find. I will cite those sources so that you can check them out for yourself.

THE GUIDE
1) Installing the Android SDK/ADB/Fastboot on Linux (64-bit Lubuntu 11.10 in this case).
2) How to Unlock and Root your Galaxy Nexus.
3) How to return your Galaxy Nexus to Factory Sate.
4) User Issues and Workarounds.*


*Here is the best part, I will try to keep a list of user Issues and Workarounds!

This is where you can help. If you are having an issue that is not solved with one reply, please put it in another thread and post the link here. I will post the link here so that others can use it to help you. Once you are sure your problem is solved, simply mark that thread solved. This way the discussion, progress and solutions can stay on topic in that thread and it will be easier for you and others to follow. If you end up solving the problem within this thread, please post a summary of the problem and the solution and I will put a link to that post so that others can find it.

Doing this will make this thread more useful because other users won't have to dig through pages and pages of replies to see if someone else had the same problem as you did. Think of it as paying it forward.


Lastly, if there are any experienced Linux Rooter and ROM'ers out there, please reserve a post or two on the first page of this thread that you could use to add to this guide. I would love the help and will be sure to link your post.


EDIT: I realize the threads look long, but there isn't all that much to do. I'm just being very verbose so that anyone should be able to follow the guide. I'm trying to make it "so easy a caveman could do it" so please bear with me.
 
Last edited:

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

1) Installing the Android SDK/ADB/Fastboot on Linux with 64-bit support!

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EDIT: You could follow this guide if you like or you could use a script will take care of it for you. You can find more information HERE. I used it with 64-bit Lubuntu 12.04 and it worked great.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

I found that working with the Galaxy Nexus with Linux was actually really easy once I figured out how to get the Android SDK working with my 64-bit Linux system. I used 64-bit Lubuntu 11.10 which is just a light weight version of Ubuntu so this guide should work for Ubuntu users.

(If you are using something other than Ubuntu, then you probably don't need this guide. If you feel your distro of choice needs it, please add a post or a dedicated thread for it and I will add a link or simply add the information to this guide.)

This part of the guide should get your computer to the point where you can unlock, root and restore your phone. This will probably be the hardest part of the entire process and it isn't even that hard. I know this looks like a lot of work, but it shouldn't take more than 30 minutes or so. Once you get this done you will be rewarded because everything after this will be easy peasy!

WARNING: If the thought of typing commands in a terminal scares you to death, then using Linux to Unlock and Root you phone might not be for you. There are some great "one click" methods for Windows out there if that's more your style.

INSTALLING the SDK
1) Install Java
You need to get a Java SDK on your machine.

To see if you have a Java JDK, open your terminal and type in the following command:
Command:
java -version

(If you have never used the terminal in Ubuntu, you should find it in your accessories menu or by pressing Ctrl+Alt+T. You can copy and past the command and press enter. Also, if you are typing in commands or directories, you can type the first few letters and double press Tab for auto-complete options.)

If you have Java JDK, you will see something like this:
Command:
Aspire-3820:~$ java -version java version "1.6.0_23" OpenJDK Runtime Environment (IcedTea6 1.11pre) (6b23~pre11-0ubuntu1.11.10) OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)


I'm using OpenJDK6.0 but any Java JDK should do. In Lubuntu you can use Synaptic Package Manager to install the OpenJDK. If you are using Ubuntu (without Synaptic) you may want to check out the first reference at the bottom of this post.

You could also use Google to find a guide like this one: how to install jdk on Ubuntu 11.10 Which simply says to type the following command in your terminal to get OpenJDK:
Command:
sudo apt-get install openjdk-7-jdk


Or this for the Sun JDK:
Command:
sudo add-apt-repository ppa:ferramroberto/java sudo apt-get update sudo apt-get install sun-java6-jdk sun-java6-plugin


2) Install Android SDK/ADB?Fastboot
Now you need to download the Android JDK for Linux from here: Android SDK | Android Developers

Once it's done downloading, open your file manager and go to Downloads. Find the zip you just downloaded, right click the file and choose "Extract Here" to unpack it. You will then have a folder named android-sdk-linux. Copy the file and paste it in your home directory. (You can delete the zip file you pasted if you want to clean things up a bit.) The end result is that you have a android-sdk-linux folder to your home directory.

The command lines to accomplish this same task would look like this:
Command:
cd Downloads tar xfvz android-sdk_r16-linux.tgz mv android-sdk-linux/ ~


Now we need to cd (change directory) to the android-sdk-linux folder and run the update script:
Command:
cd ~/android-sdk-linux/tools/ ./android update sdk


Click install and wait for it to do its thing. This will take a little while. When finished you should find a folder called "platform-tools" inside your android-sdk-linux directory. Inside "platform-tools" you should see "adb" and "fastboot". (If for some reason you don't see fastboot, you can download it HERE. Extract the contents, place it in the "platform-tools" folder and rename it to fastboot.)

While you wait for the update to finish, lets get the Galaxy Nexus ready for work. You need to make sure USB debugging is enabled. You do this on your phone with settings/applications/development menu options and checking the USB debugging box. Now wait until the SDK is finished updating and we will test your phone.

If you are on 64-bit Linux, you will need run the following command before moving on to the next step:
64-bit only Command:
sudo apt-get install ia32-libs


When the updated is complete, plug you phone (power should be on) into the USB port on your computer. DO NOT choose USB storage. You should see the usb debugging connected message in your notifications screen.

Now lets see if ADB sees your phone:
Command:
cd platform-tools/ ./adb devices


If you are lucky, you will see something like this:
Command:
List of devices attached H100004t0000


This means ADB is working! You can continue to step 4. The rest of us will need to set up uDev rules before ADB sees or phone.

3) Setting up uDev rules (if needed)
This shouldn't be too difficult. First make sure you don't already have android.rules set up.
Command:
ls /etc/udev/rules.d/


If you find something with "android.rules" you should probably rename it with the mv command. For example I'll just add .bak to mine:
Command:
mv /etc/udev/rules.d/91-android.rules /etc/udev/rules.d/91-android.rules.bak


This next command will create a new android.rules file. If your Linux distro doesn't have gedit, you can try leafpad (in Lubuntu) or use nano, vim, etc:
Command:
sudo gedit ~/etc/udev/rules.d/99-android.rules


Now paste the following into the file:
Copy and paste:
#Acer SUBSYSTEM=="usb", SYSFS{idVendor}=="0502", MODE="0666" #Dell SUBSYSTEM=="usb", SYSFS{idVendor}=="413c", MODE="0666" #Foxconn SUBSYSTEM=="usb", SYSFS{idVendor}=="0489", MODE="0666" #Garmin-Asus SUBSYSTEM=="usb", SYSFS{idVendor}=="091E", MODE="0666" #Google SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666" #HTC SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666" #Huawei SUBSYSTEM=="usb", SYSFS{idVendor}=="12d1", MODE="0666" #Kyocera SUBSYSTEM=="usb", SYSFS{idVendor}=="0482", MODE="0666" #LG SUBSYSTEM=="usb", SYSFS{idVendor}=="1004", MODE="0666" #Motorola SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", MODE="0666" #Nvidia SUBSYSTEM=="usb", SYSFS{idVendor}=="0955", MODE="0666" #Pantech SUBSYSTEM=="usb", SYSFS{idVendor}=="10A9", MODE="0666" #Samsung SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666" #Sharp SUBSYSTEM=="usb", SYSFS{idVendor}=="04dd", MODE="0666" #Sony Ericsson SUBSYSTEM=="usb", SYSFS{idVendor}=="0fce", MODE="0666" #ZTE SUBSYSTEM=="usb", SYSFS{idVendor}=="19D2", MODE="0666"


Save the file and close your editor. Now lets change permissions for android.rules:
Command:
ls /etc/udev/rules.d/sudo chmod a+r /etc/udev/rules.d/99-android.rules


Now make sure your phone is not plugged into your computer and restart uDev and ADB:
Command:
sudo service uDev restart ./adb kill-server ./adb start-server


Now ADB should work. Try the devices command again:
Command:
cd platform-tools/ ./adb devices


If ADB still doesn't see your phone please make sure you ran all of the commands successfully. You may need to change the uDev rules. There are a couple of different examples used in the links I referenced. Please read those before posting here. If you need to change the uDev rules, simply open the file as you did above and add the new rules to your file and save it.

4) Make ADB and Fastboot work from any directory
Doing this step will allow you to run ADB from anywhere meaning that you won't have to be in "~/android-sdk-linux$ cd platform-tools/" directory to run it and you won't need the "./" in front of the command either.

Type (or paste) the following command in the terminal (any directory will work)
Command:
sudo gedit ~/.bashrc


AND paste these lines at the bottom of the file:
Copy and Paste:
# Android tools export PATH=${PATH}:~/android-sdk-linux/tools export PATH=${PATH}:~/android-sdk-linux/platform-tools


Now make sure your phone is not plugged into your computer and restart ADB:
Command:
source ~/.bashrc ./adb kill-server ./adb start-server


Now plug your phone in, cd to your home directory and test ADB:
Command:
cd adb devices

NOTE: If this doesn't work after restarting adb, try rebooting your system. It should work after that.

If that works, congratulations! You are now set up to easily work with your phone in Linux.

If you are still having trouble, please read the referenced links. If you need to ask a question, please post here. If the question turns into it's own topic, consider taking it to another thread and post it here so I can create a link below. That will make it easier to get help and more useful for others who may experience the same problem later on.

References:
Ubuntu 11.10 and ADB and fastboot
Step by Step OEM Unlock and Root
Download the Android SDK
Installing the SDK
uDev Rules for Any Device! (No more starting adb with sudo)
More complete uDev rules in case you need it.
[GUIDE] ADB Workshop and Guide for everyone
 
Last edited:

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

WARNING: Please read all of the instructions carefully.
2) How to Unlock and Root your Galaxy Nexus
This part is easy once you can ADB into your phone. But before you do, you should make sure your phone is up to date first.

UNLOCK and ROOT
1) Downloads
Download the CDMA version of CWM Root and Recovery: http://download.clockworkmod.com/recoveries/recovery-clockwork-5.5.0.4-toro.img
DO NOT DOWNLOAD THE GSM VERSION!!!! MAKE SURE YOU USE THE "TORO" IMAGE!!!!
Download the Superuser package: http://download.clockworkmod.com/test/su.zip

2) Unlock your phone
Be careful not to move your phone or unplug the usb cable while you do this.

Make sure USB debugging is enabled. Plug in your phone if it isn't already and type the following two commands:
Command:
adb reboot bootloader sudo fastboot oem unlock

The first command takes you to the fastboot screen of your phone. If it didn't work, you can shut the phone down and hold the [power + volume up + volume down] buttons until the phone vibrates. This should get you to the fastboot screen. Once there you can run the fastboot command.

The rest of these steps will be need to be done on your phone:

1. You will get a screen asking you if you want to unlock the bootloader. READ THIS SCREEN. If you DON'T read it you WON'T know what to do! :p Do what it says and you should go back to the fast boot screen. At the bottom of the screen, it should say "unlocked' in red letters.
2. Now press [volume down] until you get the "recovery mode" option and press the [power button] to enter that selection. After a few seconds, you should see a blank blank screen with an open android.
3. Next press the [volume up + volume down + power] all at the same time to get to the next menu. (Try not to press the power button first by accident.)
4. Once in that menu, use the volume key to select "wipe data/factory reset" and press the power button. (If you get errors related to cache, go back and wipe cache and then redo the factory reset.)
5. Use the [volume down] button to select "Yes--delete all user data" and press [power] to enter. Wait for it to finish (about 5 or more minutes).
6. Select "reboot system now" and press power. Now wait for it to reboot. It might take some time so be patient and don't panic!

When your phone reboots you will see the welcome screen and you will need to sign back into your Google account. You will probably notice that you also lost any personal settings like folders, widgets and wallpaper, etc.

3) Install CWM and ROOT
Next we need to install Superuser (root) and clockwork recovery (restore). Keep in mind that you can skip rooting your phone here if you are going to flash a ROM that is rooted.

Make sure USB debugging is enabled. Next, cd into the directory that you saved the su.zip and CWM toro image. We will use ADB to push the file to the sdcard directory on your phone and then Fastboot to install CWM:
Command:
adb push su.zip /sdcard/su.zip adb reboot bootloader sudo fastboot flash recovery recovery-clockwork-5.5.0.4-toro.img


Now do these steps from your phone:
1. Press [volume down] to select "recovery mode" and then press [power] enter the selection.
2. Use [volume] to select "install zip from sdcard" and press [power].
3. Press [power] and select "choose zip from sdcard"
4. Select the su.zip from your sdcard
5 . Select "Yes -- Install su.zip" in the next menu.
6. Select "reboot phone now"cd

4) Keep CWM around (optional)
If your phone got the 4.0.2 OTA update, you will need to do the following to keep CWM around. If you are going to flash a ROM, you can skip this step.

Type each command in this list:
Command:
adb shell mount -o rw, remount /system mv /system/etc/install-recovery.sh /system/etc/install-recovery.bak exit


That's it!

References:
Step by Step OEM Unlock and Root
 
Last edited:

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

3) How to return your Galaxy Nexus to Factory Sate.

Something might go wrong or you need to return your Galaxy Nexus. This is what you need to do to restore it to STOCK 4.0.2 ICS, just like the day you got it.

UNROOT and LOCK
1) Downloads
Download the Android 4.0.2 (ICL53F) Factory Image Zip File HERE

To check the MD5, cd to the directory where you downloaded the file and run the md5sum command:
Command:
cd ~/Downloads md5sum mysid-icl53f-factory-65895fa8.tgz

MD5: bafc4d3c5faa9822f76a5313fc91f743

2) Extract the files
To extract the files you can use the file manager, right click and choose extract here or run this command:
Command:
tar xfvz mysid-icl53f-factory-65895fa8.tgz

You can move the files to another place if you want.

3) Flash the ROM
Now cd into the folder containing the extracted files and put the phone into fastboot mode:
Command:
cd mysid-icl53f/ adb reboot bootloader


Next, flash the new bootloader, radio, CDMA radio making sure to reboot the bootloader each time.
1. Bootloader image:
Command:
sudo fastboot flash bootloader bootloader-toro-primekk15.img sudo fastboot reboot-bootloader

2. Radio:
Command:
sudo fastboot flash radio radio-toro-i515.ek02.img sudo fastboot reboot-bootloader

3. CDMA radio(this one takes a couple minutes so don't panic):
Command:
sudo fastboot flash radio-cdma radio-cdma-toro-i515.ek05.img sudo fastboot reboot-bootloader


And then update the image (this one takes a few minutes and reboots a few times):
Command:
sudo fastboot -w update image-mysid-icl53f.zip

When it's done you will be at the Android Welcome screen. You will need to set up your phone now.

You now have a fresh factory image on the phone, but it's still unlocked. If you want to look it, see the next step. If not you are finished.

4) Lock the Bootloader (optional)
If you want to lock the bootloader, make sure USB Debugging is still enabled on your phone (Settings/Developer Options) and run the following commands:
Command:
adb reboot bootloader sudo fastboot oem lock

When you are done press the power button and you are finished.

References:
Return to Factory State (Unroot and Relock)
 
Last edited:

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

4) User Issues and Workarounds.

I NEED YOUR HELP!!

If you are having an issue that is not solved with one reply, please put it in another thread and post the link here and I will post the link here so that others can use it to help you. Once you are sure your problem is solved, simply mark that thread solved. This way the discussion, progress and solutions can stay on topic in that thread and it will be easier for you and others to follow. If you end up solving the problem within this thread, please post a summary of the problem and the solution and I will put a link to that post so that others can find it.

Doing this will make this thread more useful because other users won't have to dig through pages and pages of replies to see if someone else had the same problem as you did. Think of it as paying it forward.

Look here to see who needs help or to find solutions to your problems:
links go here
 
Last edited:

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

Reserved just in case. :)
 
Last edited:

mfischer2

New member
Jan 17, 2012
4
0
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

On my phone, once I get to the fastboot menu, adb can no longer see my device and running the command "fastboot oem unlock" won't work. It just hangs saying "< waiting for device >". Any ideas?
 

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

Go back into your phone and make sure USB debugging is checked.
 

mfischer2

New member
Jan 17, 2012
4
0
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

Yes, it is enabled. adb works fine when the phone is not in the bootloader. Once I'm in the bootloader, adb doesn't see any devices, making it and fastboot useless. (note: I'm not a total noob, I rooted my original droid a few times, this is obviously a different process).
 

mfischer2

New member
Jan 17, 2012
4
0
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

Okay, I fixed it. Here's the note for your notes.

I ran "fastboot devices" and saw I had permission issues:

mfisch@caprica:~$ fastboot devices

Then, I re-ran it using sudo and it worked, so I then did sudo fastboot oem unlock and that worked too. Perhaps add to your notes?
 

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

Sounds like it could be a problem with your uDev rules. I noticed there are different setups. You may want to look at some of the references.

Anyway, glad you got it to work. I'll add that to the information in the guide.
 

goater1220

Well-known member
Dec 13, 2010
60
4
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

Im having an issue, Yes I am a noob to linux and Im trying to get my gnexus work on ubuntu 11.04. I followed all the directions and downloaded everything that you said I needed. I get to the part where I check if adb can read my device and set up the udev rules but it wont work for me. When I try the device command it says no such file or directory. Any help is greatly appreciated
 

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

Sounds like you are not in the correct directory to run the command or you didn't install the sdk.

Make sure you are in the android-sdk-linux/platform-tools directory and then type "ls" to list the contents of the directory. (You can use the which command to find it. Mine is located in my opt directory.) You should see "adb" in the list and it should be green.

Code:
Aspire-3820:~$ which adb
/opt/android-sdk-linux/platform-tools/adb
Aspire-3820:~$cd /opt//android-sdk-linux/platform-tools/
Aspire-3820:/opt/android-sdk-linux/platform-tools$ ls
aapt  adb  aidl  dexdump  dx  fastboot  lib  llvm-rs-cc  NOTICE.txt  renderscript  source.properties

If adb is there in green type the adb devices command.
Code:
Aspire-3820:/opt/android-sdk-linux/platform-tools$ ./adb devices
List of devices attached
If you see the "List of devices attached" prompt, you know adb is working. If it finds your phone your good. if not, then you will need to set up udev rules.
 

goater1220

Well-known member
Dec 13, 2010
60
4
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

I'm not sure if that's it. Maybe I'm doing something wrong since I'm so new to this but when I do the ./android update sdk. It starts then I get in red letters stopping adb server failed(code-1) but then continues to download and install all the files. That takes a couple hours . When its all done I get ....
SSL peer shut down incorrectly
Stopping adb sever failed(code-1)
Unable to run adb cannot run program /home/mike/android-sdk-linux/platform tools/adb:Java.io.loexception:error=2, no such file or directory
starting adb server failed (code-1)
All that is in red. I have no idea what I did wrong since I followed your directions and just copied and paste the commands
 

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

I don't think it should take 2 hours to update the sdk. Type
Code:
ls  /home/mike/android-sdk-linux/platform tools/
What do you see?
 

goater1220

Well-known member
Dec 13, 2010
60
4
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

aapt aidl dx lib notice.txt source.properties
adb dexdump fastboot llvm-rs-cc renderscript
 

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

It looks like it's there. Is adb green? Have you tried rebooting the machine?
 

ohiomoto

Well-known member
Oct 31, 2011
705
111
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

Try these running these two commands.

Code:
cd  /home/mike/android-sdk-linux/platform tools/
./adb devices
If they fail, try running this command or reboot the system and try again.
Code:
sudo reboot now
 

goater1220

Well-known member
Dec 13, 2010
60
4
0
Visit site
Re: [LINUX GUIDE for NOOBS] Rooting, Unlocking, Locking and Flash

for some reason it worked but after I tried finishing your steps from 4 down now its not working. I did ls and it says adb_has_moved.txt and its in white