How to Reinstall the Boot Loader in Arch Linux
Last Update: Mar 25, 2023
Want to learn more about Linux? Live shows every week. Follow my channel!
Recently I tried dual-booting FreeBSD and Arch Linux on my laptop. I already installed Arch Linux and left a partition open for FreeBSD later. I hosed my Grub, and the machine wouldn’t boot.
It’s an easy fix, so I wanted to share it. This is similar to how to restore your bootloader after installing Windows. The only difference is this laptop is 100% Arch Linux, and it’s a UEFI machine.
So, let’s say you’re like me and have Arch Linux installed, and you’ve toasted your GRUB bootloader. Here’s what you do.
Boot from an Arch Linux ISO
The first step is to get an Arch Linux ISO, burn it to a USB stick, and boot it.
Select the first option:
You’ll land on a prompt that looks like this:
Know Your Disks
It’s important to know where your disks are and what partitions are where. You can do this by checking with:
As you can see on my machine, I have my hard drive (/dev/sda), an SDcard (/dev/mmcblk0), and the USB drive I booted into Arch with (/dev/sdb1). I’m most concerned with /dev/sda.
/dev/sda1 is my EFI system. /dev/sda2 is where my Linux installation is that I need to point to again.
Technically since I only have one operating system, I don’t need GRUB, but I have it set up because someday I’ll take the time to wrangle in FreeBSD or something else. I digress.
Mount Your Arch System
I need to mount the
/ partition of my Arch system.
mkdir /mnt/arch mount -t auto /dev/sda2 /mnt/arch
Ok, now it’s mounted, and time to chroot into it.
Now my system is up and running on my root drive. Any changes made here will be as if I logged into my system.
Next, I’ll mount my EFI folder:
mount -t auto /dev/sda1 /efi
I’ll need that when running my update.
Now I need to update GRUB. First, I’ll run OS Prober:
I only have one, but it will update my GRUB config. If you have multiple operating systems, you should do this as well. It should find them.
Now I’ll copy over the new grub config:
grub-mkconfig > /boot/grub/grub.cfg
Cool! I’m ready to install it now.
Now I’ll need to install GRUB again, and I do that with the following command:
grub-install --efi-directory=/efi --target=x86_64-efi /dev/sda
Now, this is the string that’s tricky to find in the documentation. There are many options for grub-install, and I learned the above string works due to trial and error, which is why I’m sharing it.
Sweet! Now it’s time to reboot.
If you see this, you’re a happy camper! There’s the GRUB menu!
I’ve hosed my GRUB boot so many times I’ve become a pro at this. I hope it helps! Let me know if you have any questions!
Want to learn more about Linux? Of course you do. Check out this Linux Fundamentals course. You can sign up for a free trial here and take it today!