GRUB/Restore the GRUB Bootloader
Overview
In order to load the operating system, a Linux-capable boot loader such as GRUB, rEFInd or Syslinux needs to be installed to the Master Boot Record (MBR) or the GUID Partition Table (GPT) of the media containing the Operating System. Installations created using Manjaro ISO defaults to GRUB.
For various reasons - it happens the bootloader get's corrupted, erased or misconfigured resulting to a black screen with a failure message during boot, like No boot loaders found in /dev/.... To restore system operation without re-installing your OS or losing your data you will need to use your Manjaro installation media, such as, a CD/DVD or USB Flashdrive.
Preparation
Identify the type of system you are attempted to resque as the commands involved are slightly different.
- BIOS/MBR/GPT system
- EFI/GPT system
Load Manjaro Installation Media
Identify partitions
To identify your partitions and their designated use you need to run a partition manager. Depending on environment there is various tools. GTK based ISO offers GpartEd, QT based ISO offers KParted and common to all is the CLI tools.
More comprehensive information can be found using fdisk
(requires superuser) and you can limit the probed device e.g. /dev/sda or /dev/nvme0n1
The clues to look for is mbr vs. gpt and the presence of a small partition - usually the first - formatted with the vfat filesystem followed by a larger partition formatted as ext4.
Use root context
When you have loaded the live ISO - depending on environment - open a terminal and switch to root context. Use above mentioned root:password combination.
Chroot environment
Chroot is a method to restrict various tasks to a restricted area e.g. package installation and other system maintenance tasks. Follow the link to read more about chroot on the Arch wiki.
Identify system partitions
From the above we assume you have identified the relevant partitions on your system and this document will refer the partitions as follows. Partitions not needed for this kind of maintenance has intentionally been left out (e.g. home, swap).
Partition | Usage | Comment |
---|---|---|
/dev/sdyA |
EFI system | Required for EFI system and mounted on /boot/efi |
/dev/sdyB |
boot | Optional but mounted on /boot The primary use is when GRUB cannot write to / (eg. f2fs) |
/dev/sdyC |
root | Required and for the root filesystem and mounted on / - usually formatted using ext4 |
Use manjaro-chroot
Manjaro deploys a script called manjaro-chroot
takes an optional argument which will search the visible devices - scan the partitions for signs of an operating system. If more than one Linux operating system is found you will get a choice of which system to chroot otherwise the file /etc/fstab from the system is used to mount the partitions and chroot into this system.This script is only available in live iso by default but you can get it in an installed system by installing manjaro-tools-base
package.
Manual chroot
(Unnecessary if you have used manjaro-chroot
)
Mount the partitions using the designated temporary mountpoint and always start with root
Then - if applicable - mount boot
Then - if applicable - mount efi
Create the chroot environment and use bash as shell
Reinstall GRUB
One possible cause why you are reading this document - is an unfinished update - which in turn can be caused by several situations - situation we will not dive into. To fix what ever caused this you should run a full system update including grub to ensure everything is in place.
When the transaction as completed continue below using the section matching your system
BIOS System
On a BIOS/GPT system there is no MBR and therefore no place to store the loader. The GPT partition specification allows for an unformatted partition of the BIOS boot partition type (0xEF02). The size of this partition can be as small as 1 mebibyte. The Calamares installer uses a fixed size of 32 mebibyte. On a BIOS/MBR system a part of the bootloader is written to the Master Boot Record for the primary disk.
The device is the disk (not a partition)
Make sure the grub configuration is up-to-date
EFI System
Reinstall grub
Update the grub configuration
Verify the existance of an EFI system partition
Verify the efi filesystem is loaded
Exit chroot
Try loading the efi filesystem
Re-enter chroot
Then mount the efi filesystem
Verify the efi filesystem is loaded
If successfull re-run above installation commands
Updating grub
Sometimes there is also an update for the GRUB package itself. So far, the grub package is updated, but this new GRUB is not automatically installed in the boot area.
You can do this manually following the instructions above. Or you can install the Grub Maintainer Script install-grub. It should work flawless for the majority of people, but SecureBoot, ZFS and fancy encryptions are not supported yet.
Then once run
The package includes a hook that will reinstall the bootloader when needed from now on at every update of grub.
Troubleshooting
Manjaro is not recognized
If Manjaro wasn't recognized after an update-grub then probably your Manjaro installation is missing the package lsb-release.
Confusing names
Some things around grub can be confusing.
package version of grub
Its the version of the grub-package present in your filesystem. But this version changing does not update the installed grub-bootloader.
grub-bootloader version
This can only been shown while you are in the Grub menu (that won’t show up while booting by default, you need to hit shift during boot). Hit the key [E] and your will see the Grub version on top.
update-grub
Does not update the installed bootloader. The ‘update’ is more about updating configuration. Think of this more as ‘applying settings’. (~ equal to grub-mkconfig -o /boot/grub/grub.cfg)
install-grub
is another script that does update the installed bootloader that runs when you turn your computer on. (it attempts to automate a system-dependent command that can look different on different setups, but an example would be: sudo grub-install --target=x86_64-efi --efi-directory=/efi --bootloader-id=Manjaro --recheck)