Reinstall GRUB and Kernels

 Published on 18 Dec 2023 .  Filed in Notes .  388 words
Table of Contents

Identify Disks and Partitions

lsblk -f

Explanation This lists all disks, including:

  • LUKS encrypted root partition
  • EFI partition (usually FAT32)
  • /boot partition (ext4 or similar)

Unlock Your LUKS Root Partition

sudo cryptsetup luksOpen /dev/sdXN cryptroot

Explanation

  • /dev/sdXN → your encrypted root partition
  • cryptroot → name for the unlocked mapper device

After unlocking, it appears as: /dev/mapper/cryptroot

Mount the Root Filesystem

sudo mount /dev/mapper/cryptroot /mnt

Explanation This mounts your decrypted root filesystem to /mnt.

Mount /boot Partition (if separate)

sudo mount /dev/sdXY /mnt/boot

Explanation Mount the separate /boot partition so kernels and initramfs can be written.

Mount EFI System Partition

sudo mount /dev/sdXZ /mnt/boot/efi

Explanation Mount the FAT32 EFI partition so GRUB can reinstall its EFI files.

Bind System Directories for chroot

for i in /dev /dev/pts /proc /sys /run; do
  sudo mount --bind $i /mnt$i
done

Explanation This makes the chroot environment act like a real running system.

Enter chroot

sudo chroot /mnt

Explanation You are now "inside" your installed Arch system as root.

Update Package Database

pacman -Syu

Explanation Refresh the package database and update installed packages. Ensures kernel and GRUB reinstall cleanly.

Install or Reinstall Both Kernels

pacman -S linux linux-headers
pacman -S linux-lts linux-lts-headers

Explanation

  • linux → latest Arch kernel
  • linux-lts → stable long-term support kernel

Headers are required for DKMS modules.

Having both gives redundancy.

Rebuild Initramfs for All Kernels

mkinitcpio -P

Explanation

  • Rebuilds initramfs for every installed kernel
  • Ensures correct LUKS hooks are included

Equivalent to rebuilding:

  • initramfs-linux.img
  • initramfs-linux-fallback.img
  • initramfs-linux-lts.img
  • initramfs-linux-lts-fallback.img

Reinstall GRUB (UEFI)

grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB

Explanation

  • Installs GRUB into the EFI System Partition
  • Creates a new UEFI boot entry

This fixes any broken signature or missing GRUB binaries.

Regenerate GRUB Configuration File

grub-mkconfig -o /boot/grub/grub.cfg

Explanation GRUB scans:

  • the latest kernel
  • the LTS kernel
  • fallback initramfs images
  • your LUKS setup

Generates a new boot menu.

Exit chroot and Unmount Cleanly

exit
for i in /dev/pts /dev /proc /sys /run; do
  sudo umount /mnt$i
done
sudo umount /mnt/boot/efi
sudo umount /mnt/boot
sudo umount /mnt
sudo cryptsetup luksClose cryptroot

Reboot

reboot

You should now see GRUB with:

  • Arch Linux (Latest Kernel)
  • Arch Linux (LTS Kernel)
  • Fallback images

Important Note for LUKS Users

Your /etc/mkinitcpio.conf must contain:

HOOKS=(base udev autodetect modconf block encrypt filesystems keyboard fsck)

If changed:

mkinitcpio -P