Erased boot partition, how to regenerate it?

While trying to remove my broken Windows installation, KDE Partition Manager erased my /boot partition. The system is still running. How do I regenerate the boot partition so that my system will still work once I reboot? I use systemd-boot as the bootloader.

I already tried sudo mkinitcpio -p linux-cachyos in the hope it would put the kernel image back but that just complains about the files not existing anymore.

Well assuming you have recreated your ESP partition…if it was destroyed, try ‘bootctl install’.

Create the partition again, run “bootctl install” and then “sudo sdboot-manage gen”

I had to mount the new partition at /mnt/boot as it doesn’t seem to pick it up without a reboot. After setting SYSTEMD_RELAX_ESP_CHECKS to 1 I was able to run bootctl install --esp-path=/mnt/boot.

However sdboot-manage gen --esp-path=/mnt/boot gives the error “There are no boot loader entries after entry generation”, probably because there is no kernel image file.

Since the new partition wasn’t even recognized, I chrooted into the system from a live USB and did it again. I used cp /usr/lib/modules/6.10.6-3-cachyos/vmlinuz /boot/vmlinuz-linux to put the kernel image back so that the boot loader entry can be generated.

However now it says “Error preparing initrd: Not found” in red flashing letters when turning the computer on.

THis is not how it works. You just need to reinstall the kernel, to generate these freshly.
Also, it would be not the “vmlinuz-linux”, it would be “vmlinuz-linux-cachyos”

Just run in the chroot, if properly mounted:
sudo pacman -Sy linux-cachyos linux-cachyos-headers

This will put this into the correcte directorys and regenerate the initramfs with mkinitcpio.

linux-cachyos-headers did it, thanks! Regenerating the bootloader entries from within a chroot messed up the ld.luks.name option in the entry but after changing it back to what it said in /etc/fstab my system works again!

1 Like