Skip to content

Instantly share code, notes, and snippets.

@mxlian
Created September 5, 2021 17:04
Show Gist options
  • Save mxlian/2ab6810d0e64cf05f9f5cc298614bca0 to your computer and use it in GitHub Desktop.
Save mxlian/2ab6810d0e64cf05f9f5cc298614bca0 to your computer and use it in GitHub Desktop.
Fix kernel / grub with LUKS crypted partition
# Mounting the LUKS partition is critical, as the name that should be used should match /etc/crypttab in order
# for the rest of the toolchain to work properly
cryptsetup luksOpen /dev/nvme0n1p6 nvme0n1p6_crypt # <-- pay attention to this (should match /etc/crypttab or update-initramfs will fail
vgchange -ay # not sure if needed
lvscan # not sure if needed, no output
# mount FS
mount /dev/mapper/nvme0n1p6_crypt /mnt
# mount unencrypted /boot partition
mount /dev/nvme0n1p5 /mnt/boot
# mount EFI partition. You can find its UUID in /etc/fstab, then match with blkid
mount /dev/nvme0n1p2 /mnt/boot/efi/
mount -o bind /proc /mnt/proc
mount -o bind /dev /mnt/dev
mount -o bind /sys /mnt/sys
# Chroot
chroot /mnt
# Reinstall kernel
apt install --reinstall linux-image-5.4.0-81-generic
update-grub
exit # exit chroot
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment