我最近通过我的主机的控制面板将VPS从50GB SSD调整到300GB SSD。 我现在正在尝试使用fdisk来调整我的主分区,以便能够使用所有新的空间。 但是,fdisk在启动时给我一个警告:
GPT PMBR size mismatch (104857599 != 629145599) will be corrected by w(rite). GPT PMBR size mismatch (104857599 != 629145599) will be corrected by w(rite).
看起来很明显,这是以前的六倍,从50GB到300GB。 所以,我决定按照提示写下表格。
Command (m for help): w GPT PMBR size mismatch (104857599 != 629145599) will be corrected by w(rite). fdisk: failed to write disklabel: Invalid argument
..哪个不行。 尽pipe有许多search查询,但我无法find导致该错误的原因。 我不使用LVM,我的分区表如下所示:
Disk /dev/vda: 300 GiB, 322122547200 bytes, 629145600 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: 30D92031-0C13-42FF-AC16-D34F36DD3907 Device Start End Sectors Size Type /dev/vda1 2048 32767 30720 15M BIOS boot /dev/vda2 32768 16809983 16777216 8G Linux swap /dev/vda3 16809984 104857566 88047583 42G Linux filesystem
注意磁盘是如何显示为300GiB的,所以它可以识别大小的变化。
我设法解决这个很简单。 我安装了parted,当我跑了,它告诉我,分区表并没有覆盖整个磁盘(杜),所以它问我Fix/Cancel我回应了Fix 。 显然,这样做的窍门,因为我能够使用sudo fdisk /dev/vda将分区修改为全尺寸,但之后我确实需要运行sudo resize2fs /dev/vda3才能应用更改。
您可能需要删除分区vda3,而不必通过按'w'将更改写入分区表,然后重新创build具有新扇区大小的分区,以避免丢失数据。 您可能需要卸载分区并执行以下操作之前执行e2fsck:
例如:fdisk / dev / vda
Enter p Delete the partition 'd' (Partition number is 3)' Create new partition 'n' Select the Start sector: Select the end sector:(New Size) Write the changes to the disk: Update the partition table: (partprobe /dev/vda) #resize2fs /dev/vda3 #mount the partition