GPT 标头签名有什么用?

Tim*_*Tea 14 gpt

根据这篇维基百科文章,GUID 分区表 (LBA 1) 的第二个逻辑块地址是主要的 GPT 标头。然后它在关于标题的部分声明标题的前 8 个字节用于“签名”。

这个 GPT 头签名是什么,它与 GPT 表/存储设备的功能/操作有什么相关性?

我在网上四处搜索,但发现有关此标头签名用途的信息很少。

编辑:

我在对 Deltik 的回答的评论中问了这些后续问题,他们非常有帮助地扩展了这些问题:

  • 如果签名是空白的,那么 GPT 表会不会被识别?
  • 我目前正在检查 Chrome OS GPT,其中签名似乎已设置为“IGNOREME”。那会有什么影响?
  • 是否还有其他有效的 GPT 签名可用?(除了默认的“EFI PART”)

Del*_*tik 24

签名EFI PART( 0x45 0x46 0x49 0x20 0x50 0x41 0x52 0x54) 只是说“这是一个 GUID 分区表”。这就是软件如何知道块设备是在 GPT 布局中格式化的。

您可以从 hexdump 的这个片段中看到它:

*
000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
00000210  ea b5 99 a4 00 00 00 00  01 00 00 00 00 00 00 00  |................|
00000220  af 12 9e 3b 00 00 00 00  22 00 00 00 00 00 00 00  |...;....".......|
00000230  8e 12 9e 3b 00 00 00 00  7f 8c d6 05 c8 e8 01 4a  |...;...........J|
00000240  b8 74 6b 37 30 7c bf 15  02 00 00 00 00 00 00 00  |.tk70|..........|
00000250  80 00 00 00 80 00 00 00  10 d3 0e 29 00 00 00 00  |...........)....|
00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
Run Code Online (Sandbox Code Playgroud)

签名不是 GPT 独有的。文件还具有签名,软件可以使用这些签名来识别文件是什么。这就是file命令的操作机制。(例子file)


后续问题的回答

那么,如果这个签名是空白的,那么 GPT 分区表就不会被识别?

至少,gdisk不会再认了。看看这个演示:

  1. 为演示创建一个文件(充当块设备):

    root@demo [/tmp]# truncate -s 1M gpt-demo
    
    Run Code Online (Sandbox Code Playgroud)
  2. 使用 GPT 格式化文件:

    root@demo [/tmp]# sgdisk --clear gpt-demo
    Creating new GPT entries.
    Warning: The kernel is still using the old partition table.
    The new table will be used at the next reboot or after you
    run partprobe(8) or kpartx(8)
    The operation has completed successfully.
    
    Run Code Online (Sandbox Code Playgroud)
  3. 查看分区表的二进制数据:

    root@demo [/tmp]# hexdump -C gpt-demo
    00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    000001c0  02 00 ee 20 20 00 01 00  00 00 ff 07 00 00 00 00  |...  ...........|
    000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
    00000200  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
    00000210  13 14 6d 6a 00 00 00 00  01 00 00 00 00 00 00 00  |..mj............|
    00000220  ff 07 00 00 00 00 00 00  22 00 00 00 00 00 00 00  |........".......|
    00000230  de 07 00 00 00 00 00 00  be 2c cb 6e 58 d4 e3 46  |.........,.nX..F|
    00000240  84 84 3c 83 52 59 5b 58  02 00 00 00 00 00 00 00  |..<.RY[X........|
    00000250  80 00 00 00 80 00 00 00  86 d2 54 ab 00 00 00 00  |..........T.....|
    00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    000ffe00  45 46 49 20 50 41 52 54  00 00 01 00 5c 00 00 00  |EFI PART....\...|
    000ffe10  18 3a 1f d9 00 00 00 00  ff 07 00 00 00 00 00 00  |.:..............|
    000ffe20  01 00 00 00 00 00 00 00  22 00 00 00 00 00 00 00  |........".......|
    000ffe30  de 07 00 00 00 00 00 00  be 2c cb 6e 58 d4 e3 46  |.........,.nX..F|
    000ffe40  84 84 3c 83 52 59 5b 58  df 07 00 00 00 00 00 00  |..<.RY[X........|
    000ffe50  80 00 00 00 80 00 00 00  86 d2 54 ab 00 00 00 00  |..........T.....|
    000ffe60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00100000
    
    Run Code Online (Sandbox Code Playgroud)
  4. 检查如何gdisk读取分区表:

    root@demo [/tmp]# gdisk gpt-demo
    GPT fdisk (gdisk) version 1.0.3
    
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    Found valid GPT with protective MBR; using GPT.
    
    Command (? for help): q
    
    Run Code Online (Sandbox Code Playgroud)
  5. 更改 GPT 签名:

    root@demo [/tmp]# sed -i 's/EFI PART/IGNOREME/g' gpt-demo
    
    Run Code Online (Sandbox Code Playgroud)
  6. 验证签名是否核对:

    root@demo [/tmp]# hexdump -C gpt-demo
    00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    000001c0  02 00 ee 20 20 00 01 00  00 00 ff 07 00 00 00 00  |...  ...........|
    000001d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    000001f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa  |..............U.|
    00000200  49 47 4e 4f 52 45 4d 45  00 00 01 00 5c 00 00 00  |IGNOREME....\...|
    00000210  13 14 6d 6a 00 00 00 00  01 00 00 00 00 00 00 00  |..mj............|
    00000220  ff 07 00 00 00 00 00 00  22 00 00 00 00 00 00 00  |........".......|
    00000230  de 07 00 00 00 00 00 00  be 2c cb 6e 58 d4 e3 46  |.........,.nX..F|
    00000240  84 84 3c 83 52 59 5b 58  02 00 00 00 00 00 00 00  |..<.RY[X........|
    00000250  80 00 00 00 80 00 00 00  86 d2 54 ab 00 00 00 00  |..........T.....|
    00000260  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    000ffe00  49 47 4e 4f 52 45 4d 45  00 00 01 00 5c 00 00 00  |IGNOREME....\...|
    000ffe10  18 3a 1f d9 00 00 00 00  ff 07 00 00 00 00 00 00  |.:..............|
    000ffe20  01 00 00 00 00 00 00 00  22 00 00 00 00 00 00 00  |........".......|
    000ffe30  de 07 00 00 00 00 00 00  be 2c cb 6e 58 d4 e3 46  |.........,.nX..F|
    000ffe40  84 84 3c 83 52 59 5b 58  df 07 00 00 00 00 00 00  |..<.RY[X........|
    000ffe50  80 00 00 00 80 00 00 00  86 d2 54 ab 00 00 00 00  |..........T.....|
    000ffe60  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00100000
    
    Run Code Online (Sandbox Code Playgroud)
  7. 请注意,GUID 分区表 (GPT) 不再被以下各项识别gdisk

    root@demo [/tmp]# gdisk gpt-demo
    GPT fdisk (gdisk) version 1.0.3
    
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: not present
    
    Creating new GPT entries.
    
    Command (? for help): q
    
    Run Code Online (Sandbox Code Playgroud)

我目前正在检查 Chrome OS GPT,其中签名似乎已设置为“IGNOREME”。你知道这会产生什么影响吗?

从上面的演示可以看出,如果签名与 不同EFI PART,则无法识别 GPT。

IGNOREME“签名”是铬创建一个特殊的签名。这是我找到IGNOREME文档

cgptlib: Add support for IGNOREME GPT signature

This patch makes cgpt aware of a special "IGNOREME" GPT header signature
string that may appear in either the primary or the secondary GPT and
cause cgpt (and other cgptlib clients) to completely ignore that GPT. It
will continue to function correctly for all other purposes (using the
data from the non-ignored GPT), but never write any data back to the
ignored GPT.

BRANCH=None
BUG=chrome-os-partner:52595
TEST=unit tests

Change-Id: I7e53542385ae9d8d24dc25b75e91f4ff4917f66f
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/340072
Reviewed-by: Nam Nguyen <namnguyen@google.com>
Run Code Online (Sandbox Code Playgroud)

您是否检查了磁盘/块设备末尾的辅助 GPT?

是否还有其他有效的 GPT 签名可用?

不,除了UEFI 规范中EFI PART唯一的签名(参见第 123 页)之外,没有其他签名。(UEFI 规范版本 2.7(勘误 A)的存档副本

  • @Time4Tea:我已经在对上述答案的编辑中回答了您的后续问题。 (3认同)
  • @Time4Tea:正确。您可以从我的回答中的演示中看到,将签名更改为“IGNOREME”后,Linux 无法再识别 GPT 布局。 (2认同)