RPI3: AndroidThings Preview6 分区表分析(iot_rpi3.img)

从Android官网下载下来的Raspberry PI 3B preview 6的安装镜像,发现所使用的GPT分区表,在我的印象中,树莓派是只支持MBR分区表的。为什么GPT格式的分区表可以在树莓派上正常启动?


  • 分区表

在Ubuntu 14.04系统上,可以使用gdisk命令查看镜像文件的分区表:

$ gdisk iot_rpi3.img 
GPT fdisk (gdisk) version 0.8.8

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): 

这里最关键的是这句话:Found valid GPT with hybrid MBR

简单也说,这个镜像上包含两种分区表: GTP & MBR分区表,使得树莓派可以识别MBR 分区表正常启动?


Disk iot_rpi3.img: 8912896 sectors, 4.2 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): B4E0B8F7-2781-4463-B8F6-C5E9739823BC
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 8912862
Partitions will be aligned on 8-sector boundaries
Total free space is 13 sectors (6.5 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40          131111   64.0 MiB    FFFF  rpiboot
   2          131112          133159   1024.0 KiB  FFFF  uboot_a
   3          133160          135207   1024.0 KiB  FFFF  uboot_b
   4          135208          200743   32.0 MiB    FFFF  boot_a
   5          200744          266279   32.0 MiB    FFFF  boot_b
   6          266280         1314855   512.0 MiB   FFFF  system_a
   7         1314856         2363431   512.0 MiB   FFFF  system_b
   8         2363432         2363559   64.0 KiB    FFFF  vbmeta_a
   9         2363560         2363687   64.0 KiB    FFFF  vbmeta_b
  10         2363688         2365735   1024.0 KiB  FFFF  misc
  11         2365736         2496807   64.0 MiB    FFFF  vendor_a
  12         2496808         2627879   64.0 MiB    FFFF  vendor_b
  13         2627880         4086055   712.0 MiB   FFFF  oem_a
  14         4086056         5544231   712.0 MiB   FFFF  oem_b
  15         5544232         5552423   4.0 MiB     FFFF  oem_bootloader_a
  16         5552424         5560615   4.0 MiB     FFFF  oem_bootloader_b
  17         5560616         5626151   32.0 MiB    FFFF  factory
  18         5626152         5658919   16.0 MiB    FFFF  factory_bootloader
  19         5658920         8912847   1.6 GiB     FFFF  userdata
  20         8912848         8912855   4.0 KiB     FFFF  gapps

分区还是挺多的:包含第一个树莓派的启动分区,还有uboot, boot, system, vbmeta, misc, vendor, oem, oem_bootloader, factory, userdata, gapps 分区,看来rpi使用了uboot做引导器,kernel也应该放在了boot分区



Command (? for help): r

Recovery/transformation command (? for help): o

Disk size is 8912896 sectors (4.2 GiB)
MBR disk identifier: 0x00000000
MBR partitions:

Number  Boot  Start Sector   End Sector   Status      Code
   1                    40       131111   primary     0x06
   2                     1           34   primary     0xEE



  • 关于hybrid MBR


As noted on other pages in this document, a conventional GPT disk contains a protective MBR with a single partition, of type 0xEE (EFI GPT), defined. This partition spans the entire size of the disk or 2 TiB, whichever is smaller. The intent is to keep GPT-unaware OSes and utilities from trying to modify the disk.

A hybrid MBR is a variant on the normal protective MBR. A hybrid MBR contains a type-0xEE partition, but it also contains up to three additional primary partitions, which point to the same space that's marked out by up to three GPT partitions. For instance, suppose you've got a Macintosh computer that dual-boots Mac OS X and Windows. OS X is happy on GPT, and so can use GPT partition definitions; but Windows is less capable in this respect. Thus, you'll define your partitions first as GPT partitions (including your Windows partitions), and then you'll modify your protective MBR so that its 0xEE partition is smaller than normal and it contains one to three partition definitions that point to the same disk locations as corresponding GPT partitions. You can then install Windows on these hybridized partitions. Apple's Boot Camp helps automate this process, so you don't need GPT fdisk to set up a hybrid MBR on a Mac; however, GPT fdisk can be useful in maintaining your hybrid MBR after it's configured, and you might want to use it on BIOS-based computers for similar configurations involving other OSes. On any computer, the end result is that GPT-unaware OSes can use up to three primary partitions, while GPT-aware OSes can use all the partitions on the disk.


  • 相关的参考文档
  1. http://www.rodsbooks.com/gdisk/hybrid.html


Be the First to Comment!