System fails to recognize main macos boot partition after Ubuntu dual booting attempt

bootdual-boothard drivepartitionunix

enter image description here
I recently attempted, and temporarily succeeded, in dual-booting Ubuntu and MacOS Mojave on my MacBook Air. After I installed and successfully tested Ubuntu, I tried to use Disk Utility to create a third partition in ExFat to be shared between the two operating systems. After running for a while, Disk Utility quit unexpectedly, but nothing else seemed out of the ordinary. I tested the new partition on MacOS, and it seemed to work fine. However, when I rebooted my Mac while holding Option, the only bootable disk that showed up was Ubuntu. The output of Disks on Ubuntu (attached image) shows me that the main partition (191 GB Unknown) is no longer recognized, the Shared partition I just created is inexplicably recognized as HFS+ instead of ExFAT as intended.

Is there any way for me to restore MacOS without formatting the damaged partition?

Best Answer

From Ubuntu, you need to run the command gdisk.

  1. Open a Terminal. Basically, press the control+alt/option key combination.
  2. Enter the command given below to execute gdisk.

    sudo gdisk /dev/sda
    
  3. If the version is not at least 1.0.4, then enter the q command to exit gdisk. Next, enter the commands given below to update gdisk, then return to step 2. Otherwise, proceed to step 4.

    sudo apt-get update
    sudo apt-get install gdisk
    
  4. Enter the following when prompted by gdisk. This will change the type for the macOS partition to APFS.

    t
    2
    af0a
    w
    y
    

References

GPT fdisk Tutorial
Man page of gdisk