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.


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.

| improve this answer | |
  • Glad that you got it fixed. Cheers mate. – ZVIK Aug 24 '15 at 15:19
  • I had the same issue when I was trying to delete partitions in fdisk - with the same error message (failed to write disklabel: Invalid argument) - and parted prompted me to Fix/Cancel, and after that I was able to delete the partition. Thanks for the answer. – elBradford Aug 14 '16 at 0:02
  • parted or gparted? – tokland Feb 5 '17 at 21:25
  • I run into the same issue and parted solved GPT problem. Use resizepart command in parted to resize partition and then use resize2fs to resize file system. – Sergei G Aug 3 '17 at 16:43

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.

| improve this answer | |
  • In windows we can just do right click expand partition. I am regretting creating a too small partition now its taking me ages to resize this damn thing :( – Piotr Kula Nov 15 '18 at 14:18
  • +1 for explaining the cause of the problem.. Not sure if it matters, but fdisk wouldn't let me start the new partition on sector 1 unless I enabled DOS compatibility mode (c in main menu) and explicitly give 1 as the start sector. Alternatively, gdisk can rebuild the PMBR with n from the advanced menu. – mwfearnley Feb 25 at 9:17

You may need to delete the partition vda3 without writing the changes to the partition table by pressing 'w' and then re-create the partition with the new sector size so that you wont loose the data. You may need to unmount the partition and do a e2fsck before executing the below:

Eg: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
| improve this answer | |
  • Strangely it's not letting me create the bigger partition. Created a new partition 3 of type 'Linux filesystem' and of size 42 GiB. while the maximum should be ~242GB. Trying to create it bigger: First sector (16809984-104857566, default 16809984): 629145599 Value out of range.. – Bart Pelle Aug 24 '15 at 11:11

This is what worked for me when trying to enlarge a GPT partition. As always, when changing a partition table, a backup is vital in case this doesn't go as planned.

First, not all fdisks are created equal. On Ubuntu 18.04, this is the version of fdisk I am using:

$ fdisk -v
fdisk from util-linux 2.31.1

Start up fdisk. Print your partition table with 'p' and verify the existing partition table is GPT:

Disklabel type: gpt

Copy and paste the partition information to another window so you can recreate the partitions with precisely the same start sectors.

Replace the old GPT partition table with a new GPT partition table by pressing 'g'.

Press 'p' again to print out the new table information to verify it now shows the larger size.

Press 'n' to recreate your partitions. All partitions must be recreated with the exact same start and last sectors, except for your last partition, which must have the same start sector but can have a greater ending sector.

If your partitions have filesystems on it, you should see something like this:

Partition #1 contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: N

Respond with 'N' as you want to keep your filesystem signatures.

Back at the fdisk prompt, type 'p' one more time to look at the table to confirm everything looks as it should.

Type 'w' to write (commit) the changes.

From there, exit fdisk and follow a standard procedure to resize your filesystem (e.g., e2fsck -f then resize2fs if ext4). If you're working with a raw disk image file (i.e., for QEMU), then you can use kpartx -av disk.img to get loop devices for your partitions so that you can run e2fsck and resize2fs on those loop devices.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.