4

On my Mac OSX Mojave machine.. I installed Ubuntu 18.04 to attempt to dual boot on the internal Apple SSD. Worked for a while, but after some updates to Ubuntu... hitting the power button boots up to a GRUB terminal, and when hitting the option key there is no 'Macintosh HD' as a startup option.

I have seen 2 similar posts on this topic, but none of them appear to exactly match as far as partitions go here and here and I am hesitant to try something that would wipe out or corrupt my OSX data that I know is still on the SSD/drive.

When booting into recovery media, I executed the following command to list disks:

enter image description here

I notice the partition FFFFF-FFFF...

I then do a disktuil info /dev/disk0s2 to look at the info. enter image description here

I then use GPT to check...

gpt -r show /dev/disk0

enter image description here

What can I do to make it so that I can fix my OSX boot partition without losing any files. The disk that my OSX files are stored are on disk0s2, which is the FFFFFFF partition... how do I fix up my ability to boot into the OSX Mojave without wiping out my data or is there a way? Does APFS have anything to do with this?

At this point I don't care about the Ubuntu 18.04 partition, but I do not want to lose any data on the 900+GB partition, which is all my the Mac files are.

4
  • Is the recovery media on the flash drive? If so, what version of macOS? Jan 23, 2019 at 4:08
  • The recovery media I am using is Mojave (latest OSX version), it is just the OS installer on a usb stick. That is what I used to access the terminal as shown in the screen captures. Am hoping using it, I can somehow put in the right commands to fix my OSX boot partition. When I attempt to go to the "Select Startup Disk" GUI window, nothing shows up there.
    – Rolando
    Jan 23, 2019 at 4:11
  • So was Ubuntu only given 27 GB of space? Jan 23, 2019 at 4:21
  • Yes, Ubuntu 18.04 was only given 27 GB. That partition does not have any of my files on it (except for ubuntu related stuff that I am okay with getting rid of that partition if necessary).
    – Rolando
    Jan 23, 2019 at 4:23

2 Answers 2

4

Usually when the FFFFFFFF-FFFF-FFFF-FFFFFFFFFFFF error occurs, the partition starting and ending values are still correct. I assume this is true in your case. If I am correct, then you need to enter the following commands to change FFFFFFFF-FFFF-FFFF-FFFFFFFFFFFF to 7C3457EF-0000-11AA-AA11-00306543ECAC.

diskutil unmountdisk disk0
gpt remove -i 2 disk0
diskutil unmountdisk disk0
gpt add -i 2 -b 409640 -s 1900925984 -t apfs disk0

The EFI partition (disk0s1) is used occasionally by macOS, so you need to keep this partition. However, Grub files were added to this partition when you installed Ubuntu. The commands below will remove any Grub files that may still exist on the EFI partition . You can enter these commands while booted to macOS.

sudo diskutil mount disk0s1
cd /Volumes/EFI/EFI
rm -rf BOOT
rm -rf ubuntu
cd ~
diskutil unmount disk0s1

Since the free space occurs immediately after the partition identified as disk0s2, this free space can be added back to macOS. To add the free space back to macOS , enter the command given below. You can enter this command while booted to macOS.

sudo diskutil apfs resizeContainer disk0s2 0
4
  • Does this answer hold true given my response to your question: " So was Ubuntu only given 27 GB of space?"
    – Rolando
    Jan 23, 2019 at 4:26
  • The Ubuntu partition is gone. I assume Ubuntu was located in the 52874463 blocks of free space. (52874463 blocks * 512 bytes/block = 27,071,725,056 bytes = 27 GB) I assume the APFS container is in the 1900925984 blocks above the free space. If correct, my answer should work, although you might need a sudo. I also assume you do not need to disable SIP when booted from the flash drive. If you do, then I expect an error message. I suppose a hex dump would confirm my answer, but I do think the hexdump command is available. Another solution would involve booting to a live version of Ubuntu. Jan 23, 2019 at 4:54
  • I case you were wondering. Grub probably still exists in your EFI partition (disk0s1). This is why you are still able to boot to Grub. Ubuntu may still exist on the drive, but the Ubuntu partition is no longer listed in the GUID Partition Table (GPT). Jan 23, 2019 at 4:54
  • Upvoted. Thank you so much. You sir are a hero! If I don't want the Grub anymore (or anything Ubuntu decided to put on, are there other commands I can run to get rid of the Grub partition so it's as if I just had Mac on this machine?)
    – Rolando
    Jan 23, 2019 at 5:15
0

If you have or can make the Ubuntu Live USB flash drive installer, then you can boot to the Live version to fix your Mac. Usually when the FFFFFFFF-FFFF-FFFF-FFFFFFFFFFFF error occurs, the partition starting and ending values are still correct. I assume this is true in your case. If I am correct, then you can implement the following steps to change the partition type from FFFFFFFF-FFFF-FFFF-FFFFFFFFFFFF to 7C3457EF-0000-11AA-AA11-00306543ECAC.

  1. Boot from the flash drive to the Live version.

  2. Open a Terminal application window.

  3. Enter the command lsblk to get the name of the internal drive. Here I will assume the name is sda. If you determine an different name, then make the appropriate substitution in the next step.

  4. Enter the following command below to change the partition type.

    sudo gdisk /dev/sda
    

    The gdisk command is interactive. Enter the values given in the first column of the table below.

    Entry Type Comment
    t command change partition's type code
    2 data second GPT entry
    af0a data gdisk's code for 7C3457EF-0000-11AA-AA11-00306543ECAC
    w command write new MBR and new GPT and exit
    y data confirm OK to write
  5. Boot back to macOS.

The EFI partition (disk0s1) is used occasionally by macOS, so you need to keep this partition. However, Grub files were added to this partition when you installed Ubuntu. The commands below will remove any Grub files that may still exist on the EFI partition . You can enter these commands while booted to macOS.

sudo diskutil mount disk0s1
cd /Volumes/EFI/EFI
rm -rf BOOT
rm -rf ubuntu
cd ~
diskutil unmount disk0s1

Since the free space occurs immediately after the partition identified as disk0s2, this free space can be added back to macOS. To add the free space back to macOS, enter the command given below. You can enter this command while booted to macOS.

sudo diskutil apfs resizeContainer disk0s2 0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .