背景
在使用阿里云 redhat 8.2 镜像创建实例时启动信息中如下错误信息打印
[ 3.006529] GPT:Primary header thinks Alt. header is not at the end of the disk. [ 3.007973] GPT:20971519 != 41943039 [ 3.008692] GPT:Alternate GPT header not at the end of the disk. [ 3.009702] GPT:20971519 != 41943039 [ 3.010444] GPT: Use GNU Parted to correct GPT errors. [ 3.011358] vda: vda1 vda2 vda3原因分析
redhat 8.2 使用的是 gpt 格式分区,gpt 格式分区有两个分区表,分别位于分区的首尾
第一个分区表叫作 Primary GPT, 第二个叫作Backup GPT, 也叫作Alternate GPT。
阿里云基础镜像是大小是20G,在实例创建时,会根据用户的选择的大小 进行在线扩容,比如 用户选择的是40G ,那么实例启动时的 分区表 大致结果如下:
这就导致 第二个 gpt table 不在磁盘的末尾,所以启动时内核会报 Alternate GPT header not at the end of the disk。 在实例初始化过程中,cloud-init 会进行分区及文件系统扩容,(扩容至40G) 扩容后的 gpt 分区表大致如下
第二个gpt table 又回到了磁盘的末尾。
所以 在实例启动后,再次重启 ,启动信息中就没有这个报错信息了。
如果要复现这个错误信息,可以给实例 进行 在线磁盘扩容,扩容后执行 fdisk -l
[root@redhat8-2 ~]# fdisk -l GPT PMBR size mismatch (83886079 != 209715199) will be corrected by write. The backup GPT table is not on the end of the device. This problem will be corrected by write. Disk /dev/vda: 100 GiB, 107374182400 bytes, 209715200 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 7E3CDFD9-E4C6-44E5-B774-8875B5C717C5 Device Start End Sectors Size Type /dev/vda1 2048 4095 2048 1M BIOS boot /dev/vda2 4096 208895 204800 100M EFI System /dev/vda3 208896 83886046 83677151 39.9G Linux filesystem会打印The backup GPT table is not on the end of the device 这个信息,此时重启机器,系统启动信息就会打印 GPT:Alternate GPT header not at the end of the disk. 这样的错误了。 执行分区及文件系统扩容后,再重启就 dmesg 里不会有这个信息了。
growpart /dev/vda 3 xfs_growfs /参考链接
https://access.redhat.com/solutions/3236591
https://access.redhat.com/solutions/114503