android images loaded sd card partition analysis

this is partition info obtained through ‘fdisk’ on the sd card preloaded with the necessary android images in each partition.

Disk /dev/mmcblk0: 7948 MB, 7948206080 bytes
245 heads, 62 sectors/track, 1021 cylinders, total 15523840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1           15190       45569       15190   83  Linux
/dev/mmcblk0p2           45570       75949       15190   83  Linux
/dev/mmcblk0p3           75950     2293689     1108870    5  Extended
/dev/mmcblk0p4         2293690    15645699     6676005   83  Linux
/dev/mmcblk0p5           75951     1139249      531649+  83  Linux
/dev/mmcblk0p6         1139251     2202549      531649+  83  Linux
/dev/mmcblk0p7         2202551     2232929       15189+  83  Linux
/dev/mmcblk0p8         2232931     2263309       15189+  83  Linux

unit is “512bytes”

At first glance, I only focused on the list of numbers of each partition and simply assumed that the numbers meant bytes. However, I soon found this did not make sense because there is no way that one block would equal to 2 bytes.

The initial and faulty calculation from the numbers from p1 gave me this:
total size=45569-15190+1=30380bytes
since the result said that 15190 blocks correspond to this partitions, this would mean 30380/15190=2bytes/block which is absolutely proposterous.

Without doubt, I was wrong to think that the unit of the numbers are bytes and I realized that the true unit is actually mentioned at the beginning:
“Units = sectors of 1 * 512 = 512 bytes”

Redoing the calculation gives me,
30380*512bytes/15190blocks=1024bytes/block

google results showed that there are many meanings for ‘blocks’ and as for disk blocks it is 1024bytes so the calculation above is correct (or at least it is reasonable to see it that way for now).

start of partition default: “2048”

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-31116287, default 2048):

after deleting all partitions and trying to create a new partition, fdisk will limit the start of it to 2048. The units are again 512bytes thus this means that the earliest offset the user can create a partition is 512*2048=1MB. This can raise questions because a skim through the wikipedia on MBR states that the MBR resides in the first sector of the disk: that is, the first 512bytes are used as MBR and the rest is free of use. Then why the 1MB padding instead of 512bytes?

According to here, this is actually a considerate policy implemented in order to make the partitioning to be compatible with GPT which the user may decided to convert in the future.

partition layout for android

The sd card was given out of the box from a freescale imx6quad sabre-sdb(smart device board) kit. The partition stated in the user guide is as below:

table crop
based on this table, I could deduct which partitions are which.

Concepts of primary, extended, and logical partitions must be understood beforehand. The key point is that logical partitions are subitems of one extended partition which is used in cases where more than four partitions should be created under MBR partitioning system. Once this is clearly understood, the partition list can be understood as below:

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1           15190       45569       15190   83  Linux  --> boot.img
/dev/mmcblk0p2           45570       75949       15190   83  Linux --> recovery.img
/dev/mmcblk0p3           75950     2293689     1108870    5  Extended (covers p5,6,7,8)
/dev/mmcblk0p4         2293690    15645699     6676005   83  Linux --> DATA. primary 4
/dev/mmcblk0p5           75951     1139249      531649+  83  Linux --> SYSTEM partition. ext4
/dev/mmcblk0p6         1139251     2202549      531649+  83  Linux --> cache?
/dev/mmcblk0p7         2202551     2232929       15189+  83  Linux --> vender, ext4
/dev/mmcblk0p8         2232931     2263309       15189+  83  Linux --> ??? don't know yet

note that the p3, which is the extended partition’s start-end encompasses partition 5,6,7,8 which are logical partitions. This is noted in the table shown above by “(Extended 3)” next to the logical partitions.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s