Resizing partition fdisk fails with invalid argument

arch-linuxfdiskgptpartition

I recently resized a VPS from a 50GB SSD to a 300GB SSD through my hoster's control panel. I now am trying to resize my main partition with fdisk to be able to use all the new space. However, fdisk gives me a warning upon starting:

GPT PMBR size mismatch (104857599 != 629145599) will be corrected by w(rite).
GPT PMBR size mismatch (104857599 != 629145599) will be corrected by w(rite).

It seems obvious that it's a sixfold of the previous size, as I went from 50GB to 300GB. So, I decide to follow the hint and write the table…

Command (m for help): w
GPT PMBR size mismatch (104857599 != 629145599) will be corrected by w(rite).
fdisk: failed to write disklabel: Invalid argument

.. which does not work. I can't find what causes that error anywhere despite many search queries. I do not use LVM and my partition table looks like:

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

Notice how the disk shows it as 300GiB, so it does recognize the size change.

Best Answer

I managed to solve this rather simply. I installed parted and when I ran that it informed me that the partition table didn't cover the full disk (duh), so it asked me Fix/Cancel to which I responded with Fix. Apparently, that did the trick as I was able to modify the partition to the full size using sudo fdisk /dev/vda, but afterwards I did need to run sudo resize2fs /dev/vda3 to have the changes applied.

Related Topic