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: 00040000 00000200 "misc" mmcblk0p21: 0087f400 00000200 "recovery" mmcblk0p22: 00400000 00000200 "boot" mmcblk0p25: 22dffe00 00000200 "system" mmcblk0p29: 002ffc00 00000200 "local" mmcblk0p27: 090ffe00 00000200 "cache" mmcblk0p26: 496ffe00 00000200 "userdata" mmcblk0p30: 014bfe00 00000200 "devlog" mmcblk0p31: 00040000 00000200 "pdata" mmcblk0p28: 09800000 00000200 "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 7 0 12506 loop0 7 1 2111 loop1 179 0 15388672 mmcblk0 179 1 2048 mmcblk0p1 179 2 128 mmcblk0p2 179 3 256 mmcblk0p3 179 4 256 mmcblk0p4 179 5 512 mmcblk0p5 179 6 512 mmcblk0p6 179 7 512 mmcblk0p7 179 8 128 mmcblk0p8 179 9 256 mmcblk0p9 179 10 256 mmcblk0p10 179 11 512 mmcblk0p11 179 12 512 mmcblk0p12 179 13 512 mmcblk0p13 179 14 512 mmcblk0p14 179 15 512 mmcblk0p15 179 16 16384 mmcblk0p16 179 17 20480 mmcblk0p17 179 18 780 mmcblk0p18 179 19 780 mmcblk0p19 179 20 780 mmcblk0p20 179 21 5120 mmcblk0p21 179 22 8192 mmcblk0p22 179 23 16384 mmcblk0p23 179 24 2097152 mmcblk0p24 179 25 563200 mmcblk0p25 179 26 12527599 mmcblk0p26 179 32 31166976 mmcblk1 179 33 31162880 mmcblk1p1 254 0 12505 dm-0 254 1 2110 dm-1
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.1/by-name/ lrwxrwxrwx root root 2014-02-09 11:27 FOTAKernel -> /dev/block/mmcblk0p23 lrwxrwxrwx root root 2014-02-09 11:27 LTALabel -> /dev/block/mmcblk0p16 lrwxrwxrwx root root 2014-02-09 11:27 TA -> /dev/block/mmcblk0p1 lrwxrwxrwx root root 2014-02-09 11:27 aboot -> /dev/block/mmcblk0p6 lrwxrwxrwx root root 2014-02-09 11:27 alt_aboot -> /dev/block/mmcblk0p12 lrwxrwxrwx root root 2014-02-09 11:27 alt_rpm -> /dev/block/mmcblk0p15 lrwxrwxrwx root root 2014-02-09 11:27 alt_s1sbl2 -> /dev/block/mmcblk0p10 lrwxrwxrwx root root 2014-02-09 11:27 alt_sbl1 -> /dev/block/mmcblk0p8 lrwxrwxrwx root root 2014-02-09 11:27 alt_sbl2 -> /dev/block/mmcblk0p9 lrwxrwxrwx root root 2014-02-09 11:27 alt_sbl3 -> /dev/block/mmcblk0p11 lrwxrwxrwx root root 2014-02-09 11:27 alt_tz -> /dev/block/mmcblk0p13 lrwxrwxrwx root root 2014-02-09 11:27 apps_log -> /dev/block/mmcblk0p22 lrwxrwxrwx root root 2014-02-09 11:27 boot -> /dev/block/mmcblk0p17 lrwxrwxrwx root root 2014-02-09 11:27 cache -> /dev/block/mmcblk0p25 lrwxrwxrwx root root 2014-02-09 11:27 m9kefs1 -> /dev/block/mmcblk0p18 lrwxrwxrwx root root 2014-02-09 11:27 m9kefs2 -> /dev/block/mmcblk0p19 lrwxrwxrwx root root 2014-02-09 11:27 m9kefs3 -> /dev/block/mmcblk0p20 lrwxrwxrwx root root 2014-02-09 11:27 ramdump -> /dev/block/mmcblk0p21 lrwxrwxrwx root root 2014-02-09 11:27 rpm -> /dev/block/mmcblk0p14 lrwxrwxrwx root root 2014-02-09 11:27 s1sbl2 -> /dev/block/mmcblk0p4 lrwxrwxrwx root root 2014-02-09 11:27 sbl1 -> /dev/block/mmcblk0p2 lrwxrwxrwx root root 2014-02-09 11:27 sbl2 -> /dev/block/mmcblk0p3 lrwxrwxrwx root root 2014-02-09 11:27 sbl3 -> /dev/block/mmcblk0p5 lrwxrwxrwx root root 2014-02-09 11:27 system -> /dev/block/mmcblk0p24 lrwxrwxrwx root root 2014-02-09 11:27 tz -> /dev/block/mmcblk0p7 lrwxrwxrwx root root 2014-02-09 11:27 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.179-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: 15.8GB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 131kB 2228kB 2097kB TA 2 2228kB 2359kB 131kB sbl1 3 2359kB 2621kB 262kB sbl2 4 2621kB 2884kB 262kB s1sbl2 5 2884kB 3408kB 524kB sbl3 6 3408kB 3932kB 524kB aboot 7 3932kB 4456kB 524kB tz 8 4456kB 4588kB 131kB alt_sbl1 9 4588kB 4850kB 262kB alt_sbl2 10 4850kB 5112kB 262kB alt_s1sbl2 11 5112kB 5636kB 524kB alt_sbl3 12 5636kB 6160kB 524kB alt_aboot 13 6160kB 6685kB 524kB alt_tz 14 6685kB 7209kB 524kB rpm 15 7209kB 7733kB 524kB alt_rpm 16 8389kB 25.2MB 16.8MB ext4 LTALabel 17 25.2MB 46.1MB 21.0MB boot 18 46.1MB 46.9MB 799kB m9kefs1 19 48.2MB 49.0MB 799kB m9kefs2 20 50.3MB 51.1MB 799kB m9kefs3 21 51.1MB 56.4MB 5243kB ramdump 22 56.4MB 64.8MB 8389kB ext4 apps_log 23 64.8MB 81.5MB 16.8MB FOTAKernel 24 81.8MB 2229MB 2147MB ext4 system 25 2229MB 2806MB 577MB ext4 cache 26 2806MB 15.6GB 12.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 31 0 640 mtdblock0 31 1 4608 mtdblock1 31 2 3072 mtdblock2 31 3 256000 mtdblock3 31 4 40960 mtdblock4 31 5 151168 mtdblock5 179 0 3872256 mmcblk0 179 1 2872070 mmcblk0p1 179 2 1000185 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 1 1 0:1 / / ro,relatime - rootfs rootfs ro 11 1 0:11 / /dev rw,relatime - tmpfs tmpfs rw,mode=755 12 11 0:9 / /dev/pts rw,relatime - devpts devpts rw,mode=600 13 1 0:3 / /proc rw,relatime - proc proc rw 14 1 0:12 / /sys rw,relatime - sysfs sysfs rw 15 1 0:13 / /acct rw,relatime - cgroup none rw,cpuacct 16 1 0:14 / /mnt/asec rw,relatime - tmpfs tmpfs rw,mode=755,gid=1000 17 1 0:15 / /mnt/obb rw,relatime - tmpfs tmpfs rw,mode=755,gid=1000 18 11 0:16 / /dev/cpuctl rw,relatime - cgroup none rw,cpu 19 1 31:3 / /system ro,relatime - yaffs2 /dev/block/mtdblock3 ro 20 1 31:5 / /data rw,nosuid,nodev,relatime - yaffs2 /dev/block/mtdblock5 rw 21 1 31:4 / /cache rw,nosuid,nodev,relatime - yaffs2 /dev/block/mtdblock4 rw 22 21 31:5 /local/download /cache/download rw,nosuid,nodev,relatime - yaffs2 /dev/block/mtdblock5 rw 23 1 179:2 / /sd-ext rw,nosuid,nodev,noatime,nodiratime - ext4 /dev/block/mmcblk0p2 rw,commit=19,barrier=0,data=writeback 24 20 179:2 /app /data/app rw,nosuid,nodev,noatime,nodiratime - ext4 /dev/block/mmcblk0p2 rw,commit=19,barrier=0,data=writeback 25 20 179:2 /data /data/data rw,nosuid,nodev,noatime,nodiratime - ext4 /dev/block/mmcblk0p2 rw,commit=19,barrier=0,data=writeback 26 14 0:6 / /sys/kernel/debug rw,relatime - debugfs /sys/kernel/debug rw 27 1 179:1 / /mnt/sdcard rw,nosuid,nodev,noexec,relatime - vfat /dev/block/vold/179:1 rw,dirsync,uid=1000,gid=1015,fmask=0602,dmask=0602,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 28 1 179:1 /.android_secure /mnt/secure/asec rw,nosuid,nodev,noexec,relatime - vfat /dev/block/vold/179:1 rw,dirsync,uid=1000,gid=1015,fmask=0602,dmask=0602,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 29 27 0:17 / /mnt/sdcard/.android_secure ro,relatime - tmpfs tmpfs ro,size=0k,mode=000
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.
01-dbl-03E8.raw 02-oemsbl-0080.raw 03-osbl-2328.raw 04-header_rex_amss.elf 05-rex_amss-EA60.elf 06-modem_DSP-61A8.raw 07-unknown_data-1000.raw 08-unknown-1800.raw 09-unknown-1000.raw 10-unknown-0800.raw 11-unknown-0800.raw 12-unknown-445F.raw 13-unknown-1800.efs 14-unknown-1800.efs 15-unknown-0800.raw 16-unknown-45FB.raw 17-misc-0200.raw 18-hboot-0800.raw 19-sp1-0800.raw 20-wifi-0A00.raw 21-recovery-43FA.raw 22-boot-2000.raw 23-mfg-0200.raw 24-sp2-0FFE.raw 25-system-116FFF.ext3 27-cache-095FFF.ext3 28-devlog-A5FF.ext3 29-pdata-0200.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 7 0 14585 loop0 179 0 2203648 mmcblk0 179 1 500 mmcblk0p1 179 2 64 mmcblk0p2 179 3 4500 mmcblk0p3 179 4 1 mmcblk0p4 179 5 30000 mmcblk0p5 179 6 12500 mmcblk0p6 179 7 2048 mmcblk0p7 179 8 3072 mmcblk0p8 179 9 2048 mmcblk0p9 179 10 1024 mmcblk0p10 179 11 1024 mmcblk0p11 179 12 8751 mmcblk0p12 179 13 3072 mmcblk0p13 179 14 3072 mmcblk0p14 179 15 1024 mmcblk0p15 179 16 8957 mmcblk0p16 179 17 256 mmcblk0p17 179 18 1024 mmcblk0p18 179 19 1024 mmcblk0p19 179 20 1280 mmcblk0p20 179 21 8701 mmcblk0p21 179 22 4096 mmcblk0p22 179 23 256 mmcblk0p23 179 24 256 mmcblk0p24 179 25 425726 mmcblk0p25 179 26 1361920 mmcblk0p26 179 27 209715 mmcblk0p27 179 28 20480 mmcblk0p28 179 32 7761920 mmcblk1 179 33 7757824 mmcblk1p1 254 0 14584 dm-0
# cat /proc/emmc dev: size erasesize name mmcblk0p17: 00040000 00000200 "misc" mmcblk0p21: 0087f400 00000200 "recovery" mmcblk0p22: 00400000 00000200 "boot" mmcblk0p25: 19fbfa00 00000200 "system" mmcblk0p27: 0cccce00 00000200 "cache" mmcblk0p26: 53200200 00000200 "userdata" mmcblk0p28: 01400000 00000200 "devlog"
# busybox fdisk -l mmcblk0 Disk mmcblk0: 2256 MB, 2256535552 bytes 1 heads, 16 sectors/track, 275456 cylinders Units = cylinders of 16 * 512 = 8192 bytes Device Boot Start End Blocks Id System mmcblk0p1 * 1 63 500 4d Unknown Partition 1 does not end on cylinder boundary mmcblk0p2 63 71 64 45 Unknown Partition 2 does not end on cylinder boundary mmcblk0p3 71 634 4500 46 Unknown Partition 3 does not end on cylinder boundary mmcblk0p4 634 1048577 8383544 5 Extended Partition 4 does not end on cylinder boundary mmcblk0p5 634 4384 30000 49 Unknown mmcblk0p6 4384 5946 12500 50 Unknown mmcblk0p7 5946 6202 2048 51 Unknown mmcblk0p8 6202 6586 3072 52 Unknown mmcblk0p9 6586 6842 2048 53 Unknown mmcblk0p10 6842 6970 1024 54 Unknown mmcblk0p11 6971 7098 1024 56 Unknown mmcblk0p12 7099 8192 8751+ 55 Unknown mmcblk0p13 8193 8577 3072 4a Unknown mmcblk0p14 8577 8961 3072 4b Unknown mmcblk0p15 8961 9089 1024 74 Unknown mmcblk0p16 9089 10208 8957+ 75 Unknown mmcblk0p17 10209 10240 256 76 Unknown mmcblk0p18 10241 10369 1024 47 Unknown mmcblk0p19 10369 10497 1024 34 Unknown mmcblk0p20 10497 10657 1280 36 Unknown mmcblk0p21 10657 11744 8701 71 Unknown mmcblk0p22 11744 12256 4096 48 Unknown mmcblk0p23 12257 12288 256 73 Unknown mmcblk0p24 12289 12321 256 31 Unknown mmcblk0p25 12321 65536 425726+ 83 Linux mmcblk0p26 65537 235777 1361920+ 83 Linux mmcblk0p27 235777 261991 209715+ 83 Linux mmcblk0p28 261991 264551 20480 19 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 179 0 2277376 mmcblk0 179 1 500 mmcblk0p1 179 2 64 mmcblk0p2 179 3 4500 mmcblk0p3 179 4 1 mmcblk0p4 179 5 30000 mmcblk0p5 179 6 12500 mmcblk0p6 179 7 2048 mmcblk0p7 179 8 3072 mmcblk0p8 179 9 2048 mmcblk0p9 179 10 1024 mmcblk0p10 179 11 1024 mmcblk0p11 179 12 8751 mmcblk0p12 179 13 3072 mmcblk0p13 179 14 3072 mmcblk0p14 179 15 1024 mmcblk0p15 179 16 8957 mmcblk0p16 179 17 256 mmcblk0p17 179 18 1024 mmcblk0p18 179 19 1024 mmcblk0p19 179 20 1280 mmcblk0p20 179 21 8701 mmcblk0p21 179 22 4096 mmcblk0p22 179 23 256 mmcblk0p23 179 24 2047 mmcblk0p24 179 25 571391 mmcblk0p25 179 26 1203199 mmcblk0p26 179 27 307199 mmcblk0p27 179 28 21247 mmcblk0p28 179 29 256 mmcblk0p29 179 32 7772160 mmcblk1 179 33 7768064 mmcblk1p1
# cat /proc/emmc dev: size erasesize name mmcblk0p17: 00040000 00000200 "misc" mmcblk0p21: 0087f400 00000200 "recovery" mmcblk0p22: 00400000 00000200 "boot" mmcblk0p25: 22dffe00 00000200 "system" mmcblk0p27: 12bffe00 00000200 "cache" mmcblk0p26: 496ffe00 00000200 "userdata" mmcblk0p28: 014bfe00 00000200 "devlog" mmcblk0p29: 00040000 00000200 "pdata"
# fdisk -ul /dev/block/mmcblk0 Warning: deleting partitions after 60 Disk /dev/block/mmcblk0: 2332 MB, 2332033024 bytes 1 heads, 16 sectors/track, 284672 cylinders, total 4554752 sectors Units = sectors of 1 * 512 = 512 bytes Device Boot Start End Blocks Id System /dev/block/mmcblk0p1 * 1 1000 500 4d Unknown Partition 1 does not end on cylinder boundary /dev/block/mmcblk0p2 1001 1128 64 45 Unknown Partition 2 does not end on cylinder boundary /dev/block/mmcblk0p3 1129 10128 4500 46 Unknown Partition 3 does not end on cylinder boundary /dev/block/mmcblk0p4 10129 4554750 2272311 5 Extended Partition 4 does not end on cylinder boundary /dev/block/mmcblk0p5 10130 70129 30000 49 Unknown /dev/block/mmcblk0p6 70131 95130 12500 50 Unknown /dev/block/mmcblk0p7 95132 99227 2048 51 Unknown /dev/block/mmcblk0p8 99229 105372 3072 52 Unknown /dev/block/mmcblk0p9 105374 109469 2048 53 Unknown /dev/block/mmcblk0p10 109471 111518 1024 54 Unknown /dev/block/mmcblk0p11 111520 113567 1024 56 Unknown /dev/block/mmcblk0p12 113569 131071 8751+ 55 Unknown /dev/block/mmcblk0p13 131073 137216 3072 4a Unknown /dev/block/mmcblk0p14 137218 143361 3072 4b Unknown /dev/block/mmcblk0p15 143363 145410 1024 74 Unknown /dev/block/mmcblk0p16 145412 163326 8957+ 75 Unknown /dev/block/mmcblk0p17 163328 163839 256 76 Unknown /dev/block/mmcblk0p18 163841 165888 1024 47 Unknown /dev/block/mmcblk0p19 165890 167937 1024 34 Unknown /dev/block/mmcblk0p20 167939 170498 1280 36 Unknown /dev/block/mmcblk0p21 170500 187901 8701 71 Unknown /dev/block/mmcblk0p22 187903 196094 4096 48 Unknown /dev/block/mmcblk0p23 196096 196607 256 73 Unknown /dev/block/mmcblk0p24 196609 200702 2047 26 Unknown /dev/block/mmcblk0p25 200704 1343486 571391+ 83 Linux /dev/block/mmcblk0p26 1343488 3749886 1203199+ 83 Linux /dev/block/mmcblk0p27 3749888 4364286 307199+ 83 Linux /dev/block/mmcblk0p28 4364288 4406782 21247+ 19 Unknown /dev/block/mmcblk0p29 4406784 4407295 256 23 Unknown
This dmesg output
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: 3959 MB, 3959422976 bytes 1 heads, 16 sectors/track, 483328 cylinders, total 7733248 sectors Units = sectors of 1 * 512 = 512 bytes Device Boot Start End Blocks Id System /dev/block/mmcblk0p1 1 212991 106495+ c Win95 FAT32 (LBA) Partition 1 does not end on cylinder boundary /dev/block/mmcblk0p2 * 212992 213991 500 4d Unknown Partition 2 does not end on cylinder boundary /dev/block/mmcblk0p3 213992 221183 3596 46 Unknown Partition 3 does not end on cylinder boundary /dev/block/mmcblk0p4 221184 7733247 3756032 5 Extended Partition 4 does not end on cylinder boundary /dev/block/mmcblk0p5 229376 239615 5120 47 Unknown /dev/block/mmcblk0p6 245760 285759 20000 49 Unknown /dev/block/mmcblk0p7 286720 292863 3072 58 Unknown /dev/block/mmcblk0p8 294912 306175 5632 48 Unknown /dev/block/mmcblk0p9 311296 324271 6488 50 Unknown /dev/block/mmcblk0p10 327680 333823 3072 4a Unknown /dev/block/mmcblk0p11 335872 342015 3072 4b Unknown /dev/block/mmcblk0p12 344064 360447 8192 90 Unknown /dev/block/mmcblk0p13 360448 375807 7680 91 Unknown /dev/block/mmcblk0p14 376832 387071 5120 92 Unknown /dev/block/mmcblk0p15 393216 1488895 547840 93 Unknown /dev/block/mmcblk0p16 1490944 1613823 61440 94 Unknown /dev/block/mmcblk0p17 1613824 3887103 1136640 95 Unknown /dev/block/mmcblk0p18 3891200 3993599 51200 96 Unknown /dev/block/mmcblk0p19 3997696 3998695 500 97 Unknown /dev/block/mmcblk0p20 4005888 4013079 3596 98 Unknown /dev/block/mmcblk0p21 4014080 4024319 5120 99 Unknown /dev/block/mmcblk0p22 4030464 4070463 20000 9a Unknown /dev/block/mmcblk0p23 4071424 4081663 5120 9b Unknown /dev/block/mmcblk0p24 4087808 4101807 7000 9c Unknown /dev/block/mmcblk0p25 4104192 4114431 5120 9d Unknown /dev/block/mmcblk0p26 4120576 4130815 5120 9e Unknown /dev/block/mmcblk0p27 4136960 4147199 5120 9f BSD/OS /dev/block/mmcblk0p28 4153344 7733247 1789952 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).
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 179 0 15388672 mmcblk0 179 1 65536 mmcblk0p1 179 2 512 mmcblk0p2 179 3 512 mmcblk0p3 179 4 2048 mmcblk0p4 179 5 512 mmcblk0p5 179 6 22528 mmcblk0p6 179 7 22528 mmcblk0p7 179 8 780 mmcblk0p8 179 9 780 mmcblk0p9 179 10 780 mmcblk0p10 179 11 512 mmcblk0p11 179 12 512 mmcblk0p12 179 13 512 mmcblk0p13 179 14 2048 mmcblk0p14 179 15 512 mmcblk0p15 179 16 512 mmcblk0p16 179 17 512 mmcblk0p17 179 18 512 mmcblk0p18 179 19 16384 mmcblk0p19 179 20 16384 mmcblk0p20 179 21 860160 mmcblk0p21 179 22 573440 mmcblk0p22 179 23 13798400 mmcblk0p23 179 24 512 mmcblk0p24 179 25 495 mmcblk0p25
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: 19000000 00020000 "system" mtd1: 00600000 00020000 "appslog" mtd2: 06580000 00020000 "cache" mtd3: 1a400000 00020000 "userdata" mtd4: 00c80000 00020000 "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.
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 000000 "unknown" mmcblk0p2: 000040 000000 "unknown" mmcblk0p3: 001194 000000 "unknown" mmcblk0p4: 000001 000000 "unknown" mmcblk0p5: 007530 000000 "unknown" mmcblk0p6: 0030d4 000000 "unknown" mmcblk0p7: 000800 000000 "unknown" mmcblk0p8: 000c00 000000 "unknown" mmcblk0p9: 000800 000000 "unknown" mmcblk0p10: 000400 000000 "unknown" mmcblk0p11: 000400 000000 "unknown" mmcblk0p12: 00222f 000000 "unknown" mmcblk0p13: 000c00 000000 "unknown" mmcblk0p14: 000c00 000000 "unknown" mmcblk0p15: 000400 000000 "unknown" mmcblk0p16: 0022fd 000000 "unknown" mmcblk0p17: 000100 000000 "unknown" mmcblk0p18: 000400 000000 "unknown" mmcblk0p19: 000800 000000 "unknown" mmcblk0p20: 000500 000000 "unknown" mmcblk0p21: 0021fd 000000 "recovery" mmcblk0p22: 001000 000000 "boot" mmcblk0p23: 000100 000000 "unknown" mmcblk0p24: 007bff 000000 "unknown" mmcblk0p25: 0fffff 000000 "unknown" mmcblk0p26: 000c00 000000 "unknown" mmcblk0p27: 000c00 000000 "unknown" mmcblk0p28: 0067fe 000000 "misc" mmcblk0p29: 407fff 000000 "userdata" mmcblk0p30: 08ffff 000000 "cache" mmcblk0p31: 007eff 000000 "unknown" mmcblk0p32: 000103 000000 "unknown" mmcblk0p33: 8e4ffc 000000 "emmc"
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 2 /dev/misc-sd dsp_bl 0x00000000005c0000 0x0000000000040000 2 /dev/misc-sd mbr 0x0000000000004000 0x0000000000000000 2 /dev/block/mmcblk0 ebr1 0x0000000000004000 0x0000000000004000 2 /dev/block/mmcblk0p1 pmt 0x0000000000400000 0x0000000000008000 2 /dev/block/mmcblk0 nvram 0x0000000000500000 0x0000000000408000 2 /dev/block/mmcblk0 seccfg 0x0000000000020000 0x0000000000908000 2 /dev/block/mmcblk0 uboot 0x0000000000060000 0x0000000000928000 2 /dev/block/mmcblk0 bootimg 0x0000000000600000 0x0000000000988000 2 /dev/block/mmcblk0 recovery 0x0000000000600000 0x0000000000f88000 2 /dev/block/mmcblk0 sec_ro 0x0000000000600000 0x0000000001588000 2 /dev/block/mmcblk0p2 misc 0x0000000000060000 0x0000000001b88000 2 /dev/block/mmcblk0 logo 0x0000000000300000 0x0000000001be8000 2 /dev/block/mmcblk0 expdb 0x0000000000200000 0x0000000001ee8000 2 /dev/block/mmcblk0 android 0x0000000020100000 0x00000000020e8000 2 /dev/block/mmcblk0p3 cache 0x0000000020100000 0x00000000221e8000 2 /dev/block/mmcblk0p4 usrdata 0x0000000020100000 0x00000000422e8000 2 /dev/block/mmcblk0p5 fat 0x00000000854f8000 0x00000000623e8000 2 /dev/block/mmcblk0p6 bmtpool 0x0000000001500000 0x00000000ff9f00a8 2 /dev/block/mmcblk0 Part_Name:Partition name you should open; Size:size of partition StartAddr:Start Address of partition; Type:Type of partition(MTD=1,EMMC=2) MapTo:actual device you operate
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 2 /dev/misc-sd dsp_bl 0x00000000005c0000 0x0000000000040000 2 /dev/misc-sd mbr 0x0000000000004000 0x0000000000000000 2 /dev/block/mmcblk0 ebr1 0x000000000005c000 0x0000000000004000 2 /dev/block/mmcblk0p1 pmt 0x0000000000400000 0x0000000000060000 2 /dev/block/mmcblk0 nvram 0x0000000000300000 0x0000000000460000 2 /dev/block/mmcblk0 seccfg 0x0000000000020000 0x0000000000760000 2 /dev/block/mmcblk0 uboot 0x0000000000060000 0x0000000000780000 2 /dev/block/mmcblk0 bootimg 0x0000000000600000 0x00000000007e0000 2 /dev/block/mmcblk0 recovery 0x0000000000600000 0x0000000000de0000 2 /dev/block/mmcblk0 sec_ro 0x0000000000600000 0x00000000013e0000 2 /dev/block/mmcblk0p5 misc 0x0000000000060000 0x00000000019e0000 2 /dev/block/mmcblk0 logo 0x0000000000300000 0x0000000001a40000 2 /dev/block/mmcblk0 expdb 0x00000000000a0000 0x0000000001d40000 2 /dev/block/mmcblk0 ebr2 0x0000000000004000 0x0000000001de0000 2 /dev/block/mmcblk0 android 0x0000000020100000 0x0000000001de4000 2 /dev/block/mmcblk0p6 cache 0x000000000a100000 0x0000000021ee4000 2 /dev/block/mmcblk0p2 usrdata 0x0000000041100000 0x000000002bfe4000 2 /dev/block/mmcblk0p3 fat 0x0000000000000001 0x000000006d0e4000 2 /dev/block/mmcblk0p4 bmtpool 0x000000007bafbfff 0xffffffffffa00000 2 /dev/block/mmcblk0 recovery filesystem table ========================= 0 /tmp ramdisk (null) (null) 0 1 /boot emmc boot (null) 0 2 /cache ext4 /dev/block/mmcblk0p2 (null) 0 3 /data ext4 /dev/block/mmcblk0p3 (null) 0 4 /misc emmc misc (null) 0 5 /recovery emmc recovery (null) 0 6 /sdcard vfat /dev/block/mmcblk1 /dev/block/mmcblk0p4 0 7 /sdcard2 vfat /dev/block/mmcblk0p4 (null) 0 8 /system ext4 /dev/block/mmcblk0p6 (null) 0
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.1 msm_sdcc.3
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.1/by-name < lrwxrwxrwx root root 1970-01-25 07:48 DDR -> /dev/block/mmcblk0p8 lrwxrwxrwx root root 1970-01-25 07:48 aboot -> /dev/block/mmcblk0p5 lrwxrwxrwx root root 1970-01-25 07:48 boot -> /dev/block/mmcblk0p9 lrwxrwxrwx root root 1970-01-25 07:48 cache -> /dev/block/mmcblk0p20 lrwxrwxrwx root root 1970-01-25 07:48 dbi -> /dev/block/mmcblk0p3 lrwxrwxrwx root root 1970-01-25 07:48 fsc -> /dev/block/mmcblk0p6 lrwxrwxrwx root root 1970-01-25 07:48 fsg -> /dev/block/mmcblk0p17 lrwxrwxrwx root root 1970-01-25 07:48 misc -> /dev/block/mmcblk0p19 lrwxrwxrwx root root 1970-01-25 07:48 modem -> /dev/block/mmcblk0p1 lrwxrwxrwx root root 1970-01-25 07:48 modemst1 -> /dev/block/mmcblk0p15 lrwxrwxrwx root root 1970-01-25 07:48 modemst2 -> /dev/block/mmcblk0p16 lrwxrwxrwx root root 1970-01-25 07:48 mrd -> /dev/block/mmcblk0p12 lrwxrwxrwx root root 1970-01-25 07:48 pad -> /dev/block/mmcblk0p14 lrwxrwxrwx root root 1970-01-25 07:48 persist -> /dev/block/mmcblk0p18 lrwxrwxrwx root root 1970-01-25 07:48 preload -> /dev/block/mmcblk0p22 lrwxrwxrwx root root 1970-01-25 07:48 recovery -> /dev/block/mmcblk0p10 lrwxrwxrwx root root 1970-01-25 07:48 rpm -> /dev/block/mmcblk0p4 lrwxrwxrwx root root 1970-01-25 07:48 sbl1 -> /dev/block/mmcblk0p2 lrwxrwxrwx root root 1970-01-25 07:48 splash -> /dev/block/mmcblk0p11 lrwxrwxrwx root root 1970-01-25 07:48 ssd -> /dev/block/mmcblk0p7 lrwxrwxrwx root root 1970-01-25 07:48 system -> /dev/block/mmcblk0p21 lrwxrwxrwx root root 1970-01-25 07:48 tz -> /dev/block/mmcblk0p13 lrwxrwxrwx root root 1970-01-25 07:48 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=1 skip=6291456 count=8257536
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.1 # ls -l /dev/block/platform/msm_sdcc.1/by-num s -l /dev/block/platform/msm_sdcc.1/by-num < lrwxrwxrwx root root 1970-01-25 07:48 p1 -> /dev/block/mmcblk0p1 lrwxrwxrwx root root 1970-01-25 07:48 p10 -> /dev/block/mmcblk0p10 lrwxrwxrwx root root 1970-01-25 07:48 p11 -> /dev/block/mmcblk0p11 lrwxrwxrwx root root 1970-01-25 07:48 p12 -> /dev/block/mmcblk0p12 lrwxrwxrwx root root 1970-01-25 07:48 p13 -> /dev/block/mmcblk0p13 lrwxrwxrwx root root 1970-01-25 07:48 p14 -> /dev/block/mmcblk0p14 lrwxrwxrwx root root 1970-01-25 07:48 p15 -> /dev/block/mmcblk0p15 lrwxrwxrwx root root 1970-01-25 07:48 p16 -> /dev/block/mmcblk0p16 lrwxrwxrwx root root 1970-01-25 07:48 p17 -> /dev/block/mmcblk0p17 lrwxrwxrwx root root 1970-01-25 07:48 p18 -> /dev/block/mmcblk0p18 lrwxrwxrwx root root 1970-01-25 07:48 p19 -> /dev/block/mmcblk0p19 lrwxrwxrwx root root 1970-01-25 07:48 p2 -> /dev/block/mmcblk0p2 lrwxrwxrwx root root 1970-01-25 07:48 p20 -> /dev/block/mmcblk0p20 lrwxrwxrwx root root 1970-01-25 07:48 p21 -> /dev/block/mmcblk0p21 lrwxrwxrwx root root 1970-01-25 07:48 p22 -> /dev/block/mmcblk0p22 lrwxrwxrwx root root 1970-01-25 07:48 p23 -> /dev/block/mmcblk0p23 lrwxrwxrwx root root 1970-01-25 07:48 p3 -> /dev/block/mmcblk0p3 lrwxrwxrwx root root 1970-01-25 07:48 p4 -> /dev/block/mmcblk0p4 lrwxrwxrwx root root 1970-01-25 07:48 p5 -> /dev/block/mmcblk0p5 lrwxrwxrwx root root 1970-01-25 07:48 p6 -> /dev/block/mmcblk0p6 lrwxrwxrwx root root 1970-01-25 07:48 p7 -> /dev/block/mmcblk0p7 lrwxrwxrwx root root 1970-01-25 07:48 p8 -> /dev/block/mmcblk0p8 lrwxrwxrwx root root 1970-01-25 07:48 p9 -> /dev/block/mmcblk0p9