[GUIDE] Making Dump Files Out of Android Device Partitions

Search This thread

gandolf007

Senior Member
Feb 6, 2011
142
9
hi majdinj

when i want to create dump file of system.img below error occurred!!! whats the problem ? how to solve that ?

dd if=/dev/block/mmcblk0p20 of=/sdcard/system.img
dd if=/dev/block/mmcblk0p20 of=/sdcard/system.img
dd: can't open '/sdcard/system.img':Read-only file system
 

CVAngelo

Senior Member
Mar 24, 2015
1,014
392
Praia
investincv.blogspot.com
hi majdinj

when i want to create dump file of system.img below error occurred!!! whats the problem ? how to solve that ?

dd if=/dev/block/mmcblk0p20 of=/sdcard/system.img
dd if=/dev/block/mmcblk0p20 of=/sdcard/system.img
dd: can't open '/sdcard/system.img':Read-only file system
Is that the internal emulated SD card or the external SD card? Is it mounted as read-write? Can you see any files if you do LS command on it?

Sent from my Nexus 7 using XDA Free mobile app
 

w1nst0n sm1th

Senior Member
Feb 3, 2016
95
30
hi majdinj

when i want to create dump file of system.img below error occurred!!! whats the problem ? how to solve that ?

dd if=/dev/block/mmcblk0p20 of=/sdcard/system.img
dd if=/dev/block/mmcblk0p20 of=/sdcard/system.img
dd: can't open '/sdcard/system.img':Read-only file system

You need to gzip system.img.

Permission can differ according the symlink you use to acces your internal storage. (sdcard is internal starage). Maybe that's the cause of your issue.

Here the command fot internal sdcard :
dd bs=512k conv=sync,noerror if=/dev/block/mmcblk0p20 | gzip -c > /storage/sdcard0/system.img.gz

For the external sdcard :
dd bs=512k conv=sync,noerror if=/dev/block/mmcblk0p20 | gzip -c > /storage/sdcard1/system.img.gz
 

w1nst0n sm1th

Senior Member
Feb 3, 2016
95
30
I have made a dump of the partition data & system as a backup but cannot fastboot the dump file directly to restore my system.

I can mount system.img on linux, which prove the dump is ok...

But i have to transform it in the proper format to fastboot it.

How can i do so ?
 

CVAngelo

Senior Member
Mar 24, 2015
1,014
392
Praia
investincv.blogspot.com
I have made a dump of the partition data & system as a backup but cannot fastboot the dump file directly to restore my system.

I can mount system.img on linux, which prove the dump is ok...

But i have to transform it in the proper format to fastboot it.

How can i do so ?
You can learn how to create a flashable zip which you can put on an SD card and flash via custom recovery. This thread will give you an understanding of the process: http://xdaforums.com/showthread.php?p=52528043

The easiest way to flash the firmware partitions back to the phone is with SP Flash Tool, provided your phone uses the MTK chipset. You can learn how to use SPFT here: https://www.youtube.com/watch?v=LzyYXAflmOk

Sent from my Nexus 7 using XDA Free mobile app
 

w1nst0n sm1th

Senior Member
Feb 3, 2016
95
30
You can learn how to create a flashable zip which you can put on an SD card and flash via custom recovery. This thread will give you an understanding of the process: http://xdaforums.com/showthread.php?p=52528043

The easiest way to flash the firmware partitions back to the phone is with SP Flash Tool, provided your phone uses the MTK chipset. You can learn how to use SPFT here: https://www.youtube.com/watch?v=LzyYXAflmOk

Sent from my Nexus 7 using XDA Free mobile app

Thank for the answer.

I have a intel tablet, and since there is no custom recovery for intel, i can only flah it via fastboot.

I solved the issue with the tool ext2simg which allow to convert raw linux ext4 format to 'regular' (compressed) android ext4 format. Worked like a charm.

It took me several weeks to figure out the process. It seems it is all about zip file and custom recoveries (which are not very standard imo since custom recoveries are per device case scenario).

I have to see if i can do the same with data partition and other partitions.

Now i can start to build and port my custom rom... After i figured out how to handle the make_ext4f tool with selinux file_context and partition size argument.
 
  • Like
Reactions: Tapatalkshshsjbs
G

GuestD0020

Guest
shell@AUSU_T00J: /$ ls ‐al /dev/block/by‐name
ls ‐al /dev/block/by‐name
/dev/block/by‐name: permission denied
i am getting this error "permission denied". my "by-name" folder is present under /dev/block/.
 

CVAngelo

Senior Member
Mar 24, 2015
1,014
392
Praia
investincv.blogspot.com
shell@AUSU_T00J: /$ ls ‐al /dev/block/by‐name
ls ‐al /dev/block/by‐name
/dev/block/by‐name: permission denied
i am getting this error "permission denied". my "by-name" folder is present under /dev/block/.
But you didn't have superuser permission at that point. Is your phone even rooted? If so, you need to enter the following before the ls command:

shell@AUSU_T00J: /$ su

Sent from my Nexus 7 using XDA Free mobile app
 

gza036

Member
Jan 24, 2014
19
1
trying to dump the 12GB userdata partition, dev/block/mmcblk0p26
This phone is stuck in a bootloop and getting I/O errors when I run dd on this partition, so I add conv=sync,noerror
Code:
dd if=/dev/block/mmcblk0p26 of=/storage/sdcard1/userdata.img conv=sync,noerror

it gets past some of the errors (there are just a few at the beginning) but after around 2GB it stops with
Code:
lseek: Value too large for defined data type

I read that^ could have something to do with trying to go over 2GB with a program not compiled for "large file support"

But, I tried to dump the entire 16GB internal memory, mmcblk0
and it makes it to 3.46 GB before it shows that error. I can also successfully dump the full 12GB partition on another working identical phone ( both sprint s5, TWRP recovery v2.8.6.0, android 5.0)
:confused:
 
Last edited:

CVAngelo

Senior Member
Mar 24, 2015
1,014
392
Praia
investincv.blogspot.com
trying to dump the 12GB userdata partition, dev/block/mmcblk0p26
This phone is stuck in a bootloop and getting I/O errors when I run dd on this partition, so I add conv=sync,noerror
Code:
dd if=/dev/block/mmcblk0p26 of=/storage/sdcard1/userdata.img conv=sync,noerror

it gets past some of the errors (there are just a few at the beginning) but after around 2GB it stops with
Code:
lseek: Value too large for defined data type

I read that^ could have something to do with trying to go over 2GB with a program not compiled for "large file support"

But, I tried to dump the entire 16GB internal memory, mmcblk0
and it makes it to 3.46 GB before it shows that error. I can also successfully dump the full 12GB partition on another working identical phone ( both sprint s5, TWRP recovery v2.8.6.0, android 5.0)
:confused:
If your phone is stuck in a bootloop, why not flash a custom recovery (preferably TWRP) with ODIN then backup the data partition that way? Then flash the stock ROM and restore the data. Or maybe I'm being overly simplistic/over optimistic.

But it sounds like your phone has become corrupted since you can backup a working phone but not your own?

Sent from my Nexus 7 using XDA Free mobile app
 
Last edited:
  • Like
Reactions: Wuby986

Wuby986

Senior Member
Oct 18, 2013
2,144
2,440
trying to dump the 12GB userdata partition, dev/block/mmcblk0p26

This phone is stuck in a bootloop and getting I/O errors when I run dd on this partition, so I add conv=sync,noerror

Code:
dd if=/dev/block/mmcblk0p26 of=/storage/sdcard1/userdata.img conv=sync,noerror



it gets past some of the errors (there are just a few at the beginning) but after around 2GB it stops with

Code:
lseek: Value too large for defined data type



I read that^ could have something to do with trying to go over 2GB with a program not compiled for "large file support"



But, I tried to dump the entire 16GB internal memory, mmcblk0

and it makes it to 3.46 GB before it shows that error. I can also successfully dump the full 12GB partition on another working identical phone ( both sprint s5, TWRP recovery v2.8.6.0, android 5.0)

:confused:


you cannot dump it because it will create an image of the same size of your data partition.. so it won't fit at all, never..

you might want to try to zip it.. better chances, but still not for sure.. depends on how much it's used by now..

also you cannot do it on the extsd if it is bigger then 4gb due to ext4 partition limits
 

CVAngelo

Senior Member
Mar 24, 2015
1,014
392
Praia
investincv.blogspot.com
you cannot dump it because it will create an image of the same size of your data partition.. so it won't fit at all, never..

you might want to try to zip it.. better chances, but still not for sure.. depends on how much it's used by now..

also you cannot do it on the extsd if it is bigger then 4gb due to ext4 partition limits
Not understanding your response here. It won't fit where? On his hard disk drive? How come he is able to dump the full 12Gb of his friend's phone?

Sent from my Nexus 7 using XDA Free mobile app
 

Wuby986

Senior Member
Oct 18, 2013
2,144
2,440
Not understanding your response here. It won't fit where? On his hard disk drive? How come he is able to dump the full 12Gb of his friend's phone?

Sent from my Nexus 7 using XDA Free mobile app


he's foing dd to sdcard.. userdata is 12gb and if you use dd the img file will be 12 gb as well because it copies also the blank bits.. so it will never be able to fit in.. using adb shell to do it won't let youcreate it directly to hdd of the as well.. so no chances using dd binary..
correct me if i am wrong [emoji4]
 

gza036

Member
Jan 24, 2014
19
1
he's foing dd to sdcard.. userdata is 12gb and if you use dd the img file will be 12 gb as well because it copies also the blank bits.. so it will never be able to fit in.. using adb shell to do it won't let youcreate it directly to hdd of the as well.. so no chances using dd binary..
correct me if i am wrong [emoji4]

Sorry, I didn't make it clear I was dumping to external MicoSD.

userdata: 12 GB
I'm dumping to microSD: 16GB. it would fit.


(dumping userdata to the internal folder /sdcard doesn't even make sense to me because it's copying the partition to itself???)

you can absolutely dump to hdd. I did it with another working S5.
open one command prompt:
Code:
adb forward tcp:5555 tcp:5555
adb shell
busybox nc -l -p 5555 -e busybox dd if=/dev/block/mmcblk0p26 conv=sync,noerror
in second command prompt:
Code:
adb forward tcp:5555 tcp:5555
nc 127.0.0.1 5555 | pv -i 0.5 > userdata.raw
(needs pipe viewer, netcat, busybox)
the file will transfer to the same location as adb.exe on the PC
it still uses dd so my results are exactly the same either way:
-I/O errors at 133mb
-another I/O error at 2.06GB then process stops with

lseek value too large for defined data type

can we address the problem of why it is giving me lseek value too large for defined data type

---------- Post added at 11:27 AM ---------- Previous post was at 11:21 AM ----------

[/COLOR]
If your phone is stuck in a bootloop, why not flash a custom recovery (preferably TWRP) with ODIN then backup the data partition that way? Then flash the stock ROM and restore the data. Or maybe I'm being overly simplistic/over optimistic.

But it sounds like your phone has become corrupted since you can backup a working phone but not your own?

Sent from my Nexus 7 using XDA Free mobile app

Yes, I am using TWRP... without a custom recovery I couldn't be running adb in recovery. I need the userdata partition to recover some deleted pictures/video, I'm pretty sure flashing the stock ROM will destroy the deleted data.
 
Last edited:
  • Like
Reactions: EarlyMon

Wuby986

Senior Member
Oct 18, 2013
2,144
2,440
Sorry, I didn't make it clear I was dumping to external MicoSD.

userdata: 12 GB
I'm dumping to microSD: 16GB. it would fit.


(dumping userdata to the internal folder /sdcard doesn't even make sense to me because it's copying the partition to itself???)

you can absolutely dump to hdd. I did it with another S5.
open one command prompt:
Code:
adb forward tcp:5555 tcp:5555
adb shell
busybox nc -l -p 5555 -e busybox dd if=/dev/block/mmcblk0p26 conv=sync,noerror

in second command prompt:
Code:
adb forward tcp:5555 tcp:5555
nc 127.0.0.1 5555 | pv -i 0.5 > userdata.raw

can we address the problem of why it is giving me "lseek value too large for defined data type"

---------- Post added at 11:27 AM ---------- Previous post was at 11:21 AM ----------



Yes, I am using TWRP... without a custom recovery I couldn't be running adb. I need the userdata partition to recover some deleted pictures/video, I'm pretty sure flashing the stock ROM will destroy the deleted data.
ok then aparently know more then me... go wild and flash stock.. since android 4.3 flash stock never wipes data ;)

if i am not wrong also on this :D loll
 
  • Like
Reactions: gza036

gza036

Member
Jan 24, 2014
19
1
ok then aparently know more then me... go wild and flash stock.. since android 4.3 flash stock never wipes data ;)

if i am not wrong also on this :D loll

Hmm you sure?:eek: Regardless, I need to dump the userdata partition to do forensics and recover the deleted files. I don't see how flashing stock will help with that
 

Wuby986

Senior Member
Oct 18, 2013
2,144
2,440
Hmm you sure?:eek: Regardless, I need to dump the userdata partition to do forensics and recover the deleted files. I don't see how flashing stock will help with that

i am sure it won't wipe userdata at all! yes.. if you try google it you'll be sure.. never odin flashed a phone?
anyway.. if you try to do that on a booted up phone from terminal you might get more intresting stdout/stderr.

i still am quite sure you cannot do that because it's bigger then 4gb.. which is the max supported for the fat32 fs on the micro sd ( given the sd is formatted this way - before i said ext4 which instead is fine..)so try to see if the sd has this fs and then change it and retry.. the only option i can think of
 
  • Like
Reactions: gza036

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..??