Restoring Manjaro Grub after Ubuntu upgrade

On a multi-boot Linux computer where Ubuntu has already been installed, adding on Manjaro Linux installs its own version of Grub (that I’ll call Arch-Grub) that is different but compatible with that previously installed (that I’ll call Debian-Grub).

Addendum:  The below instructions worked for Manjaro releases before March 2018.  For some instructions dated May 2021 (that worked in February 2022), see “Restore Manjaro boot after dualbooted Ubuntu-Mate replaced grub” at  https://forum.manjaro.org/t/restore-manjaro-boot-after-dualbooted-ubuntu-mate-replaced-grub/67583/2 

  • On some of my laptops, the “grub-install — rechedk — no-rs-codes” would give a response “grub-install: error: install device isn’t specified”.
  • The manual command was then “grub-install /dev/sda” for the laptop with a single drive, and “grub-install /dev/sdb” for the laptop with two drives where I wanted to not boot off the first drive with Windows installed.

Updating Ubuntu to a newer version (or installing an older version) restores Debian-Grub, replacing the working Arch-Grub.  This will result in Debian-Grub showing both Ubuntu and Manjaro as options on booting.  Choosing Ubuntu from Arch-Grub works just fine.  However, choosing Manjaro from Debian-Grub will lead to a black screen with messages, e.g.:

… Failed to execute /init (error -13)
… Starting init: /sbin/init exists but couldn’t execute it (error -13)
… Starting init: /bin/init exists but couldn’t execute it (error -13)
… Starting init: /bin/sh exists but couldn’t execute it (error -13)
… Kernel panic – not syncing: No working init found. Try passing init option to kernel …

… —[ end Kernel panic – not syncing: No working init found …

Kernel Panic after upgrade

“Kernal Panic after upgrade” as reported by ben1 in December 2017

On my Thinkpad X200, the only way to exit this screen was to pull the battery for a cold reboot.

The reason that Arch-Grub is different from Debian-Grub is that it loads Intel microcode before the OS, rather than inside the OS.

Manjaro will load intel-ucode using grub.
Unlike other OS’s, it is not built into initd (initramfs) nor into kernel.
But it will load this separately (first) from /boot/intel-ucode.img

But don’t worry about this. It will be done automatically for you when you install or boot Manjaro (provided you use Manjaro’s bootloader (grub) as default bootloader).

… says gohlip | “Does manjaro supply intel microcode automatically?” | May 2016 at https://forum.manjaro.org/t/does-manjaro-supply-intel-microcode-automatically/646/2

Thus, Arch-Grub does more work than Debian-Grub.  Arch-Grub will successfully start Ubuntu (based on Debian), but Debian-Grub will not successfully start Manjaro (based on Arch).  The resolution is to replace Debian-Grub with Arch-Grub to the multiboot system.

gohlip suggests seven ways to fix this …

1. chroot from livecd (which you’re aware of, I think)
2. use this method which does not need chroot or boot livecd but still make manjaro default boot
3. remove intel-code from manjaro OS but you’ll boot Manjaro without intel microcode enabled
4. …

The Intel microcode updates are theoretically desirable for patches, e.g. Spectre, but unfortunately the Core 2 Duo Penryn CPU I have isn’t one of the them, says “Intel finishes Spectre patching, some older CPUs won’t receive planned updates” | Brad Chacos | April 4, 2018 at https://www.pcworld.com/article/3268007/components-processors/intel-finishes-spectre-cpu-patches-cancels-update-plans.html

After digging into trying to remove the intel-ucode, I figured out it was simpler to just use a Manjaro install DVD (or USB) to restore the Arch-Grub. This then has to be done after every Ubuntu upgrade … but is relatively straightforward (and having a Manjaro install ISO burned onto a DVD means that it’s readily at hand).

Here’s a summary of the steps I’ve used:

  1. With Ubuntu running, use GPartEd to confirm which partition has Manjaro installed.  (In my case, it was sda11).
  2. Boot from the Manjaro install DVD or USB.
  3. When the menu appears, choose the LiveDVD option (rather than immediately (re-)installing Manjaro, which isn’t necessary).
  4. Open a terminal.
  5. Confirm the partition with Manjaro installed:
    $ sudo fdisk -l
    $ lsblk -f
  6. Mount the Manjaro system partition (mine was sda11):
    $ sudo mount  /dev/sda11  /mnt
  7. Reinstall Arch-Grub:
    $ sudo  grub-install  –boot-directory=/mnt/boot  /dev/sda

(That’s two hyphens preceding “boot-directory”)!

This method is consistent with the description of “Restore the GRUB Bootloader” at https://wiki.manjaro.org/index.php?title=Restore_the_GRUB_Bootloader for a BIOS (not UEFI) system.

While this procedure will have to be repeated after every Ubuntu upgrade, it’s understandable and replicable.

#arch, #boot, #debian, #dual-boot, #kernel-panic, #manjaro, #multiboot, #ubuntu