[GUIDE] Making Dump Files Out of Android Device Partitions

Search This thread

a1-kh

New member
Dec 14, 2017
1
0
error

My earlier response clearly said to direct the output file to your C drive.

of=c:/directory/filename.img

Sent from my Nexus 7 using XDA Free mobile app

Hi .. i tried it but gave me this error
root@hero2lte:/ # dd if=/dev/block/sda14 of=c:/system.img
dd: c:/system.img: No such file or directory

i try the other backslash with the error

1|root@hero2lte:/ # dd if=/dev/block/sda14 of=c:\system.img
dd: c:system.img: Read-only file system

any ideas ?
 

stevexce

Senior Member
Dec 21, 2014
96
11
My data block is "sda45"
These commands will give me same files? Or dd creates specific .img file?
Code:
adb pull dev/block/platform/soc/1da4000.ufshc/by-name/userdata  D:\folder
Code:
dd if=/dev/block/sda45 of=D:\folder\userdata.img
 

Varanthan

Member
Feb 21, 2013
5
0
How do I read these dumps? I can create them successfully by gziping, copy them to my desktop, unzip, mount and in Linux Reader I get this message:
TUTTgyn.png
 

dharakv

Senior Member
May 26, 2018
116
6
When I look at a traditional Unix box, in / directory there is bin boot dev etc home mnt media sbin var etc... but these arnt separate partitions. All partitions are in dev/sda1 where a is the hard drive and 1 would be the first partition on it. So theres sda1 2 3 and sdb1 2 3 and so on...

But in android these are all separate partitions am I right?
 

kpirnie

Recognized Contributor
When I look at a traditional Unix box, in / directory there is bin boot dev etc home mnt media sbin var etc... but these arnt separate partitions. All partitions are in dev/sda1 where a is the hard drive and 1 would be the first partition on it. So theres sda1 2 3 and sdb1 2 3 and so on...

But in android these are all separate partitions am I right?
yes
you can drop into adb shell to check by running
blkid
or
mount

to find your partitions.

newer devices you could also do a

ls /dev/block/bootdevice/by-name
 

kpirnie

Recognized Contributor

dharakv

Senior Member
May 26, 2018
116
6
on my phone? no
on my linux box yes

don't forget mate android really is only a java virtual machine running in a linux namespace.

its not linux

---------- Post added at 03:35 AM ---------- Previous post was at 03:33 AM ----------


try
/dev/block

Will try after I root. Thanks

I also found you can do cat /proc/partitions
 

siamak5561

Senior Member
Dec 7, 2012
66
2
Behbahan
How to pull partitions? and for data recovery i need to able to pull partition on computer or external memory, how to address my computer or external memrory
 

lehmancurtis

Senior Member
You need a rooted device, Android sdk, knowledge of adb and fastboot, and a computer.

Code:
 $ adb shell
$ if=/device/block/by-name/boot of=/storage/sdcard/boot.img
$ exit
$adb pull /storage/sdcard/boot.img .\path\to\fastboot-folder-windows\

This is example of creating the pulling a boot.img from a Qualcomm device. You may have to adjust the paths depending on your device.
 
Last edited:
  • Like
Reactions: siamak5561

siamak5561

Senior Member
Dec 7, 2012
66
2
Behbahan
You need a rooted device, Android sdk, knowledge of adb and fastboot, and a computer.

Code:
 $ adb shell
$ if=/device/block/by-name/boot of=/storage/sdcard/boot.img
$ exit
$adb pull /storage/sdcard/boot.img .\path\to\fastboot-folder-windows\
This is example of creating the pulling a boot.img from a Qualcomm device. You may have to adjust the paths depending on your device.


Thanks but For Data recovery I need to Directly copy userdata partition to my hard drive, with cable or wifi, is there any way?
 
  • Like
Reactions: Sands207

davidbiate

New member
Dec 2, 2018
2
0
"Don't forget to "quit" the parted action after grasping your device mounting points"

Sorry just a Noob question...how do we quit parted?
 

Johnn78

Senior Member
Apr 19, 2016
463
54
Instead the command "of=/sdcard/system.img", can be the destination path be within from my pc ? Because I want to dump the whole user data partition which is all the internal memory size & can't be saved due to capacity in the phone memory.
 
  • Like
Reactions: aenews

koivth

Senior Member
Dec 5, 2014
52
13
Instead the command "of=/sdcard/system.img", can be the destination path be within from my pc ? Because I want to dump the whole user data partition which is all the internal memory size & can't be saved due to capacity in the phone memory.

I'm not very good at this stuff so sorry for not really answering your question with another question. However,

If you create a script to run the dd commands and push that script to your device, could you have the output of dd saved to an external storage connected via OTG? That way you don't have the space limitations of your internal storage if you can connect a USB or similar to your phone via OTG.
 

youmbi

Senior Member
Jun 16, 2018
62
5
System.img

Use:
The main purpose is to make a file that contains all data in android specific partition. This is really handy in case of dumping leak firmwares.


Pr-requirement:
- Rooted device.
- Knowledge of how to use adb or Terminal Emulator.

The first step of making dump files out of device partitions is to locate its mounting points..!!
So in our tutorial, we will make it in 2 sections. Section 1 for how to get mounting points, and section 2 for how to get partition dumped..
Keep in mind that this is xda-university; so my target is to show beginners how to do that manually, without the aid of any tool, so they can get the concept behind it.. OK let's begin..!!

Section 1:
Getting mounting points
There are several methods to achieve this, but we will discuss the easiest methods that give efficient information about the partition that you want to know its mounting point.
All these methods will be described using adb shell.

Way #1
Code:
adb shell
cat /proc/partitions
This one needs from you to figure out which block belong to which partition name.!!

2ds4ujd.png


Way #2
Code:
adb shell
ls -al /dev/block/platform/[B][COLOR="Blue"]dw_mmc[/COLOR][/B]/by-name
This one will give you info about the dev block names WITH their familiar names (i.e, boot, recovery, system... etc)

rsg20h.png

This command is not universal between devices, and you will need to gather its pieces (/dev/block/platform/dw_mmc/by-name).
How?
- In your device, use any explorer that can get you to the device root (personally I use ES Explorer, by pressing on "/" on navigation bar).
- Go to "/dev/block/platform/" folder
- Here you will see some files and folders, we need to open folders and search for the folder called "by-name" inside one of them; in my situation it was "dw_mmc" folder which has the folder "by-name" inside it.
- At the end, my targeted piece info will be (/dev/block/platform/dw_mmc/by-name)
- Now open adb shell and put that command..


Way #3
By pushing parted binary to /system/bin folder and run it (you can find it in attachment).
Code:
adb remount
adb shell "su" "" "mount -o remount,rw /system"
adb push parted /system/bin/parted
adb shell
chmod 0755 /system/bin/parted
parted /dev/block/[B][COLOR="Blue"]mmcblk0[/COLOR][/B]
print

11t5x7c.png

Here, your mounting points will start with /dev/block/mmcblk0p* where (*) is the number shown in the table above for each partition.
example:
The hidden partition mounting point will be mmcblk0p10
The radio partition mounting point will be mmcblk0p7
The system partition mounting point will be mmcblk0p9
The recovery partition mounting point will be mmcblk0p6

and so on

Don't forget to "quit" the parted action after grasping your device mounting points.

N.B:
- You may need to run first:
Code:
adb shell
cat /proc/partitions
to know what is the initial name for your device partition.. In the example above, it was mmcblk0.

wbaufd.png

- Also to be able to do adb push to /system partition for parted binary, you will need insecure boot.img used in your ROM or adbd insecure installed in your device (Check this thread for that app), or just push parted binary manually by any root explorer and then fix permissions to rwxr-xr-x (755).

***​

Section 2:
Dumping ROM partition
After locating the mounting point of the partition you want to dump, open adb shell command prompt and type:
Code:
adb shell
su
dd if=[B][COLOR="Blue"]/yourMountingPoint[/COLOR][/B] of=[B][COLOR="Green"]/yourDestination[/COLOR][COLOR="Red"]/partitionType[/COLOR][/B]
Let's say I want to take a dump out of system partition from above example. So the adb commands will be:
Code:
adb shell
su
dd if=[B][COLOR="Blue"]/dev/block/mmcblk0p9[/COLOR][/B] of=[B][COLOR="Green"]/sdcard[/COLOR][COLOR="Red"]/system.img[/COLOR][/B]
This may take a while to complete the dumping process, depending on the size of your dumped partition; so be patient..

Note:
If the partition is formatted as ext3/4 then the dumped partition will have .img as an extension.
Other partition dumps have different extensions; examples:
  • radio.bin
  • param.lfs
  • Sbl.bin
  • zImage (without extension)

***​

Optional:
Read Partition Image
After dumping an image from android partition, you can mount it to extract a particular file for sharing, or the whole dump content in case the ROM chief wants to make a ROM out of dump files..
For Linux Users:
- Open terminal and type:
Code:
su -
mkdir -p /mnt/disk
mount -o loop [B][COLOR="Red"]yourImage.img[/COLOR][/B] /mnt/disk
cd /mnt/disk
ls -l

For Windows Users:
- Download LinuxReader from this site here.
- Open it -> Drives -> Mount Image -> Then choose your dumped image and hit Mount. A new driver will appear that contains all files inside the dumped image called "Linux native Volume 1". Just double click it to get inside the dumped image.

2roj2f4.png


2dhbhxd.png


I hope you will find this tutorial beneficial,,,
Yours;


Hi brother thank you so much for this tutorial
Please any solution for unpack and repack Oreo system.img with original signature?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 353
    Use:
    The main purpose is to make a file that contains all data in android specific partition. This is really handy in case of dumping leak firmwares.


    Pr-requirement:
    - Rooted device.
    - Knowledge of how to use adb or Terminal Emulator.

    The first step of making dump files out of device partitions is to locate its mounting points..!!
    So in our tutorial, we will make it in 2 sections. Section 1 for how to get mounting points, and section 2 for how to get partition dumped..
    Keep in mind that this is xda-university; so my target is to show beginners how to do that manually, without the aid of any tool, so they can get the concept behind it.. OK let's begin..!!

    Section 1:
    Getting mounting points
    There are several methods to achieve this, but we will discuss the easiest methods that give efficient information about the partition that you want to know its mounting point.
    All these methods will be described using adb shell.

    Way #1
    Code:
    adb shell
    cat /proc/partitions
    This one needs from you to figure out which block belong to which partition name.!!

    2ds4ujd.png


    Way #2
    Code:
    adb shell
    ls -al /dev/block/platform/[B][COLOR="Blue"]dw_mmc[/COLOR][/B]/by-name
    This one will give you info about the dev block names WITH their familiar names (i.e, boot, recovery, system... etc)

    rsg20h.png

    This command is not universal between devices, and you will need to gather its pieces (/dev/block/platform/dw_mmc/by-name).
    How?
    - In your device, use any explorer that can get you to the device root (personally I use ES Explorer, by pressing on "/" on navigation bar).
    - Go to "/dev/block/platform/" folder
    - Here you will see some files and folders, we need to open folders and search for the folder called "by-name" inside one of them; in my situation it was "dw_mmc" folder which has the folder "by-name" inside it.
    - At the end, my targeted piece info will be (/dev/block/platform/dw_mmc/by-name)
    - Now open adb shell and put that command..


    Way #3
    By pushing parted binary to /system/bin folder and run it (you can find it in attachment).
    Code:
    adb remount
    adb shell "su" "" "mount -o remount,rw /system"
    adb push parted /system/bin/parted
    adb shell
    chmod 0755 /system/bin/parted
    parted /dev/block/[B][COLOR="Blue"]mmcblk0[/COLOR][/B]
    print

    11t5x7c.png

    Here, your mounting points will start with /dev/block/mmcblk0p* where (*) is the number shown in the table above for each partition.
    example:
    The hidden partition mounting point will be mmcblk0p10
    The radio partition mounting point will be mmcblk0p7
    The system partition mounting point will be mmcblk0p9
    The recovery partition mounting point will be mmcblk0p6

    and so on

    Don't forget to "quit" the parted action after grasping your device mounting points.

    N.B:
    - You may need to run first:
    Code:
    adb shell
    cat /proc/partitions
    to know what is the initial name for your device partition.. In the example above, it was mmcblk0.

    wbaufd.png

    - Also to be able to do adb push to /system partition for parted binary, you will need insecure boot.img used in your ROM or adbd insecure installed in your device (Check this thread for that app), or just push parted binary manually by any root explorer and then fix permissions to rwxr-xr-x (755).

    ***​

    Section 2:
    Dumping ROM partition
    After locating the mounting point of the partition you want to dump, open adb shell command prompt and type:
    Code:
    adb shell
    su
    dd if=[B][COLOR="Blue"]/yourMountingPoint[/COLOR][/B] of=[B][COLOR="Green"]/yourDestination[/COLOR][COLOR="Red"]/partitionType[/COLOR][/B]
    Let's say I want to take a dump out of system partition from above example. So the adb commands will be:
    Code:
    adb shell
    su
    dd if=[B][COLOR="Blue"]/dev/block/mmcblk0p9[/COLOR][/B] of=[B][COLOR="Green"]/sdcard[/COLOR][COLOR="Red"]/system.img[/COLOR][/B]
    This may take a while to complete the dumping process, depending on the size of your dumped partition; so be patient..

    Note:
    If the partition is formatted as ext3/4 then the dumped partition will have .img as an extension.
    Other partition dumps have different extensions; examples:
    • radio.bin
    • param.lfs
    • Sbl.bin
    • zImage (without extension)

    ***​

    Optional:
    Read Partition Image
    After dumping an image from android partition, you can mount it to extract a particular file for sharing, or the whole dump content in case the ROM chief wants to make a ROM out of dump files..
    For Linux Users:
    - Open terminal and type:
    Code:
    su -
    mkdir -p /mnt/disk
    mount -o loop [B][COLOR="Red"]yourImage.img[/COLOR][/B] /mnt/disk
    cd /mnt/disk
    ls -l

    For Windows Users:
    - Download LinuxReader from this site here.
    - Open it -> Drives -> Mount Image -> Then choose your dumped image and hit Mount. A new driver will appear that contains all files inside the dumped image called "Linux native Volume 1". Just double click it to get inside the dumped image.

    2roj2f4.png


    2dhbhxd.png


    I hope you will find this tutorial beneficial,,,
    Yours;

    115
    Actions Explanation

    ★ Tutorial Legends ★

    In this post, I will try to explain the use of each binary used in the tutorial, so you can make sense of each action taken.

    #1
    Code:
    adb shell
    Run remote shell interactively, as if you are in linux terminal.

    #2
    Code:
    cat /proc/partitions
    cat binary is used to concatenate file(s) and print them to standard output display. In our example, it prints the content of partitions file which is found in proc folder to screen display.

    #3
    Code:
    ls -al /dev/block/platform/dw_mmc/by-name
    ls binary is used to list directory contents.
    -al is the used option for ls which means to include entries that started with "." in long listing format. There are a lot of options for ls binary. You can always print ls --h to display help menu for other options available.

    #4
    Code:
    adb remount
    Remounts the /system partition on the device read / write. This has been disabled in some devices (those with secure boot image); so you need to make sure that you have patched adbd that can run this command effectively.

    #5
    Code:
    su
    Used to get super-user privilege.


    #6
    Code:
    mount -o remount,[B][COLOR="Red"]rw[/COLOR][/B] /system
    Specific command to mount the /system partition on the device read / write (rw).
    If you change rw to ro, you will get /system partition mounted as read only.

    #7
    Code:
    adb push parted /system/bin/parted
    adb push is used to copy file/dir from your local computer to android device. The usual format is adb push <local> <remote>

    #8
    Code:
    chmod 0755 /system/bin/parted
    chmod binary is used to set permissions for the specified file/dir.
    The number after chmod is the permission used. See the next box for better understanding of chmod formatting:
    Code:
    [CENTER][B][COLOR="Red"]----------------
    | CHMOD SCHEME |
    ----------------[/COLOR][/B][/CENTER]
              [B] r     w     x[/B]
               [B]4     2     1    [COLOR="Green"]= 7 (Full Permissions)[/COLOR][/B]
    
      User    ( )   ( )   ( )   [B][COLOR="Green"]--> 2nd digit[/COLOR][/B]
      Group   ( )   ( )   ( )   [B][COLOR="Green"]--> 3rd digit[/COLOR][/B]
      Other   ( )   ( )   ( )   [B][COLOR="Green"]--> 4th digit[/COLOR][/B]
    
      Special UID   GID   STK
              ( )   ( )   ( )   [B][COLOR="Green"]--> 1st digit, ignored on most cases or put 0[/COLOR][/B]
    In the above example, it is set to 0755 which means the following scheme:
    Code:
              [B] r     w     x[/B]
               [B]4     2     1[/B]
    
      User    ([B][COLOR="Red"]*[/COLOR][/B])   ([B][COLOR="Red"]*[/COLOR][/B])   ([B][COLOR="Red"]*[/COLOR][/B])   [B][COLOR="Green"]--> This equals to 7 (rwx)[/COLOR][/B]
      Group   ([B][COLOR="Red"]*[/COLOR][/B])   ( )   ([B][COLOR="Red"]*[/COLOR][/B])   [B][COLOR="Green"]--> This equals to 5 (r-x)[/COLOR][/B]
      Other   ([B][COLOR="Red"]*[/COLOR][/B])   ( )   ([B][COLOR="Red"]*[/COLOR][/B])   [B][COLOR="Green"]--> This equals to 5 (r-x)[/COLOR][/B]
    
      Special UID   GID   STK
              ( )   ( )   ( )   [B][COLOR="Green"]--> This equals to 0 (---)[/COLOR][/B]
    As you can see, if you said 0755, it will be as same as saying ---rwxr-xr-x

    #9
    Code:
    dd if=/dev/block/mmcblk0p9 of=/sdcard/system.img
    dd binary is used to copy a file with converting and formatting.
    if means input file; here we pointed to the whole partition, not specific file.
    of means outputting file to specific destination path; here it is to sdcard with system.img name.

    #10
    Code:
    mkdir -p /mnt/disk
    mkdir binary is used to make folder dir.
    -p is mkdir option which means to create folder with sub-folder at the same time. Here we want to create mnt folder that contains disk sub-folder in it. If the folder and or sub-folder(s) are already exists, it will not give error but nothing will be created.

    #11
    Code:
    mount -o loop yourImage.img /mnt/disk
    This is linux way to mount images into specific directory (/mnt/disk in this example).

    #12
    Code:
    cd /mnt/disk
    cd used to get inside specific dir path.

    #13
    Code:
    ls -l
    ls binary is used to list directory contents as described above.
    -l is the used option for ls which means to list contents in long listing format.


    Cheers
    11
    another way to get common names

    on way #2, I've often used:
    Code:
    cat /proc/emmc
    on a few devices to reveal similar info.

    Rob
    5
    can i able to mount boot.img in android itself...actually i wanted to extract boot.img frm mobile without any tools or without the help of PC...if there be any possibilities..??

    if you mean extract to modify boot.img, then I don't think there is away to do that from device itself in the moment..
    if you mean dumping boot.img then yes you can, just install terminal emulator from Google play and you can run adb shell commands directly from the device
    4
    can i able to mount boot.img in android itself...actually i wanted to extract boot.img frm mobile without any tools or without the help of PC...if there be any possibilities..??