dimanche 23 août 2015

[How to] determine dd parameters for all LG G4 models



IMPORTANT:
Only for advanced users!
You are an advanced user if you know exactly what you are doing.
You are an advanced user if you know what to do if something went wrong.
You are NOT an advanced user if you know how to do copy+paste.

You can bring your smartphone into a state, so it no longer works.
I am not responsible for anything. The following instructions are only suggestions.



Hello,
everyone knows how to root the LG G4 with the "low effort root" method.
They copied the system partition to an ".img" file, rooted it and copied it back to the "system" partition.
Many users wonder how to get the right parameters for the "dd" commands.
Please read the complete guide and be sure that you understand it until you execute a command!

Information:

Code:


dd if=/inputfile bs=8192 count=12345 of=/outputfile

if = Input File
of = Output File
bs = Blocksize in bytes
count = how many blocks
skip = skip blocks before start reading
seek = skip blocks before start writing


There are different models of the LG G4 on the market.
We know that the system partition is different depending on the model of the G4.
As an example I will show you how to calculate the parameters for the LG G4 H815 (International Model).

What you need:
Windows with Send_Command.exe
Linux with "gdisk" installed

Instructions:
Put your smartphone to "Download Mode" and connect it to the Send_Command.exe command prompt.

We need to copy the partition table to the internal storage.
The partition table of GPT (GUID Partition Table) has a size of 16384 bytes and starts at LBA2.
Each LBA has a size of 512 bytes. Because we start at LBA0 we need to add 1024 bytes.
In summary 16384 + 1024 = 17408 (bytes).

Execute the following command:

Code:


dd if=/dev/block/mmcblk0 bs=1 count=17408 of=/data/media/0/gpt_backup.img

Enter "LEAVE" to restart your phone.

You will find the (very small) file "gpt_backup.img" on your internal storage.
Switch to Linux:
Copy the file to your Linux and open the terminal. Then type this:

Code:


gdisk /yourpath/gpt_backup.img

Some warnings will occur. Ignore them.
You will see:

Code:


Command (? for help):

Enter "p" and hit "enter".
You will get a list of the partitions.
Scroll up a bit and check that you see:
"Logical sector size: 512 bytes"
Scroll down and look for the "system" partition.
You will find a line similar to this:

Code:


47    884736  9363455  4.0GiB  FFFF system

Now you know the number of the "system" partition is "47".

You will see:

Code:


Command (? for help):

Type "i" and hit "enter".
You will be asked the partition number.
Enter it and hit "enter".
You will see something conatining lines similar to this:

Code:


First sector: 884736
Last sector: 9363455
Partition size: 8478720
Partition name: 'system'


We need the values from "First sector" and "Partition size".

Now the mathematics (using the values from above):
Assuming bs=8192
skip and seek: "First sector" * "Logical sector size" / bs
884736 * 512 / 8192 = 55296

count: "Partition size" * "Logical sector size" / bs
8478720 * 512 / 8192 = 529920

That was an example for the H815 (International Model).
Use your own values that you got from "gdisk" to calulate the "dd" parameters!


Back to Windows:
Put your smartphone to "Download Mode" and connect it to the Send_Command.exe command prompt.
Now you can copy your "system" partition to "system.img" with the following command:

Code:


dd if=/dev/block/mmcblk0 bs=8192 skip=55296 count=529920 of=/data/media/0/system.img

Replace the values with the ones you calculated for your model!

Now you could copy the "system.img" to your Linux and root it or do everything else you want.

Important: Do NOT delete the original "system.img" from your internal storage as long as you are not 100% sure your G4 is stable.
If your modifications don't work, you can copy back the original "system" partition (with "dd").


To copy the modified "system_changed.img" back to the "system" partition use the following command:

Code:


dd if=/data/media/0/system_changed.img bs=8192 seek=55296 count=529920 of=/dev/block/mmcblk0

Replace the values with the ones you calculated for your model!

Important: Be sure to use "skip" when reading and "seek" when writing.
The "dd" command should take about a minute.

Did the instructions help you?
Please give a "Thanks!"
Thank you ;)



Aucun commentaire:

Enregistrer un commentaire