MacOS – To Rescue Nonbooting OS X with Grub

bootgrubmacos

I had Refind bootloader in Macbook Air 2013-mid. My disk has OSX and broken Ubuntu. Ubuntu messed up my bootloader such that it starts only.
I cannot go to grub/refind by pressing ALT, ALT-R, …
My SIP is disabled.

I followed the guides here and here.
I am now in grub> command prompt where I managed to get by pressing ESC at startup. In grub, ls gives

(proc) (hd0) (hd1) (hd3) (hd1,gpt4) (hd1,gpt2) (hd1,gpt1) error: failure reading sector 0x0 from `hd2'

where

  • hd1 is my SSD find out by ls (hd1)
  • (hd1,gpt1) EFI here, fat filesystem, probably swap size 20kB
  • (hd1,gpt2) 75 GB here, probably OS X
  • (hd1,gpt3) Recovery HD, not sure what
  • (hd1,gpt4) Ubuntu 16.04, 45 Gb here

So I need to setup a bootloader which has (hd1,gpt2) and (hd1,gpt4) in the same table. I may still have refind but not sure, because Ubuntu probably replaced it.
Problem: ls (hd1,gpt2)/ gives

error: unknown filesystem

I cannot configure the bootloader apparently back with Linux grub.
If I could see the contents, I would like to do

set root='(hd1,gpt2)'
...

I really would like to start some live system to fix the thing, but I cannot find any key to boot from USB.

Updates in Linux side

I did many update and upgrade cycles on the Linux side. So the Linux kernel is now 4.4. In startup, I get only Grub menu where is no OS X. Just the Ubuntu and its variations.
So I think the problem is just to link the OS X to Grub but I am not sure about if when I could read OS X filesystem in grub>.

Unsuccessful attempt of installing refind in Linux

In Linux, install refind again

sudo apt-add-repository ppa:rodsmith/refind
sudo apt-get update
sudo apt-get install refind

and answer yes. Restart. However, Grub is still there but not refind.


How can you fix the bootloader in Macbook?

Best Answer

Just run the refind-install script with sudo in the OS X side. I could not get to the recovery mode. This solved the problem.