Howto root the Samsung Galaxy S2 from Linux

Hi Everyone, i have found this article very interesting one and wanted to share with you all.This work was originally created by Ben Tasker.

Rooting the S2 is actually a lot less painless than the X8, though I did find a small gotcha in the process! Let’s deal wuth the pre-requisites first;

Go and download Heimdall, I went with compiling from source but give the binaries a go. I went with version 1.3.1 given the warnings for 1.3.2 but either should work.

Now we need to find out which kernel our phone is running. So on your phone

Settings -> About Phone

Look for Kernel Version, it will be something like “2.6.35.7-I900XWKK10CK726411”. I’ve made the relevant bit bold (KK1). Now go to the xda-developers forum thread and find the kernel image that matches your phone based on this string. If you can’t find an exact match, go for the closest (i.e. KK2 -> KK3).

Note: If you have version KK1, I found that it caused my phone to whitescreen. I used KK2 instead.

Once you’ve downloaded the image, we need to push it to the phone. First we want to extract just the bits we want, so assuming you downloaded CF-Root-SGS2_XW_XEN_KK2-V5.0-CWM5.zip

unzip CF-Root-SGS2_XW_XEN_KK2-V5.0-XWM5.zip
tar xvf CF-Root-SGS2_XW_XEN_KK2-v5.0-CWM5.tar

Which should leave you with the file zImage.

Now, put your phone into Download mode;

  • Power Off
  • Hold Volume Down+Home Key+Power key until you see the intro key
    Press Volume up to continue (the screen will prompt you to do so)
  • Connect the phone to your PC with USB and check whether it’s been detected

heimdall detect
# Should return Device Detected sudo heimdall flash –kernel zImage

A large amount of output will appear, which should end with

Uploading KERNEL
100%
KERNEL upload successful
Ending Session….
Rebooting Device….
Re-attaching kernel driver….

And your phone should reboot into the newly rooted system. Now’s a good time to look at backing up your efs folder though, to avoid needing to pay Samsung to repair things should anything go wrong.

So, install a terminal emulator on your phone, and after opening run the following

su
# Accept when asked if you want to grant permissions
mkdir /sdcard/efs
busybox tar zcvf /sdcard/efs/efs-backup.tar.gz /efs

This will create a backup of the /efs folder on your SDCard, so should you ever break anything in this folder you have half a chance of restoring it!

Leave a Reply