Resizing partition fdisk fails with invalid argument

Solution 1:

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.

Solution 2:

The problem is that the protective MBR (PMBR) is too small. You can change the protective MBR using:

  1. x for extra functionality
  2. M to enter protective/hybrid MBR
  3. (p allows to show the protective MBR)
  4. r to return to main menu (still in protective MBR mode!)
  5. d to delete the wrongly sized protective MBR partition
  6. n to create a new partition and 4xenter to accept defaults settings (primary, partition number 1 and full size)
  7. t and ee to change type to GPT
  8. x for extra functionality
  9. M to leave protective/hybrid MBR mode
  10. r to return to main menu (now in GPT mode again)
  11. w to write

With that I could fix the GPT PMBR size mismatch.

To fix the disklabel issue I had to dump the partition table using O and change last-lba in the exported script to the disksize as reported in fdisk, minus 34 (for secondary GPT). I then reimported the script using I.