MacOS – Disk Utility can’t find free space and Recovery Mode can’t resize

disk-utilityhard drivemacmacospartition

I had Linux installed on my Macbook in dual boot with MacOS.

Today, I uninstalled Linux, so I erased the partitions on which it was installed from Internet Recovery Mode. But, now, when I want to resize my Mac partition to its original size (250GB) ( now it is 200GB, Linux had 50GB in total) one of these 2 things will happen:

  1. If I try to resize it from inside the OS, in Disk Utility, it won't find any free space. It will show that I have 200GB available (my current partition) which is not true.
  2. In Recovery Mode, I am able to see the free space of 50GB but I can't add it to my current partition, nor can I format it as another partition. It would get stuck on "Preparing to partition disk".

enter image description here
disk0s2 is the Recovery partition. Don't ask me why it's name is FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF.

enter image description here

Please, tell me that the solution is not to re-install/format everything. Thanks!

Edit:
enter image description here

Best Answer

Your EFI is missing in the partition table - the content should be still there though - and the Recovery HD's partition has the wrong type.

To salvage this you just have to rewrite the GUID partition table:

  • Boot to Internet Recovery Mode
  • Open Terminal in the menubar > Utilities > Terminal
  • Enter diskutil list and with the disk identifier of the internal disk found there: gpt -r show diskX. Usually it's disk0 - below I assume it's disk0. Use the disk identifier you have found in your environment in the commands below!
  • Unmount the internal disk:

    diskutil umountDisk /dev/disk0
    
  • Remove all partitions:

    gpt remove -i 1 /dev/disk0 
    gpt remove -i 2 /dev/disk0 
    
  • Re-add all partitions:

    gpt add -b 40 -i 1 -s 409600 -t C12A7328-F81F-11D2-BA4B-00A0C93EC93B /dev/disk0
    gpt add -b 391759648 -i 3 -s 1269536 -t 426F6F74-0000-11AA-AA11-00306543ECAC /dev/disk0
    gpt add -b 409640 -i 2 -s 391350008 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/disk0       
    
  • Verify disk and main volume and repair it if necessary:

    diskutil verifyDisk /dev/disk0
    diskutil verifyVolume /dev/disk0s2
    
  • Resize the main volume:

    diskutil resizeVolume /dev/disk0s2 100% #or 250g
    
  • Reboot to your main volume