[Hardware Hacking General] E:V:A:
How to obtain your partition table?

Although the way to obtain your complete partition table layout varies from

device to device, there are some standard tools and methods to do this. The

most important thing to know, especially if you're used to the old-school

Windows/Linux Master Boot Record (MBR) type file systems, is that most modern

Android smartphones now make heavy use of the GUID Partition Table (GPT)

structure (formatting). Thus you will need some slightly different tools, to

obtain the proper information from your device. Different tools give different

information, as we shall see.

NOTE: You have to be rooted to use these tools!

Example-1: (Partition Tables for the Samsung Galaxy S2 GT-I9100)

Here we get our partition table using three different tools:

fdisk

parted

gdisk (aka gptfdisk)

And the results will differ quite dramatically.

1. Using fdisk:

[SIZE=2]/ # fdisk -l /dev/block/mmcblk0[/SIZE]

[SIZE=2] Disk /dev/block/mmcblk0: 15.7 GB, 15756951552 bytes[/SIZE]
[SIZE=2] 1 heads, 16 sectors/track, 1923456 cylinders[/SIZE]
[SIZE=2] Units = cylinders of 16 * 512 = 8192 bytes[/SIZE]

[SIZE=2] Device Boot Start End Blocks Id System[/SIZE]
[SIZE=2] /dev/block/mmcblk0p1 1 1923456 15387647+ ee EFI GPT[/SIZE]
[SIZE=2] Partition 1 does not end on cylinder boundary[/SIZE]

2. Using parted:

[SIZE=2]/ # parted /dev/block/mmcblk0[/SIZE]
[SIZE=2] GNU Parted 1.8.8.1.179-aef3[/SIZE]
[SIZE=2] Using /dev/block/mmcblk0[/SIZE]
[SIZE=2] Welcome to GNU Parted! Type 'help' to view a list of commands.[/SIZE]
[SIZE=2] (parted) p[/SIZE]
[SIZE=2] p[/SIZE]
[SIZE=2] Model: MMC VYL00M (sd/mmc)[/SIZE]
[SIZE=2] Disk /dev/block/mmcblk0: 15.8GB[/SIZE]
[SIZE=2] Sector size (logical/physical): 512B/512B[/SIZE]
[SIZE=2] Partition Table: gpt[/SIZE]

[SIZE=2] Number Start End Size File system Name Flags[/SIZE]
[SIZE=2] 1 4194kB 25.2MB 21.0MB ext4 EFS[/SIZE]
[SIZE=2] 2 25.2MB 26.5MB 1311kB SBL1[/SIZE]
[SIZE=2] 3 27.3MB 28.6MB 1311kB SBL2[/SIZE]
[SIZE=2] 4 29.4MB 37.7MB 8389kB PARAM[/SIZE]
[SIZE=2] 5 37.7MB 46.1MB 8389kB KERNEL[/SIZE]
[SIZE=2] 6 46.1MB 54.5MB 8389kB RECOVERY[/SIZE]
[SIZE=2] 7 54.5MB 159MB 105MB ext4 CACHE[/SIZE]
[SIZE=2] 8 159MB 176MB 16.8MB MODEM[/SIZE]
[SIZE=2] 9 176MB 713MB 537MB ext4 FACTORYFS[/SIZE]
[SIZE=2] 10 713MB 2861MB 2147MB ext4 DATAFS[/SIZE]
[SIZE=2] 11 2861MB 15.2GB 12.4GB fat32 UMS[/SIZE]
[SIZE=2] 12 15.2GB 15.8GB 537MB ext4 HIDDEN[/SIZE]

3. Using gdisk:

[SIZE=2]/ # gdisk -l /dev/block/mmcblk0[/SIZE]
[SIZE=2] GPT fdisk (gdisk) version 0.8.4[/SIZE]

[SIZE=2] Partition table scan:[/SIZE]
[SIZE=2] MBR: protective[/SIZE]
[SIZE=2] BSD: not present[/SIZE]
[SIZE=2] APM: not present[/SIZE]
[SIZE=2] GPT: present[/SIZE]

[SIZE=2] Found valid GPT with protective MBR; using GPT.[/SIZE]
[SIZE=2] Disk /dev/block/mmcblk0: 30775296 sectors, 14.7 GiB[/SIZE]
[SIZE=2] Logical sector size: 512 bytes[/SIZE]
[SIZE=2] Disk identifier (GUID): 52444E41-494F-2044-4D4D-43204449534B[/SIZE]
[SIZE=2] Partition table holds up to 128 entries[/SIZE]
[SIZE=2] First usable sector is 34, last usable sector is 30775262[/SIZE]
[SIZE=2] Partitions will be aligned on 2048-sector boundaries[/SIZE]
[SIZE=2] Total free space is 17341 sectors (8.5 MiB)[/SIZE]

[SIZE=2] Number Start (sector) End (sector) Size Code Name[/SIZE]
[SIZE=2] 1 8192 49151 20.0 MiB 0700 EFS[/SIZE]
[SIZE=2] 2 49152 51711 1.2 MiB 0700 SBL1[/SIZE]
[SIZE=2] 3 53248 55807 1.2 MiB 0700 SBL2[/SIZE]
[SIZE=2] 4 57344 73727 8.0 MiB 0700 PARAM[/SIZE]
[SIZE=2] 5 73728 90111 8.0 MiB 0700 KERNEL[/SIZE]
[SIZE=2] 6 90112 106495 8.0 MiB 0700 RECOVERY[/SIZE]
[SIZE=2] 7 106496 311295 100.0 MiB 0700 CACHE[/SIZE]
[SIZE=2] 8 311296 344063 16.0 MiB 0700 MODEM[/SIZE]
[SIZE=2] 9 344064 1392639 512.0 MiB 0700 FACTORYFS[/SIZE]
[SIZE=2] 10 1392640 5586943 2.0 GiB 0700 DATAFS[/SIZE]
[SIZE=2] 11 5586944 29720575 11.5 GiB 0700 UMS[/SIZE]
[SIZE=2] 12 29720576 30769151 512.0 MiB 0700 HIDDEN[/SIZE]

Example-2: (Using built-in system tools.)

[SIZE=2]/ # mount
rootfs / rootfs ro,relatime 0 0
tmpfs /dev tmpfs rw,relatime,mode=111 0 0
devpts /dev/pts devpts rw,relatime,mode=600 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,relatime 0 0
none /acct cgroup rw,relatime,cpuacct 0 0
tmpfs /mnt/asec tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/obb tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /mnt/usb tmpfs rw,relatime,mode=755,gid=1000 0 0
tmpfs /app-cache tmpfs rw,relatime,size=7168k 0 0
none /dev/cpuctl cgroup rw,relatime,cpu 0 0
/dev/block/mmcblk0p9 /system ext4 ro,relatime,barrier=1,data=ordered 0 0
/dev/block/mmcblk0p7 /cache ext4 rw,nosuid,nodev,noatime,barrier=1,data=ordered 0 0
/dev/block/mmcblk0p1 /efs ext4 rw,nosuid,nodev,noatime,barrier=1,data=ordered 0 0
nil /sys/kernel/debug debugfs rw,relatime 0 0
/dev/block/mmcblk0p10 /data ext4 rw,nosuid,nodev,noatime,barrier=1,data=ordered,noauto_da_alloc,discard 0 0
/dev/block/mmcblk0p4 /mnt/.lfs j4fs rw,relatime 0 0
/dev/block/vold/179:11 /mnt/sdcard vfat rw,dirsync,nosuid,nodev,noexec,noatime,nodiratime,uid=1000,gid=1015,fmask=0002,dmask=0002,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro,discard 0 0

/ # busybox cat /proc/partitions
major minor #blocks name

179 0 15387648 mmcblk0
179 1 20480 mmcblk0p1
179 2 1280 mmcblk0p2
179 3 1280 mmcblk0p3
179 4 8192 mmcblk0p4
179 5 8192 mmcblk0p5
179 6 8192 mmcblk0p6
179 7 102400 mmcblk0p7
179 8 16384 mmcblk0p8
179 9 524288 mmcblk0p9
179 10 2097152 mmcblk0p10
179 11 12066816 mmcblk0p11
179 12 524288 mmcblk0p12
[/SIZE]

Download These Partition Tools

I have collected the above three tools into one ZIP package

that you can download HERE. << WIP TBA >>

Download the ZIP containing parted HERE.

(Do not use/push/install anything else than "parted", as they may

already be present on your system, or in Busybox.)

The gptfdisk binary is rather large (~1.5 MB) as it is statically compiled.

It would be nice if someone could create an NDK based dynamic binary.

Download the binary HERE. (SourceForge, Info)

darkspr1te have collected even more (statically compiled) tools in his

post #13, that can be downloaded HERE.

Collecting Alternative Information

There are several system commands and files that you can use, that contain

partitioning information. The most common ones are:

mount
cat /proc/mtd
cat /proc/mounts
cat /proc/partitions
cat /proc/emmc

busybox fdisk -l /dev/block/mmcblk0
parted -l /dev/block/mmcblk0
gdisk -l /dev/block/mmcblk0

[You will probably need to modify these to suit your particular storage device.]

Another useful place for info is in the Kernel and debug messages output.

However, these commands need to be performed as soon as possible after a

reboot, since the message log is a ring-buffer of only 4K. (Meaning it will soon

overwrite itself.)

dmesg |grep "mmc"
dmesg |grep "partition"
cat /proc/kmesg >/path-to-your-writeable-area/kmesg.log

Collecting Partition Tables while Flashing

(Root not required)

You can also collect very detailed partition table layout while flashing new firmware (using Windows).

Thanks to attentive users: [MENTION=5730223]IGGYVIP[/MENTION] and [MENTION=4478935]Antagonist42[/MENTION] we show in Post#51 and beyond, how you

can use SysInternals DebugView tool, to collect interesting debug information while flashing.