Android devices have a couple of partitions to store different data.
The common ones are the recovery, boot, system, data and cache partitions.
Almost every device has it’s own unique layout even though they come from the same manufacturer.
I have seen phones based on
MTD (Memory Technology Device),
EMMC (Embedded MultiMedia Card) and
MMC (MultiMedia Card) devices.
For MTD and EMMC devices, the partition layout and the partition names
can be retrieved by reading the /proc/mtd
and /proc/emmc
files.
cat /proc/mtd
cat /proc/emmc
Below is a layout of the EMMC device (HTC Desire S) layout.
MTD device layouts are similar.
The name
field for each partition gives us an indication of what each partition is being used for.
shell@android:/ # cat /proc/emmc
dev: size erasesize name
mmcblk0p17: "misc"
mmcblk0p21: 0087f400 "recovery"
mmcblk0p22: "boot"
mmcblk0p25: 22dffe00 "system"
mmcblk0p29: 002ffc00 "local"
mmcblk0p27: 090ffe00 "cache"
mmcblk0p26: 496ffe00 "userdata"
mmcblk0p30: 014bfe00 "devlog"
mmcblk0p31: "pdata"
mmcblk0p28: "lib"
If the device is based on MMC, the partition layout can be retrieved from the /proc/partitions
file.
But based on the output below, we are unable to map a name for each partition as it was the case for MTD and EMMC devices.
shell@C6603:/ # cat /proc/partitions
major minor #blocks name
loop0
loop1
mmcblk0
mmcblk0p1
mmcblk0p2
mmcblk0p3
mmcblk0p4
mmcblk0p5
mmcblk0p6
mmcblk0p7
mmcblk0p8
mmcblk0p9
mmcblk0p10
mmcblk0p11
mmcblk0p12
mmcblk0p13
mmcblk0p14
mmcblk0p15
mmcblk0p16
mmcblk0p17
mmcblk0p18
mmcblk0p19
mmcblk0p20
mmcblk0p21
mmcblk0p22
mmcblk0p23
mmcblk0p24
mmcblk0p25
mmcblk0p26
mmcblk1
mmcblk1p1
dm-
dm-
To retrieve the so called names for the MMC device partitions, we will need to look under the /dev/
directory.
shell@C6603:/ $ ls -l /dev/block/platform/msm_sdcc./by-name/
lrwxrwxrwx root root -- : FOTAKernel -> /dev/block/mmcblk0p23
lrwxrwxrwx root root -- : LTALabel -> /dev/block/mmcblk0p16
lrwxrwxrwx root root -- : TA -> /dev/block/mmcblk0p1
lrwxrwxrwx root root -- : aboot -> /dev/block/mmcblk0p6
lrwxrwxrwx root root -- : alt_aboot -> /dev/block/mmcblk0p12
lrwxrwxrwx root root -- : alt_rpm -> /dev/block/mmcblk0p15
lrwxrwxrwx root root -- : alt_s1sbl2 -> /dev/block/mmcblk0p10
lrwxrwxrwx root root -- : alt_sbl1 -> /dev/block/mmcblk0p8
lrwxrwxrwx root root -- : alt_sbl2 -> /dev/block/mmcblk0p9
lrwxrwxrwx root root -- : alt_sbl3 -> /dev/block/mmcblk0p11
lrwxrwxrwx root root -- : alt_tz -> /dev/block/mmcblk0p13
lrwxrwxrwx root root -- : apps_log -> /dev/block/mmcblk0p22
lrwxrwxrwx root root -- : boot -> /dev/block/mmcblk0p17
lrwxrwxrwx root root -- : cache -> /dev/block/mmcblk0p25
lrwxrwxrwx root root -- : m9kefs1 -> /dev/block/mmcblk0p18
lrwxrwxrwx root root -- : m9kefs2 -> /dev/block/mmcblk0p19
lrwxrwxrwx root root -- : m9kefs3 -> /dev/block/mmcblk0p20
lrwxrwxrwx root root -- : ramdump -> /dev/block/mmcblk0p21
lrwxrwxrwx root root -- : rpm -> /dev/block/mmcblk0p14
lrwxrwxrwx root root -- : s1sbl2 -> /dev/block/mmcblk0p4
lrwxrwxrwx root root -- : sbl1 -> /dev/block/mmcblk0p2
lrwxrwxrwx root root -- : sbl2 -> /dev/block/mmcblk0p3
lrwxrwxrwx root root -- : sbl3 -> /dev/block/mmcblk0p5
lrwxrwxrwx root root -- : system -> /dev/block/mmcblk0p24
lrwxrwxrwx root root -- : tz -> /dev/block/mmcblk0p7
lrwxrwxrwx root root -- : userdata -> /dev/block/mmcblk0p26
We can now see that the mmcblk0p24
is actually the system
partition.
If your phone is rooted and if your ROM has the parted
utility, you can use it to get the above information as well.
root@C6603:/ # parted /dev/block/mmcblk0
parted /dev/block/mmcblk0
GNU Parted 1.8.8.1.-aef3
Using /dev/block/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: MMC 016G93 (sd/mmc)
Disk /dev/block/mmcblk0: .8GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt Number Start End Size File system Name Flags
131kB 2228kB 2097kB TA
2228kB 2359kB 131kB sbl1
2359kB 2621kB 262kB sbl2
2621kB 2884kB 262kB s1sbl2
2884kB 3408kB 524kB sbl3
3408kB 3932kB 524kB aboot
3932kB 4456kB 524kB tz
4456kB 4588kB 131kB alt_sbl1
4588kB 4850kB 262kB alt_sbl2
4850kB 5112kB 262kB alt_s1sbl2
5112kB 5636kB 524kB alt_sbl3
5636kB 6160kB 524kB alt_aboot
6160kB 6685kB 524kB alt_tz
6685kB 7209kB 524kB rpm
7209kB 7733kB 524kB alt_rpm
8389kB .2MB .8MB ext4 LTALabel
.2MB .1MB .0MB boot
.1MB .9MB 799kB m9kefs1
.2MB .0MB 799kB m9kefs2
.3MB .1MB 799kB m9kefs3
.1MB .4MB 5243kB ramdump
.4MB .8MB 8389kB ext4 apps_log
.8MB .5MB .8MB FOTAKernel
.8MB 2229MB 2147MB ext4 system
2229MB 2806MB 577MB ext4 cache
2806MB .6GB .8GB ext4 userdata (parted)
Partition names like m9kefs1
and sbl1
may not tell us much about what is inside the partition,
but it gives us some clue to move forward.
If you would like to explore the partition further, you may consider
making a backup of the partition to your SD card using the dd
command
and then perform analysis on the dump.
You can see the partitions known to the system by examining /proc/partitions
. From my HTC desire:
major minor #blocks name mtdblock0
mtdblock1
mtdblock2
mtdblock3
mtdblock4
mtdblock5
mmcblk0
mmcblk0p1
mmcblk0p2
The mtdblock
devices are the phone's internal flash storage. mmcblk0
is the phone's SD card.
The best way to see what is mounted where is to examine
/proc/self/mountinfo
This is better than /proc/mounts
because the latter misses certain information.
Again, on my HTC desire (I added column headings and ran the output through column -s
for good measure):
ID PARENT BLOCK ROOT MOUNTPOINT OPTIONS - TYPE SOURCE SUPEROPTS
: / / ro,relatime - rootfs rootfs ro
: / /dev rw,relatime - tmpfs tmpfs rw,mode=
: / /dev/pts rw,relatime - devpts devpts rw,mode=
: / /proc rw,relatime - proc proc rw
: / /sys rw,relatime - sysfs sysfs rw
: / /acct rw,relatime - cgroup none rw,cpuacct
: / /mnt/asec rw,relatime - tmpfs tmpfs rw,mode=,gid=
: / /mnt/obb rw,relatime - tmpfs tmpfs rw,mode=,gid=
: / /dev/cpuctl rw,relatime - cgroup none rw,cpu
: / /system ro,relatime - yaffs2 /dev/block/mtdblock3 ro
: / /data rw,nosuid,nodev,relatime - yaffs2 /dev/block/mtdblock5 rw
: / /cache rw,nosuid,nodev,relatime - yaffs2 /dev/block/mtdblock4 rw
: /local/download /cache/download rw,nosuid,nodev,relatime - yaffs2 /dev/block/mtdblock5 rw
: / /sd-ext rw,nosuid,nodev,noatime,nodiratime - ext4 /dev/block/mmcblk0p2 rw,commit=,barrier=,data=writeback
: /app /data/app rw,nosuid,nodev,noatime,nodiratime - ext4 /dev/block/mmcblk0p2 rw,commit=,barrier=,data=writeback
: /data /data/data rw,nosuid,nodev,noatime,nodiratime - ext4 /dev/block/mmcblk0p2 rw,commit=,barrier=,data=writeback
: / /sys/kernel/debug rw,relatime - debugfs /sys/kernel/debug rw
: / /mnt/sdcard rw,nosuid,nodev,noexec,relatime - vfat /dev/block/vold/: rw,dirsync,uid=,gid=,fmask=,dmask=,allow_utime=,codepage=cp437,iocharset=iso8859-,shortname=mixed,utf8,errors=remount-ro
: /.android_secure /mnt/secure/asec rw,nosuid,nodev,noexec,relatime - vfat /dev/block/vold/: rw,dirsync,uid=,gid=,fmask=,dmask=,allow_utime=,codepage=cp437,iocharset=iso8859-,shortname=mixed,utf8,errors=remount-ro
: / /mnt/sdcard/.android_secure ro,relatime - tmpfs tmpfs ro,size=0k,mode=
eMMC Partitioning
This is my analysis of the partitioning.
These are the symbolic links I created in a directory containing dumps of each partition
(except the over-large userdata partition which isn't of interest).
The hex values are the number of 512-byte sectors the partition uses.
This is in hex so it is easy to spot it in the partition tables that are in both HBoot and REX.
-dbl-03E8.raw
-oemsbl-.raw
-osbl-.raw
-header_rex_amss.elf
-rex_amss-EA60.elf
-modem_DSP-61A8.raw
-unknown_data-.raw
-unknown-.raw
-unknown-.raw
-unknown-.raw
-unknown-.raw
-unknown-445F.raw
-unknown-.efs
-unknown-.efs
-unknown-.raw
-unknown-45FB.raw
-misc-.raw
-hboot-.raw
-sp1-.raw
-wifi-0A00.raw
-recovery-43FA.raw
-boot-.raw
-mfg-.raw
-sp2-0FFE.raw
-system-116FFF.ext3
-cache-095FFF.ext3
-devlog-A5FF.ext3
-pdata-.raw
The partitioning as seen by the kernel on a T-Mobile G2 with 2.6.32.17-g814e0a1:
cat /proc/partitions
major minor #blocks name loop0
mmcblk0
mmcblk0p1
mmcblk0p2
mmcblk0p3
mmcblk0p4
mmcblk0p5
mmcblk0p6
mmcblk0p7
mmcblk0p8
mmcblk0p9
mmcblk0p10
mmcblk0p11
mmcblk0p12
mmcblk0p13
mmcblk0p14
mmcblk0p15
mmcblk0p16
mmcblk0p17
mmcblk0p18
mmcblk0p19
mmcblk0p20
mmcblk0p21
mmcblk0p22
mmcblk0p23
mmcblk0p24
mmcblk0p25
mmcblk0p26
mmcblk0p27
mmcblk0p28
mmcblk1
mmcblk1p1
dm-
# cat /proc/emmc
dev: size erasesize name
mmcblk0p17: "misc"
mmcblk0p21: 0087f400 "recovery"
mmcblk0p22: "boot"
mmcblk0p25: 19fbfa00 "system"
mmcblk0p27: 0cccce00 "cache"
mmcblk0p26: "userdata"
mmcblk0p28: "devlog"
# busybox fdisk -l mmcblk0 Disk mmcblk0: MB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes Device Boot Start End Blocks Id System
mmcblk0p1 * 4d Unknown
Partition does not end on cylinder boundary
mmcblk0p2 Unknown
Partition does not end on cylinder boundary
mmcblk0p3 Unknown
Partition does not end on cylinder boundary
mmcblk0p4 Extended
Partition does not end on cylinder boundary
mmcblk0p5 Unknown
mmcblk0p6 Unknown
mmcblk0p7 Unknown
mmcblk0p8 Unknown
mmcblk0p9 Unknown
mmcblk0p10 Unknown
mmcblk0p11 Unknown
mmcblk0p12 + Unknown
mmcblk0p13 4a Unknown
mmcblk0p14 4b Unknown
mmcblk0p15 Unknown
mmcblk0p16 + Unknown
mmcblk0p17 Unknown
mmcblk0p18 Unknown
mmcblk0p19 Unknown
mmcblk0p20 Unknown
mmcblk0p21 Unknown
mmcblk0p22 Unknown
mmcblk0p23 Unknown
mmcblk0p24 Unknown
mmcblk0p25 + Linux
mmcblk0p26 + Linux
mmcblk0p27 + Linux
mmcblk0p28 Unknown
And seen differently (note the additional "pdata" partition) on a Desire Z with 2.6.32.21-gd2764ed:
# cat /proc/partitions
major minor #blocks name mmcblk0
mmcblk0p1
mmcblk0p2
mmcblk0p3
mmcblk0p4
mmcblk0p5
mmcblk0p6
mmcblk0p7
mmcblk0p8
mmcblk0p9
mmcblk0p10
mmcblk0p11
mmcblk0p12
mmcblk0p13
mmcblk0p14
mmcblk0p15
mmcblk0p16
mmcblk0p17
mmcblk0p18
mmcblk0p19
mmcblk0p20
mmcblk0p21
mmcblk0p22
mmcblk0p23
mmcblk0p24
mmcblk0p25
mmcblk0p26
mmcblk0p27
mmcblk0p28
mmcblk0p29
mmcblk1
mmcblk1p1
# cat /proc/emmc
dev: size erasesize name
mmcblk0p17: "misc"
mmcblk0p21: 0087f400 "recovery"
mmcblk0p22: "boot"
mmcblk0p25: 22dffe00 "system"
mmcblk0p27: 12bffe00 "cache"
mmcblk0p26: 496ffe00 "userdata"
mmcblk0p28: 014bfe00 "devlog"
mmcblk0p29: "pdata"
# fdisk -ul /dev/block/mmcblk0
Warning: deleting partitions after Disk /dev/block/mmcblk0: MB, bytes
heads, sectors/track, cylinders, total sectors
Units = sectors of * = bytes Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1 * 4d Unknown
Partition does not end on cylinder boundary
/dev/block/mmcblk0p2 Unknown
Partition does not end on cylinder boundary
/dev/block/mmcblk0p3 Unknown
Partition does not end on cylinder boundary
/dev/block/mmcblk0p4 Extended
Partition does not end on cylinder boundary
/dev/block/mmcblk0p5 Unknown
/dev/block/mmcblk0p6 Unknown
/dev/block/mmcblk0p7 Unknown
/dev/block/mmcblk0p8 Unknown
/dev/block/mmcblk0p9 Unknown
/dev/block/mmcblk0p10 Unknown
/dev/block/mmcblk0p11 Unknown
/dev/block/mmcblk0p12 + Unknown
/dev/block/mmcblk0p13 4a Unknown
/dev/block/mmcblk0p14 4b Unknown
/dev/block/mmcblk0p15 Unknown
/dev/block/mmcblk0p16 + Unknown
/dev/block/mmcblk0p17 Unknown
/dev/block/mmcblk0p18 Unknown
/dev/block/mmcblk0p19 Unknown
/dev/block/mmcblk0p20 Unknown
/dev/block/mmcblk0p21 Unknown
/dev/block/mmcblk0p22 Unknown
/dev/block/mmcblk0p23 Unknown
/dev/block/mmcblk0p24 Unknown
/dev/block/mmcblk0p25 + Linux
/dev/block/mmcblk0p26 + Linux
/dev/block/mmcblk0p27 + Linux
/dev/block/mmcblk0p28 + Unknown
/dev/block/mmcblk0p29 Unknown
This dmesg output was captured by Scott Walker (scotty2 a.k.a damnoregonian) on his T-mobile G2 in response to a request from me.
How to find the pathname of the swap partition on SD card?
fdisk -l
works if you pass the whole disk device name explicitly
(e.g., fdisk -l /dev/block/mmcblk1
);
what does not work is automatic discovery of block devices
(apparently because Android places block device files under the /dev/block
directory, but fdisk
expects to see those files directly in /dev
).
Therefore one option is to collect the list of whole disk devices (/dev/block/mmcblk0
, /dev/block/mmcblk1
, …)
and look at their partition tables using fdisk -l <device>
.
These whole disk devices are listed in /proc/partitions
before the corresponding partitions.
The blkid
utility does not look at the partition table at all —
it opens all block devices known by the system and detects the filesystem type from the actual data on those devices;
therefore blkid
will not show correct information for the swap partition until that partition is initialized by mkswap
.
This means that blkid
is useless for your current task (finding which partition should be passed to mkswap
).
mount
usually shows devices under /dev/block/vold
, which are named according to their major and minor numbers.
To get the usual device name, you can look in /proc/partitions
to find a row containing the same numbers in the first two columns.
Then you can remove the p<number>
part from the end of the device name, add /dev/block/
at the start and pass the resulting name to
fdisk -l
to see the partition table of the corresponding device.
Beware that if you look at the fdisk -l
output for the internal eMMC flash, you may find lots of partitions with strange types,
especially on Qualcomm-based devices. E.g., see the partition table for Samsung Galaxy W (GT-I8150):
# fdisk -lu /dev/block/mmcblk0 Disk /dev/block/mmcblk0: MB, bytes
heads, sectors/track, cylinders, total sectors
Units = sectors of * = bytes Device Boot Start End Blocks Id System
/dev/block/mmcblk0p1 + c Win95 FAT32 (LBA)
Partition does not end on cylinder boundary
/dev/block/mmcblk0p2 * 4d Unknown
Partition does not end on cylinder boundary
/dev/block/mmcblk0p3 Unknown
Partition does not end on cylinder boundary
/dev/block/mmcblk0p4 Extended
Partition does not end on cylinder boundary
/dev/block/mmcblk0p5 Unknown
/dev/block/mmcblk0p6 Unknown
/dev/block/mmcblk0p7 Unknown
/dev/block/mmcblk0p8 Unknown
/dev/block/mmcblk0p9 Unknown
/dev/block/mmcblk0p10 4a Unknown
/dev/block/mmcblk0p11 4b Unknown
/dev/block/mmcblk0p12 Unknown
/dev/block/mmcblk0p13 Unknown
/dev/block/mmcblk0p14 Unknown
/dev/block/mmcblk0p15 Unknown
/dev/block/mmcblk0p16 Unknown
/dev/block/mmcblk0p17 Unknown
/dev/block/mmcblk0p18 Unknown
/dev/block/mmcblk0p19 Unknown
/dev/block/mmcblk0p20 Unknown
/dev/block/mmcblk0p21 Unknown
/dev/block/mmcblk0p22 9a Unknown
/dev/block/mmcblk0p23 9b Unknown
/dev/block/mmcblk0p24 9c Unknown
/dev/block/mmcblk0p25 9d Unknown
/dev/block/mmcblk0p26 9e Unknown
/dev/block/mmcblk0p27 9f BSD/OS
/dev/block/mmcblk0p28 a0 Thinkpad hibernation
Partition type codes there are even dangerously wrong, because /dev/block/mmcblk0p1
, which is declared Win95 FAT32 (LBA)
,
actually contains some system data (including locations and MD5 hashes of various ROM parts);
however, /dev/block/mmcblk0p28
, which is the FAT16-formatted “internal data storage”, has a type which looks completely bogus.
In this case the manufacturer did not reuse the 0x82
(Linux swap) type code for their own purposes,
but I'm not sure that such collisions never occur, so you should not blindly try to use any partition which looks like swap
— first check that the device size and partition layout are what you expect to see on your SD card.
/proc/mtd
is never useful for finding a swap partition on SD card
(MTD drivers are used to access directly attached raw flash chips, they cannot work with external SD cards).
How To Gather Information About Partition Layouts
All Android devices use separate partitions for storing different parts of the entire system.
The boot partition consists of the linux kernel,
recovery partition contains the recovery binary,
system partition contains the device's ROM,
data partition contains all user data and cache partition contains some cache data including dalvik-cache.
Partition layout files are used to determine where each specific partition,
used for Android's internal tools and provide the data to tools like Online Nandroid.
The linux kernel reveals this layout in different places at times, but not always.
In some instances, if this layout is not revealed, Online Nandroid uses it's own manually created partition layout file at
/system/partitionlayout4nandroid
Example (/proc/partitions
on a Google Nexus 4):
major minor #blocks name
mmcblk0
mmcblk0p1
mmcblk0p2
mmcblk0p3
mmcblk0p4
mmcblk0p5
mmcblk0p6
mmcblk0p7
mmcblk0p8
mmcblk0p9
mmcblk0p10
mmcblk0p11
mmcblk0p12
mmcblk0p13
mmcblk0p14
mmcblk0p15
mmcblk0p16
mmcblk0p17
mmcblk0p18
mmcblk0p19
mmcblk0p20
mmcblk0p21
mmcblk0p22
mmcblk0p23
mmcblk0p24
mmcblk0p25
MTD Based Devices
MTD (Memory Technology Device) based devices have
/proc/mtd
populated with the partition layout, by the linux kernel.
Thus, no specific partition layout file is required by Online Nandroid, on MTD based devices.
Example (/proc/mtd
on a Sony Ericsson Xperia Pro):
dev: size erasesize name
mtd0: "system"
mtd1: "appslog"
mtd2: "cache"
mtd3: 1a400000 "userdata"
mtd4: 00c80000 "boot"
Note: Some buggy kernels may not populate /proc/mtd
properly.
In most such cases, the underlying MTD partitions would also not be revealed by the kernel,
thus proving a workaround partition layout virtually useless.
EMMC Based Devices
Few EMMC (Embedded MultiMedia Card) based devices have
/proc/emmc
populated with the partition layout, by the linux kernel.
In this case, no specific patch file is required by Online Nandroid.
However, this practice is not followed in later devices. Thus, these require patch files.
A partition layout file is very similar to
/proc/mtd
or
/proc/emmc
generated by linux kernel.
It follows the same format and the same header.
Gathering information to produce a partition layout file is trivial.
It is sometimes revealed somewhere under the /sys/devices
by linux kernel.
But this is not always the case. ROM and kernel developers, would,
most of the time, figure this out and share this information in development threads on forums like XDA.
Other times, it is easiest to obtain a copy of recovery.fstab used by stock, CWM, TWRP and other recoveries.
This file is present in the recovery ramdisk and thus can be obtained from someone who has physical access to the device.
Alternatively, this file is available at device repositories on Github and other places.
A simple search on Google for android_device_oem_device
,
where oem
is the name of device manufacturer such as samsung
, sony
, motorola
, lge
...,
and device
is the code name / technical name of the device such as mako
for Google Nexus 4
and m0
for Samsung Galaxy S III
.
In addition a PIT file or a scatter file for the specific device can also be used for deducing the partition layout.
Example (Partition Layout file on an HTC Sensation XL):
dev: size erasesize name
mmcblk0p1: 0001f4 "unknown"
mmcblk0p2: "unknown"
mmcblk0p3: "unknown"
mmcblk0p4: "unknown"
mmcblk0p5: "unknown"
mmcblk0p6: 0030d4 "unknown"
mmcblk0p7: "unknown"
mmcblk0p8: 000c00 "unknown"
mmcblk0p9: "unknown"
mmcblk0p10: "unknown"
mmcblk0p11: "unknown"
mmcblk0p12: 00222f "unknown"
mmcblk0p13: 000c00 "unknown"
mmcblk0p14: 000c00 "unknown"
mmcblk0p15: "unknown"
mmcblk0p16: 0022fd "unknown"
mmcblk0p17: "unknown"
mmcblk0p18: "unknown"
mmcblk0p19: "unknown"
mmcblk0p20: "unknown"
mmcblk0p21: 0021fd "recovery"
mmcblk0p22: "boot"
mmcblk0p23: "unknown"
mmcblk0p24: 007bff "unknown"
mmcblk0p25: 0fffff "unknown"
mmcblk0p26: 000c00 "unknown"
mmcblk0p27: 000c00 "unknown"
mmcblk0p28: 0067fe "misc"
mmcblk0p29: 407fff "userdata"
mmcblk0p30: 08ffff "cache"
mmcblk0p31: 007eff "unknown"
mmcblk0p32: "unknown"
mmcblk0p33: 8e4ffc "emmc"
MTK Based Devices
On devices based on MTK (MediaTek) chipsets, a file at
/proc/dumchar_info
is populated with the partition layout, by the linux kernel.
This file, however is not similar to /proc/mtd
,/proc/emmc
and partition layout files used by Online Nandroid.
Since MTK devices use the uboot mechanism, partitions including boot and recovery, are not revealed as separate partitions,
but rather accessed sequencially by size and start parameters.
The dumchar_info file has this size and start parameters specified in it.
This file has some other major differences in partition naming such as
the boot partition is named bootimg
instead of boot
,
data partition is named usrdata
instead of userdata
,
system partition is named android
instead of system
and
internal sd card is named fat
instead emmc
.
Online Nandroid (since v8.0) has built-in support for MTK based devices,
thus does not require separate partition layout files on MTK based devices.
Example (/proc/dumchar_info
on a Star N9770 Dual Core - MT6577):
Part_Name Size StartAddr Type MapTo
preloader 0x0000000000040000 0x0000000000000000 /dev/misc-sd
dsp_bl 0x00000000005c0000 0x0000000000040000 /dev/misc-sd
mbr 0x0000000000004000 0x0000000000000000 /dev/block/mmcblk0
ebr1 0x0000000000004000 0x0000000000004000 /dev/block/mmcblk0p1
pmt 0x0000000000400000 0x0000000000008000 /dev/block/mmcblk0
nvram 0x0000000000500000 0x0000000000408000 /dev/block/mmcblk0
seccfg 0x0000000000020000 0x0000000000908000 /dev/block/mmcblk0
uboot 0x0000000000060000 0x0000000000928000 /dev/block/mmcblk0
bootimg 0x0000000000600000 0x0000000000988000 /dev/block/mmcblk0
recovery 0x0000000000600000 0x0000000000f88000 /dev/block/mmcblk0
sec_ro 0x0000000000600000 0x0000000001588000 /dev/block/mmcblk0p2
misc 0x0000000000060000 0x0000000001b88000 /dev/block/mmcblk0
logo 0x0000000000300000 0x0000000001be8000 /dev/block/mmcblk0
expdb 0x0000000000200000 0x0000000001ee8000 /dev/block/mmcblk0
android 0x0000000020100000 0x00000000020e8000 /dev/block/mmcblk0p3
cache 0x0000000020100000 0x00000000221e8000 /dev/block/mmcblk0p4
usrdata 0x0000000020100000 0x00000000422e8000 /dev/block/mmcblk0p5
fat 0x00000000854f8000 0x00000000623e8000 /dev/block/mmcblk0p6
bmtpool 0x0000000001500000 0x00000000ff9f00a8 /dev/block/mmcblk0
Part_Name:Partition name you should open;
Size:size of partition
StartAddr:Start Address of partition;
Type:Type of partition(MTD=,EMMC=)
MapTo:actual device you operate
Find Recovery Partition
I would recommend running the following command as root from terminal emulator:
cat /cache/recovery/last_log
This should tell you which partition is your recovery partition that
you can then dump a copy of the stock recovery.img to your device.
Partition Information:
preloader 0x0000000000040000 0x0000000000000000 /dev/misc-sd
dsp_bl 0x00000000005c0000 0x0000000000040000 /dev/misc-sd
mbr 0x0000000000004000 0x0000000000000000 /dev/block/mmcblk0
ebr1 0x000000000005c000 0x0000000000004000 /dev/block/mmcblk0p1
pmt 0x0000000000400000 0x0000000000060000 /dev/block/mmcblk0
nvram 0x0000000000300000 0x0000000000460000 /dev/block/mmcblk0
seccfg 0x0000000000020000 0x0000000000760000 /dev/block/mmcblk0
uboot 0x0000000000060000 0x0000000000780000 /dev/block/mmcblk0
bootimg 0x0000000000600000 0x00000000007e0000 /dev/block/mmcblk0
recovery 0x0000000000600000 0x0000000000de0000 2 /dev/block/mmcblk0
sec_ro 0x0000000000600000 0x00000000013e0000 /dev/block/mmcblk0p5
misc 0x0000000000060000 0x00000000019e0000 /dev/block/mmcblk0
logo 0x0000000000300000 0x0000000001a40000 /dev/block/mmcblk0
expdb 0x00000000000a0000 0x0000000001d40000 /dev/block/mmcblk0
ebr2 0x0000000000004000 0x0000000001de0000 /dev/block/mmcblk0
android 0x0000000020100000 0x0000000001de4000 /dev/block/mmcblk0p6
cache 0x000000000a100000 0x0000000021ee4000 /dev/block/mmcblk0p2
usrdata 0x0000000041100000 0x000000002bfe4000 /dev/block/mmcblk0p3
fat 0x0000000000000001 0x000000006d0e4000 /dev/block/mmcblk0p4
bmtpool 0x000000007bafbfff 0xffffffffffa00000 /dev/block/mmcblk0 recovery filesystem table
=========================
/tmp ramdisk (null) (null)
/boot emmc boot (null)
/cache ext4 /dev/block/mmcblk0p2 (null)
/data ext4 /dev/block/mmcblk0p3 (null)
/misc emmc misc (null)
/recovery emmc recovery (null)
/sdcard vfat /dev/block/mmcblk1 /dev/block/mmcblk0p4
/sdcard2 vfat /dev/block/mmcblk0p4 (null)
/system ext4 /dev/block/mmcblk0p6 (null)
Very interesting from looking at your partition layout I can see that that /dev/block/mmcblk0 contains your recovery partition.
However it appears /dev/block/mmcblk0 is a combined partition that also contains many critical parts of the phones file system
such u-boot, /boot, and other bootloader related components.
I would recommend running the following commands as root from either ADB shell:
cd /dev/block/platform
Then from the platform directory list the contents of the directory with the "ls" command.
Once you have done that you should see a platform name (Or multiple platform names) for example on my Verizon Galaxy S3 it shows:
msm_sdcc.
msm_sdcc.
Cd into each of the platform directories (Or if there is only one platform directory "cd" into that)
and list the contents of the platform directory using the "ls" command and look to see if it list a directory "by-name".
root@xxxxxxxxx:/dev/block/platform/msm_sdcc.1 # ls
ls
by-name
by-num
mmcblk0
mmcblk0p1
mmcblk0p10
mmcblk0p11
mmcblk0p12
mmcblk0p13
mmcblk0p14
mmcblk0p15
mmcblk0p16
mmcblk0p17
mmcblk0p18
mmcblk0p19
mmcblk0p2
mmcblk0p20
mmcblk0p21
mmcblk0p22
mmcblk0p23
mmcblk0p3
mmcblk0p4
mmcblk0p5
mmcblk0p6
mmcblk0p7
mmcblk0p8
mmcblk0p9
mmcblk0rpmb
If the platform directory your in contains the "by-name" folder run the following command:
ls -l /dev/block/platform/{platform directory name here}/by-name
If that command returns an output take note of the the block number that contains the recovery partition.
root@xxxxxxxxx:/dev/block/platform/msm_sdcc.1 # ls -l /dev/block/platform/msm_sdcc.1/by-name
s -l /dev/block/platform/msm_sdcc./by-name <
lrwxrwxrwx root root -- : DDR -> /dev/block/mmcblk0p8
lrwxrwxrwx root root -- : aboot -> /dev/block/mmcblk0p5
lrwxrwxrwx root root -- : boot -> /dev/block/mmcblk0p9
lrwxrwxrwx root root -- : cache -> /dev/block/mmcblk0p20
lrwxrwxrwx root root -- : dbi -> /dev/block/mmcblk0p3
lrwxrwxrwx root root -- : fsc -> /dev/block/mmcblk0p6
lrwxrwxrwx root root -- : fsg -> /dev/block/mmcblk0p17
lrwxrwxrwx root root -- : misc -> /dev/block/mmcblk0p19
lrwxrwxrwx root root -- : modem -> /dev/block/mmcblk0p1
lrwxrwxrwx root root -- : modemst1 -> /dev/block/mmcblk0p15
lrwxrwxrwx root root -- : modemst2 -> /dev/block/mmcblk0p16
lrwxrwxrwx root root -- : mrd -> /dev/block/mmcblk0p12
lrwxrwxrwx root root -- : pad -> /dev/block/mmcblk0p14
lrwxrwxrwx root root -- : persist -> /dev/block/mmcblk0p18
lrwxrwxrwx root root -- : preload -> /dev/block/mmcblk0p22
lrwxrwxrwx root root 1970-01-25 07:48 recovery -> /dev/block/mmcblk0p10
lrwxrwxrwx root root -- : rpm -> /dev/block/mmcblk0p4
lrwxrwxrwx root root -- : sbl1 -> /dev/block/mmcblk0p2
lrwxrwxrwx root root -- : splash -> /dev/block/mmcblk0p11
lrwxrwxrwx root root -- : ssd -> /dev/block/mmcblk0p7
lrwxrwxrwx root root -- : system -> /dev/block/mmcblk0p21
lrwxrwxrwx root root -- : tz -> /dev/block/mmcblk0p13
lrwxrwxrwx root root -- : userdata -> /dev/block/mmcblk0p23
Another suggestion would be to run the following command to try and isolate the
recovery.img from the larger /dev/block/mmcblk0 contents:
dd if=/dev/block/mmcblk0 of=mnt/sdcard/recovery.img bs= skip= count=
Additionally you could try dumping the whole /dev/block/mmcblk0 partition using the command
cat /dev/block/mmcblk0 > /mnt/sdcard/recovery.img
I dont have a by-name folder but only by-num, which really doesnt help.
So now I will try your second method, extracting a part of the main image!! I'll tell you the result!!!
root@xxxxxxxxx:/dev/block/platform/msm_sdcc. # ls -l /dev/block/platform/msm_sdcc./by-num
s -l /dev/block/platform/msm_sdcc./by-num <
lrwxrwxrwx root root -- : p1 -> /dev/block/mmcblk0p1
lrwxrwxrwx root root -- : p10 -> /dev/block/mmcblk0p10
lrwxrwxrwx root root -- : p11 -> /dev/block/mmcblk0p11
lrwxrwxrwx root root -- : p12 -> /dev/block/mmcblk0p12
lrwxrwxrwx root root -- : p13 -> /dev/block/mmcblk0p13
lrwxrwxrwx root root -- : p14 -> /dev/block/mmcblk0p14
lrwxrwxrwx root root -- : p15 -> /dev/block/mmcblk0p15
lrwxrwxrwx root root -- : p16 -> /dev/block/mmcblk0p16
lrwxrwxrwx root root -- : p17 -> /dev/block/mmcblk0p17
lrwxrwxrwx root root -- : p18 -> /dev/block/mmcblk0p18
lrwxrwxrwx root root -- : p19 -> /dev/block/mmcblk0p19
lrwxrwxrwx root root -- : p2 -> /dev/block/mmcblk0p2
lrwxrwxrwx root root -- : p20 -> /dev/block/mmcblk0p20
lrwxrwxrwx root root -- : p21 -> /dev/block/mmcblk0p21
lrwxrwxrwx root root -- : p22 -> /dev/block/mmcblk0p22
lrwxrwxrwx root root -- : p23 -> /dev/block/mmcblk0p23
lrwxrwxrwx root root -- : p3 -> /dev/block/mmcblk0p3
lrwxrwxrwx root root -- : p4 -> /dev/block/mmcblk0p4
lrwxrwxrwx root root -- : p5 -> /dev/block/mmcblk0p5
lrwxrwxrwx root root -- : p6 -> /dev/block/mmcblk0p6
lrwxrwxrwx root root -- : p7 -> /dev/block/mmcblk0p7
lrwxrwxrwx root root -- : p8 -> /dev/block/mmcblk0p8
lrwxrwxrwx root root -- : p9 -> /dev/block/mmcblk0p9