Skip to content

Instantly share code, notes, and snippets.

@jeromenerf
Created November 26, 2017 10:42
Show Gist options
  • Save jeromenerf/c3d2478082b8508a4f11ba6d39c87a1c to your computer and use it in GitHub Desktop.
Save jeromenerf/c3d2478082b8508a4f11ba6d39c87a1c to your computer and use it in GitHub Desktop.
Grub issues on a Macbook running Debian stable and Mac OS High Sierra

Setup

The machine contains one SSD drive which is partitionned as following:

  • EFI partition, vfat
  • macos partition, apfs (recently converted from something else, pre high sierra)
  • linux swap
  • linux root, ext4

Boot setup

  • grub is installed on the linux root and grub.efi was copied to the EFI fs
  • the grub,efi was blessed by macosx so it could appear in the mac boot list (pressing Option at boot)
  • grub then set its root to (hd0,gpt4) and run the linux kernel

Issue

Since the high sierra update, grub enters rescue mode and stops with a no such partition error. The system cannot be booted.

Indeed, typing at the prompt :

  • ls shows no (hd0,gpt4) but a list of unexpected devices (hd0), (hd1), (hd2), (hd3), (hd4), (hd5), (hd5,gpt4), (hd5,gpt3),(hd5,gpt2), (hd5,gpt1)
  • set shows root and prefix set to the wrong devices : (hd0,gpt4) and (hd0,gpt5)/boot/grub

Workarounds

Rescue

From the rescue prompt:

set prefix=(hd5,gpt4)/grub
set root=(hd5,gpt4)
insmod normal
normal

Grub menu appears and linux can boot if /boot/grub/grub.cfg is correctly set.

Device map

Obviousy, grub doesn't detect the same disk order at the EFI stage and when ran on linux.

grub-mkdevicemap creates a /boot/grub/device.map that can be altered to return (hd5) in place of (hd0).

cat /boot/grub/device.map
(hd5)   /dev/disk/by-id/ata-APPLE_SSD_SM0256F_S1K4NYBDB79405
(hd1)   /dev/disk/by-id/usb-USB_Flash_Disk_FBF1101121103781-0:0

Reinstall grub on this hd5 device

... hopefully setting prefix and root to the correct device

grub-install '(hd5,gpt4)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment