Android 5.x OTA Update官方文檔(五、Recovery系統下分區映射),androidota
寫在前面:若能直譯,不會意譯,意譯不成,為了選擇不誤導他人也會漏譯無傷大雅的部分,英語是硬傷,如果有誤譯,請路過的朋友幫忙指正,以免誤導更多的朋友。
Recovery系統包含了很多鉤子程式,因此OAT更新除了可以更新Android系統也可以更新裝置的其他部分。(如基帶、無線電處理器)。
分區映射
從Android2.3起,平台開始支援eMMC存放裝置和ext4檔案系統。它同樣支援MTD裝置和yaffs2檔案系統。
分區對應檔TARGET_RECOVERY_FSTAB一般會被recovery二進位程式和打包工具所使用,我們可以在BoardConfig.mk檔案中配置對應檔的檔案名稱為TARGET_RECOVERY_FSTAB。
下面是一個簡單的分區對應檔結構。
device/yoyodyne/tardis/recovery.fstab
# mount point fstype device [device2] [options (3.0+ only)]
/sdcard vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0
/cache yaffs2 cache
/misc m td misc
/boot mtd boot
/recovery emmc /dev/block/platform/s3c-sdhci.0/by-name/recovery
/system ext4 /dev/block/platform/s3c-sdhci.0/by-name/system length=-4096
/data ext4 /dev/block/platform/s3c-sdhci.0/by-name/userdata
在上面的分區對應檔中,/sdcard是個例外,因為在這裡它是可選的。除了/sdcard,例子中所有的掛載點必須被定義。這例子中我們看到有五種檔案系統類型,如下:
yaffs2
YAFFS(Yet Another Flash File System)是由Aleph One公司所發展出來的NAND flash 嵌入式檔案系統。 因此yaffs2檔案系統只能使用在MTD存放裝置上。 "device" 必須是MTD分區的名字。而且必須在/proc/mtd中配置。
mtd
一個原始的mtd分區常被用於bootale分區,如boot分區和recovery分區。mtd不一定被掛載,但是掛載點常被用於一個key來尋找分區。 "device" 必須是mtd分區的名字。而且必須在/proc/mtd中配置。
ext4
ext4檔案系統常備用於emmc存放裝置。“device”必須是塊裝置的路徑。
emmc
一個原始的eMMC塊裝置,常常被用於bootable分區如boot分區和recovery分區,因此比較與mtd類型比較類似。eMMC從來沒有被掛載,但是掛載點eMMc 習慣被用來在分區表中尋找裝置。
vfat
Vfat是一個FAT檔案系統,被用於塊裝置中。這裡通常指外設存放裝置如SD卡。Device是塊裝置,device2是第二個塊裝置。如果第一個塊裝置掛在失敗的情況下,會選擇掛在第二個塊裝置。
所有的分區必須被掛載在根目錄下。(例如掛載點的值必須是以斜線開始,而不能再有多餘的斜線。這條原則僅僅應用於recovery中。主系統可以自由掛載在任何地方。 /boot, /recovery, 和/misc 目錄必須是原始類型,(如:mtd或emmc), 二 /system, /data, /cache, 和/sdcard (如果可用) 應該是檔案系統類型 如(yaffs2, ext4, 或 vfat).
從Android3.0版本開始recovery的.fastb檔案增加了一個擴充項。一般僅僅用來指定分區的長度。
原文如下:
The recovery system includes several hooks for inserting device-specific code so that OTA updates can also update parts of the device other than the Android system (e.g., the baseband or radio processor).
The following sections and examples customize the tardis device produced by the yoyodyne vendor.
Partition map
As of Android 2.3, the platform supports eMMC flash devices and the ext4 filesystem that runs on those devices. It also supports Memory Technology Device (MTD) flash devices and the yaffs2 filesystem from older releases.
The partition map file is specified by TARGET_RECOVERY_FSTAB; this file is used by both the recovery binary and the package-building tools. You can specify the name of the map file in TARGET_RECOVERY_FSTAB in BoardConfig.mk.
A sample partition map file might look like this:
device/yoyodyne/tardis/recovery.fstab
# mount point fstype device [device2] [options (3.0+ only)]/sdcard vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0/cache yaffs2 cache/misc mtd misc/boot mtd boot/recovery emmc /dev/block/platform/s3c-sdhci.0/by-name/recovery/system ext4 /dev/block/platform/s3c-sdhci.0/by-name/system length=-4096/data ext4 /dev/block/platform/s3c-sdhci.0/by-name/userdata
With the exception of /sdcard, which is optional, all mount points in this example must be defined (devices may also add extra partitions). There are five supported filesystem types:
-
yaffs2
-
A yaffs2 filesystem atop an MTD flash device. "device" must be the name of the MTD partition and must appear in
/proc/mtd.
-
mtd
-
A raw MTD partition, used for bootable partitions such as boot and recovery. MTD is not actually mounted, but the mount point is used as a key to locate the partition. "device" must be the name of the MTD partition in
/proc/mtd.
-
ext4
-
An ext4 filesystem atop an eMMC flash device. "device" must be the path of the block device.
-
emmc
-
A raw eMMC block device, used for bootable partitions such as boot and recovery. Similar to the mtd type, eMMc is never actually mounted, but the mount point string is used to locate the device in the table.
-
vfat
-
A FAT filesystem atop a block device, typically for external storage such as an SD card. The device is the block device; device2 is a second block device the system attempts to mount if mounting the primary device fails (for compatibility with SD cards which may or may not be formatted with a partition table).
All partitions must be mounted in the root directory (i.e. the mount point value must begin with a slash and have no other slashes). This restriction applies only to mounting filesystems in recovery; the main system is free to mount them anywhere. The directories /boot, /recovery, and /misc should be raw types (mtd or emmc), while the directories /system, /data, /cache, and /sdcard (if available) should be filesystem types (yaffs2, ext4, or vfat).
Starting in Android 3.0, the recovery.fstab file gains an additional optional field, options. Currently the only defined option is length , which lets you explicitly specify the length of the partition. This length is used when reformatting the partition (e.g., for the userdata partition during a data wipe/factory reset operation, or for the system partition during installation of a full OTA package). If the length value is negative, then the size to format is taken by adding the length value to the true partition size. For instance, setting "length=-16384" means the last 16k of that partition will not be overwritten when that partition is reformatted. This supports features such as encryption of the userdata partition (where encryption metadata is stored at the end of the partition that should not be overwritten).
Note: The device2 and options fields are optional, creating ambiguity in parsing. If the entry in the fourth field on the line begins with a ‘/' character, it is considered a device2 entry; if the entry does not begin with a ‘/' character, it is considered an options field.