V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
life90
V2EX  ›  问与答

GPT 规范分区表 CRC32 校验和 到底是怎么计算的?

  •  
  •   life90 · 39 天前 · 669 次点击
    这是一个创建于 39 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近想把某路由的 emmc 换成更小的,需要修改下分区表文件。市面肯定没有相关的分区表文件。就琢磨能不能自己能不能修改分区表文件再刷入。

    其他都可以搞定了,就是这个 crc32 校验怎么都不对。

    Size (in bytes) of each entry in the Partition Entry array - must be a value of 128×2ⁿ where n ≥ 0 (in the past, multiples of 8 were acceptable)

    The Partition Entry array can contain unused entries -- that is, the GUID value is set to zero. For the purposes of the GPT header, these should be counted when considering the Number of Partition Entries field, and should also be taken into account when calculating the CRC32 of the entire array. There should be no more entries in the array, unused or otherwise, than are indicated by this field.

    看上面话的意思,把分区表起始位置中间 128*128 数据以十六进制复制出来,进行 CRC32 计算就可以了。但实际总是不对。我用的 WinHex 。

    可是 gpt 表头 92 字节的 CRC32 计算就没问题。也是这么操作的。

    大家可以提取自己的 gpt 分区表试一试。把前面 34 个扇区保存下来即可。

    dd if=/dev/sda of=gpt.img bs=512 count=35

    4 条回复    2024-08-12 11:55:32 +08:00
    ysc3839
        1
    ysc3839  
       39 天前 via Android
    直接用 fdisk 改不行吗?
    yyzh
        2
    yyzh  
       39 天前 via Android
    路由器用 gpt 分区😲?
    iX8NEGGn
        3
    iX8NEGGn  
       39 天前
    算了,没问题,我用 HxD 算出来的和软件算出来的一致,你是不是没注意小端序写法,或者数据没取对。
    life90
        4
    life90  
    OP
       35 天前
    @ysc3839 在临时 boot 下,没这个命令。不过你到提醒我应该有其他命令。


    @yyzh emmc 现在都用的 gpt 分区


    @iX8NEGGn 我晚点看看,这里图片显示不出来
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1007 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 19:11 · PVG 03:11 · LAX 12:11 · JFK 15:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.