如何在 Linux 上调整 GPT 分区表本身的大小?

如何在 Linux 上调整 GPT 分区表本身的大小?

我已使用dd.

但GPT的大小仍然是1GB。例如,辅助(备份)GPT 仍然位于 1GB(必须移至磁盘末尾)。

我也觉得两个字段主 GPT 内部(偏移量 32 和 48)必须更新。

我已经调查过gdisk但找不到任何东西。

答案1

使用示例gdisk

# gdisk /dev/yourdisk
Command (? for help): v

Problem: The secondary header's self-pointer indicates that it doesn't reside
at the end of the disk. If you've added a disk to a RAID array, use the 'e'
option on the experts' menu to adjust the secondary header's and partition
table's locations.

Identified 1 problems!

gdiskx使用起来可能有点神秘,但它在这里通过专家菜单( , )直接告诉您如何解决此问题e

Command (? for help): x

Expert command (? for help): ?
e   relocate backup data structures to the end of the disk

Expert command (? for help): e
Relocating backup data structures to the end of the disk

此时你可以调整分区或者直接写出来:

Expert command (? for help): v

No problems found. 15624933 free sectors (7.5 GiB) available in 1
segments, the largest of which is 15624933 (7.5 GiB) in size.

Expert command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/yourdisk.

parted也可以使用,当你使用任何命令时它都会要求你修复它:

# parted /dev/yourdisk print
Warning: Not all of the space available to /dev/yourdisk appears to be used, 
you can fix the GPT to use all of the space (an extra 13671875 blocks)
or continue with the current setting?
Fix/Ignore?

fdisk将通过写入来调整 GPT 的大小。

# fdisk /dev/yourdisk

Welcome to fdisk (util-linux 2.39.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

GPT PMBR size mismatch (1953124 != 15624999) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.

Command (m for help): w

The partition table has been altered.
Calling ioctl() to re-read partition table.

答案2

只需写入分区表gdisk即可。w你会看见:

Warning! Secondary header is placed too early on the disk! Do you want to
correct this problem? (Y/N):

y是。如有必要请再次确认。完毕。


或者使用fdisk.你会看见:

GPT PMBR size mismatch (…) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.

同样只需w写入分区表即可。完毕。

相关内容