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

41 天前
 life90

最近想把某路由的 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

671 次点击
所在节点    问与答
4 条回复
ysc3839
41 天前
直接用 fdisk 改不行吗?
yyzh
41 天前
路由器用 gpt 分区😲?
iX8NEGGn
41 天前
算了,没问题,我用 HxD 算出来的和软件算出来的一致,你是不是没注意小端序写法,或者数据没取对。
life90
37 天前
@ysc3839 在临时 boot 下,没这个命令。不过你到提醒我应该有其他命令。


@yyzh emmc 现在都用的 gpt 分区


@iX8NEGGn 我晚点看看,这里图片显示不出来

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1063553

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX