Preparation:
1. Create a working folder, for example pre-rooted, download and extract
THIS (64 Bit) file and copy/paste (simg2img & ext2simg) into working folder.
2. Download SuperSu.zip from Chainfire's thread and extract all files to new folder, for example "root files". Copy/paste this folder into working folder.
3. Download any Samsung FW and extract it. You'll have a single file xxxxxxxxx.tar.md5, extract it again to new folder (keep name of the folder same as name of your FW, xxxxxxxx , it makes things easier to work with).
4. Go to the new folder and check if all files are there (5-10 files), look for system.img.ext4. If everything is there, copy/paste whole folder xxxxxxxx to your working folder /pre-rooted
5. Move system.img.ext4 directly to the working folder: /pre-rooted/system.img.ext4.
At this point, you should have following files/folders in working folder:
/pre-rooted/system.img.ext4
/pre-rooted/ext2simg
/pre-rooted/simg2img
/pre-rooted/xxxxxxx (folder with your FW)
/pre-rooted/root files (folder with extracted files from SuperSU.zip)
Pre-Rooting process:
Open Terminal and navigate to the pre-rooted folder, for example: cd /home/*username*/pre-rooted.
Step 1:
Convert system.img.ext4 into a raw system partition that can be mounted under Linux as r/w partition - system.img.raw
Type in Terminal and press Enter:
Code:
./simg2img system.img.ext4 system.img.raw
and wait until the process is finished, it takes few minutes....
Step 2:
Mount converted partition under Linux:
Type in Terminal and press Enter:
Code:
mount -t ext4 -o loop system.img.raw /mnt
Use any File Manager or just navigate to /mnt/.... and there you have full access to the system files.
Step 3:
Copy/paste or delete any files you want from/to system, for example root files:
Superuser.apk -> /mnt/app/Superuser.apk
su (binary) -> /mnt/xbin/su
daemonsu (binary) -> /mnt/xbin/daemonsu
.su (binary) -> /mnt/bin/.ext/.su
recovery.sh -> /mnt/etc/install-recovery.sh
libdummy.so -> /mnt/lib/libdummy.so (extra file, can work without it)
Step 4:
Setting up permissions. Use Terminal, type and press Enter after each line:
Code:
chmod 06755 /mnt/xbin/su
chmod 06755 /mnt/bin/.ext/.su
chmod 0755 /mnt/xbin/daemonsu
chmod 0755 /mnt/etc/install-recovery.sh
chmod 0644 /mnt/app/Superuser.apk
chmod 0644 /mnt/lib/libdummy.so
Step 5:
Setting up SELinux markers (for JB 4.3 onwards). Use Terminal, type and press Enter after each line:
Code:
chown root.root /mnt/app/*
chcon u:object_r:system_file:s0 /mnt/app/*
Step 6:
Rebuilding system partition back into system_new.img.ext4. Use Terminal, type and press Enter
Code:
./ext2simg -v ./system.img.raw ./system_new.img.ext4
Partition size will be automatically adjusted, according to the size of system.img.raw (it takes few minutes to finish)
Now, just copy/paste system_new.img.ext4 to your FW folder - xxxxxxx - and rename it back to system.img.ext4.
Repacking all files back to new_xxxxxxx.tar.md5:
1. Use Terminal and navigate to your FW folder: /pre-rooted/xxxxxxx
2. Packing it all up:
Use Terminal, type and press Enter:
Code:
tar -H ustar -c aboot.mbn boot.img cache.img.ext4 hidden.img.ext4 modem.bin NON-HLOS.bin recovery.img rpm.mbn sbl1.mbn sbl2.mbn sbl3.mbn system.img.ext4 tz.mbn > I9505XXXXXXXX-PRE-ROOTED.tar
this is example of complete FW for GT-I9505, all files (bootloaders, modems, etc..) are listed and included. Check your FW folder for correct list of files from your FW.
3. Generating and adding .md5 checksum:
Use Terminal, type and press Enter after each line:
Code:
md5sum -t I9505XXXXXX-PRE-ROOTED.tar >> I9505XXXXXXX-PRE-ROOTED.tar
mv I9505XXXXXXX-PRE-ROOTED.tar I9505XXXXXXX-PRE-ROOTED.tar.md5
That's it!! All done, you can now use Odin and flash your new, pre-rooted FW.
NOTE: Make sure that you have Original FW on your HDD, just in case if your new FW won't boot up!