[G4 Q&A, Help & Troubleshooting] dominik-p:
[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:

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

if = Input File

of = Output File

bs = Blocksize in bytes (default is 512 - to increase copy speed use multiple of 512 e.g. 8192)

count = how many blocks

skip = skip blocks before start reading

seek = skip blocks before start writing

more info: http://man7.org/linux/man-pages/man1/dd.1.html

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

Instructions:

At first we need to know where the "system" partition starts (first sector) and how big it is (partition size).

I used the first method to find these values. But I recommend the second method because it's easier.

First method (difficult method, extracting the GPT and using "gdisk" in linux to read the partition info)

What you need:

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:

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:

gdisk /yourpath/gpt_backup.img

Some warnings will occur. Ignore them.

You will see:

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:

47 884736 9363455 4.0GiB FFFF system

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

You will see:

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:

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

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

Second method (easier method, just using "adb shell" to read the partition info)

What you need:

adb shell

usb debugging enabled

To get the "logical sector size" use:

cat /sys/block/mmcblk0/queue/logical_block_size

It should be 512

So "first sector" is the value from "cat start" (884736).

The "partiton size" is the value from "cat size" (8478720).

Now the mathematics (using the values from above):

Logical sector size = 512 (I never saw something different on LG G4 smartphones)

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 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:

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:

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 ;)