Skip to content

Instantly share code, notes, and snippets.

@owngr
Forked from samuelcolvin/repair_boot.md
Last active July 31, 2025 10:22
Show Gist options
  • Select an option

  • Save owngr/6e7f16e669aa4cc1092c8e29a38a629a to your computer and use it in GitHub Desktop.

Select an option

Save owngr/6e7f16e669aa4cc1092c8e29a38a629a to your computer and use it in GitHub Desktop.
repairing boot for LUKS encrypted fs

Guides:

# Repair debian work
cryptsetup luksOpen /dev/nvme0n1p3 encrypted
# Repair debian private
cryptsetup luksOpen /dev/nvme1n1p2 encrypted

vgchange -ay
lvscan
mkdir -p /media/linux
mount /dev/mapper/encrypted /media/linux/
mount -o bind /proc /media/linux/proc
mount -o bind /dev /media/linux/dev
mount -o bind /sys /media/linux/sys
# needed for efivars
mount -t devpts pts /media/linux/dev/pts/

chroot /media/linux /bin/bash
> fdisk -l:

Disk /dev/nvme1n1: 476.96 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: SAMSUNG MZVLB512HAJQ-00000              
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: BFF47E0A-5412-4D63-A954-10275C9785F7

Device           Start        End   Sectors   Size Type
/dev/nvme0n1p1    2048    1050623   1048576   512M EFI System
/dev/nvme0n1p2 1050624    2549759   1499136   732M Linux filesystem
/dev/nvme0n1p3 2549760 1000214527 997664768 475.7G Linux filesystem
# Debian work
mount /dev/nvme0n1p2 /boot
# Debian private
mount /dev/nvme1n1p1 /boot

mount /dev/nvme0n1p1 /boot/efi
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
# debian work
grub-install /dev/nvme0n1 --bootloader-id debian
# debian private
grub-install /dev/nvmen1 --bootloader-id debianpriv


umount /boot/efi
umount /boot

leave chroot

exit 
umount /media/linux/boot/efi
umount /media/linux/boot
umount -l /media/linux
vgchange -an
cryptsetup luksClose encrypted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment