#[SOLVED] Broken Bootloader (Ran `mkfs.fat -F 32 /dev/efi-partition` with existing EFI partitions

22 messages · Page 1 of 1 (latest)

crimson summit
#

Heya everyone!

I've accidentally run mkfs.fat -F 32 on an existing EFI system partition despite the warning issued here and now I can't boot into my Arch Linux Installation. Pasted below:

Warning: Only format the EFI system partition if you created it during the partitioning step. If there already was an EFI system partition on disk beforehand, reformatting it can destroy the boot loaders of other installed operating systems.

In particular, the BIOS on my motherboard doesn't detect the OS on my hard drive anymore (Linux Boot Manager of my HDD is not there anymore) and just skips to the next entry in the boot menu.

The rest of the partitions (/, /home, and swap partitions) are intact.

Full context as to why this error happened:

I was trying to clone my old HDD with my Arch Linux Installation to my new NVME using dd. I've regained the uniqueness of my partitions using:

tune2fs /dev/sdXY -U random  # For ext4
mkswap -U random /dev/sdXY # For swap

EXCEPT I didn't do something similar for my boot partition (i.e., for the vfat fat32 partition) and thus my UUID for my new boot partition stayed the same. This meant that there were now two partitions with the same UUID. Naturally, in a race condition between an HDD and an NVME, the OS mounted the NVME's boot partition instead of my old HDD partition. All other partitions were mounted correctly on the same HDD, but the boot partition was mounted on the NVME.

I didn't like this very much and wanted to change my boot partition back to my old HDD boot partition, but got confused in reading instructions and ran mkfs.fat -F 32 on the NVME's boot partition, which is exactly what the warning in the ArchWiki warned against.

After booting into an Arch Live ISO and mounting the necessary partitions on my HDD, I've tried to run bootctl install and even tried to install grub, but to no avail.

I appreciate any help you smart guys can offer!

grave stratus
crimson summit
grave stratus
#

For systemd-boot, you need to setup an entry for the kernel for it to work

crimson summit
#

Ah yes I'm using systemd-boot
Are you referring to a command like this?

efibootmgr --create --disk /dev/sdb --part 1 --label "systemd-boot" --loader /EFI/systemd/systemd-bootx64.efi

grave stratus
#

No, that is done automatically

#

You need to make a .conf file in /boot/loader/entries/ for Arch (assuming your EFI partition is mounted at /boot)

#

It'll look something like this

title Arch Linux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options [kernel paramarters here]
#

For kernel parameters, you'll need at least something saying which partition is your root partition, something like root=UUID=[root partition uuid]

#

You can get the UUID of your partitions through blkid

#

If you're using BTRFS you'll need to specify that with rootfstype=btrfs and if you have a root subvolume, include rootflags=subvol=[root subvol]

proud bridge
#

@crimson summit note that if your drive UUIDs change you likely have to update your fstab unless you're not using UUIDs there

proud bridge
crimson summit
#

Thank you everyone for your suggestions!
I'll be trying them out tomorrow
Please pray for me until then)

crimson summit
#

I believe people should get some additional context that I've forgotten to include

Since I don't have a means of either copying my clipboard and sending it to this Discord channel, I apologize for the quality of these pictures

I've included:

  • my lsblk -f output. sda is my Windows D drive, sdb is where my original Arch Linux Installation is (i.e., the one I'm trying to fix), sdc is the Arch Linux live ISO mountpoint (as you might've guessed), nvme1n1 is the NVME to which I copied my old Arch Linux Installation (using dd if=/dev/sdb of=/dev/nvme1n1 # Not the full command, but you get the idea) and finally nvme0n1 is my Windows C drive
  • bootctl output
  • /boot/loader/loader.conf file (note that this file didn't have the default arch.conf line before I added it today, and the other two lines were commented out
  • /boot/loader/entries/arch.conf file

What do you guys make of this information?

grave stratus
#

If you aren't, can you show the output of efibootmgr (it may not be installed in chroot, but out of chroot is fine)

crimson summit
#

I'm not getting any systemd-boot menu as my BIOS doesn't show my HDD (sdb) as a bootable device in the BIOS menu

Here is the output of efibootmgr

I believe the Boot0004 line is from my NVME (new, copied Arch Linux Installation) as my BIOS menu does recognize it as a bootable device (although it doesn't boot when selected and just skips to the next boot entry)

It also matches the order of boot devices I've set up in my BIOS

crimson summit
grave stratus
#

It is a bit hard to tell with all the drives, but it seems to be properly detecting the bootloaders so it should be fine

crimson summit
crimson summit
#

hey fellas! good news!

i've unborked my original Linux install! all i did was just remove the new NVME (i guess the bootloader got confused with some other hidden IDs i don't know about :p)
i figured i should try pulling it out after trying to add a GRUB entry to my old HDD
when adding the entry, my BIOS menu still interpreted it as a GRUB entry for my new NVME
this gave me the idea that the NVME is somehow still "hogging" the boot entry from the HDD, even tho the UUIDs have all been changed

knowing this, i've decided to retry my clone using clonezilla instead of just plain dd
are there any additional steps needed after clonezilla does its job? (e.g., regenerate fstab, regenerate UUIDs, etc.)
i know from a video that clonezilla regenerates the initramfs, but the extent of clonezilla's automation is a mystery to me
where can i find more info on clonezilla about this?