Removed 50GB Linux Partition with Disk Utility and Can’t Boot into macOS

bootcampdisk-utilityhard drivepartitionstartup

For a few years, I've had Linux Mint installed on a 50GB partition on my 2015 MacBook Pro. Today, I decided to remove the installation (I needed the extra 50GB and wasn't using Linux Mint anyway) and used Disk Utility to erase the 50GB partition. After rebooting, I was brought into a minimal GRUB at startup. Rebooting a second time (this time while holding the Option key), there was only an EFI boot option. I decided to go into Internet Recovery mode (using Option Command R) and tried to do a fresh install of MacOS. However, the only partition that was available to install MacOS on was the 50GB partition that I had previously erased.

As it currently stands, my laptop is booting from the 50GB partition (while the other 450GB that had my old MacOS installation cannot be accessed anymore). How would I go about accessing my old MacOS installation and recovering the (hopefully not lost) files?

Best Answer

You need to change the TYPE shown in diskutil list from FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF to Apple_APFS.

The steps below outline one possible way to accomplish this.

  1. Download and install GPT fdisk.

  2. Disable SIP or enter the subsequent commands in macOS Recovery.

  3. Enter the command below to confirm you have the correct identifier for the drive.

    diskutil list
    
  4. Enter the GPT fdisk command below. If the drive identifier is not disk0, then make the appropriate substitution. If in macOS Recovery, then omit sudo and prepend gdisk with its path (which I believe would be /Volumes/Untitled/usr/local/bin/).

    sudo gdisk /dev/disk0
    

    This command is interactive. Enter the values in the first column of the table below.

    Entry Type Comment
    s command Sort partitions.
    t command Change a partition's type code.
    2 data Partition number to change.
    af0a data Hex code for partition type.
    w command Write table to disk and exit.
    y data Confirm you you want to proceed.
  5. If you disabled SIP, then enable.