Background
I’ve been using Arch Linux for quite a while now and had to fix a few issues here and there.
However, perhaps the most annoying one is having my ReFIND bootloader completely erased everytime Windows or Lenovo UEFI decides to update.
This issue happens on my laptop because my Windows and Linux partitions are forced to coexist on the same drive. As a result, conflicts will occur and my ReFIND bootloader gets erased.
In my case, ReFIND allows me to select either Windows or Linux to boot into by detecting bootable partitions on all drives in the computer. With it gone, I can’t boot into Linux and instead have to chroot into my installation to reconfigure ReFIND.
Because this happens pretty frequently to me, I wanted to document the process in case I ever forget how to do it in the future. If anyone else has the same issues, this might also help them recover their system.
Prepping a USB Drive
This recovery process is actually quite simple.
First, you need to burn a live boot environment like the Arch Linux install .iso onto a USB drive. I recommend using Rufus or Ventoy to burn an ISO.
Tip (Ventoy's Functionality)
Personally, I like using Ventoy for whatever installation or live environment needs I have.
It provides a nice user interface for selecting the boot .iso of choice, and the utility allows you to very easily drag and drop .iso files to be booted directly onto the USB!
Retrieve the Arch Linux .iso and burn it to USB. Then, plug in your USB and boot to that device using your computer’s UEFI or BIOS settings. This will vary depending on your computer model, but typically involves entering UEFI/BIOS through hitting the right function keys on start.
Once you’re into the Arch Linux live environment, you should be able to start identifying your drives and mounting!
Detecting Drives
I typically like to use the following two commands to determine which drives correspond to what:
> fdisk -l Disk /dev/nvme0n1: 953.87 GiB, 1024209543168 bytes, 2000409264 sectors Disk model: ************** Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: **************
Device Start End Sectors Size Type /dev/nvme0n1p1 2048 206847 204800 100M EFI System /dev/nvme0n1p2 206848 239615 32768 16M Microsoft reserved /dev/nvme0n1p3 239616 2336767 2097152 1G Linux filesystem /dev/nvme0n1p4 2336768 10725375 8388608 4G Linux filesystem /dev/nvme0n1p5 10725376 717039615 706314240 336.8G Linux filesystem /dev/nvme0n1p6 717039616 1998911487 1281871872 611.2G Microsoft basic data /dev/nvme0n1p7 1998911488 2000406527 1495040 730M Windows recovery environment> lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS nvme0n1 259:0 0 953.9G 0 disk ├─nvme0n1p1 259:1 0 100M 0 part ├─nvme0n1p2 259:2 0 16M 0 part ├─nvme0n1p3 259:3 0 1G 0 part /boot ├─nvme0n1p4 259:4 0 4G 0 part ├─nvme0n1p5 259:5 0 336.8G 0 part / ├─nvme0n1p6 259:6 0 611.2G 0 part └─nvme0n1p7 259:7 0 730M 0 partHere, we can see that the EFI system partition corresponds to our EFI bootloader partition and the large Linux partition should correspond to our root partition.
Therefore, /dev/nvme0n1p1 is our EFI partition and /dev/nvme0n1p5 is our root partition.
Keep these in mind for later!
Chroot into Disk!
Now that we have our partitions identified, we can set everything up for arch-chroot to take care of the rest!
All we need to do is identify what the EFI partition is, and what the root partition is.
To do this, we’re going to use the mount command to temporarily mount our drives so that they are read/writable.
Mounted drives in Linux must be given a directory to which they are mounted to. There is a specific folder called
/mnt in Linux for this purpose.
> mount /dev/YOUR_ROOT_PARTITION /mnt> mount --mkdir /dev/YOUR_EFI_PARTITION /mnt/bootUsing those two commands, we mount our critical Linux filesystem partitions to /mnt to allow them to be read and written to.
Now, we can simply use the arch-chroot command!
This should drop us into a root shell, as if we were root in our booted Linux install.
Reconfiguring Bootloader
For the purposes of this post, I’m going to talk about how to reinstall ReFIND. However, GRUB or other bootloaders should have a similar, simple process.
For ReFIND, all we need to do now is to run the refind-install command.
If you’ve previously installed ReFIND, this should be present on your (chrooted) system.
After this runs, congrats! You’ve reinstalled your bootloader and everything should work as expected.
You can unmount the drives and reboot now, making sure to take out the USB drive. You should see ReFIND or GRUB appear. If not, follow the same steps and debug the installation of your desired bootloader.