Download all partitions from user space / normal mode using ADB

It is always important to have a complete copy of your partitions available, so that you can reinstall everything in case of deep damage to the device at the software level. Also in this case it is sufficient to use commands with the root shell in user space/normal mode. We can rely on just two commands: adb pull and adb shell dd.

Qualcomm vs Spreadtrum

Using these commands we must be careful to distinguish the directory structure in a KaiOS system installed on one chipset compared to another chipset:

  • Qualcomm and Mediatek are quite similar, their structure should be always "/dev/block/bootdevice/by-name";

  • Spreadtrum-based models have are structured like this, "/dev/block/platform/soc/by-name".

If you're not sure of what is your directory structure, just use the "ls" command to explore the structure of your phone (learn more).

In this guide I will use the common path of Qualcomm based KaiOS phones, stick to the above rule if you use different chipsets.

Backup using "adb pull"

Using a temporary root access you can download all the dumps with the command:

  • adb pull /dev/block/bootdevice/by-name (this should work for Qualcomm-based models)

  • adb pull /dev/block/platform/soc/by-name (on Spreadtrum-based models)

will be saved a folder named "by-name" containing all the binary images of our dumps.

In this way we know more aboute the nature of our partitions (images, binary, executables or archives).

We can also set the command in this way, to pull only one of our PARTITION:

  • adb pull /dev/block/bootdevice/by-name/PARTITION

For example

  • adb pull /dev/block/bootdevice/by-name/system

  • adb pull /dev/block/bootdevice/by-name/recovery

  • adb pull /dev/block/bootdevice/by-name/userdata

and so on...

  • Using the command (for Qualcomm-based phones):

adb pull /dev/block/mmcblk0 mmcblk0.img

We will download all as one disk image file, because mmcblk0 is the main block (mmcblk0.img). By mounting it we can better understand how is done the partition table. From this command I started thinking about using "pull" with the usual paths we read in tools like (a portatile solution that works without the PC).

Backup using "adb shell dd"

  • On Qualcomm-based phones, to create a backup image of the partition on the sd card, run the following command from a root shell:

dd if=/dev/block/bootdevice/by-name/PARTITION of=/sdcard/PARTITION.img bs=2048

  • On Spreadtrum-based phones the command will be:

dd if=/dev/block/platform/soc/by-name/PARTITION of=/sdcard/PARTITION.img bs=2048

Where PARTITION is the name of the partition whe want to save. The next examples are applied on a Qualcomm device. If we want do a backup of system is sufficient to do:

dd if=/dev/block/bootdevice/by-name/system of=/sdcard/system.img bs=2048

For the data partition it changes to:

dd if=/dev/block/bootdevice/by-name/userdata of=/sdcard/userdata.img bs=2048

for the recovery is:

dd if=/dev/block/bootdevice/by-name/recovery of=/sdcard/recovery.img bs=2048

for the firmware (boot) is:

dd if=/dev/block/bootdevice/by-name/boot of=/sdcard/boot.img bs=2048

and so on. This is safe and you can do this from the normal boot.

See also...