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.

Revisions

  1. owngr revised this gist Jul 31, 2025. 1 changed file with 13 additions and 2 deletions.
    15 changes: 13 additions & 2 deletions repair_boot.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,11 @@ Guides:


    ```
    # Repair debian work
    cryptsetup luksOpen /dev/nvme0n1p3 encrypted
    # Repair debian private
    cryptsetup luksOpen /dev/nvme1n1p2 encrypted
    vgchange -ay
    lvscan
    mkdir -p /media/linux
    @@ -38,14 +42,21 @@ Device Start End Sectors Size Type
    ```

    ```
    # 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
    grub-install /dev/nvme0n1 --bootloader-id debian|debianpriv
    **OR** update-grub
    # debian work
    grub-install /dev/nvme0n1 --bootloader-id debian
    # debian private
    grub-install /dev/nvmen1 --bootloader-id debianpriv
    umount /boot/efi
    umount /boot
  2. owngr revised this gist Aug 17, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions repair_boot.md
    Original file line number Diff line number Diff line change
    @@ -44,7 +44,7 @@ mount /dev/nvme0n1p1 /boot/efi

    ```
    mount -t efivarfs efivarfs /sys/firmware/efi/efivars
    grub-install /dev/nvme0n1
    grub-install /dev/nvme0n1 --bootloader-id debian|debianpriv
    **OR** update-grub
    umount /boot/efi
    @@ -60,5 +60,5 @@ umount /media/linux/boot/efi
    umount /media/linux/boot
    umount -l /media/linux
    vgchange -an
    cryptsetup luksClose home_sdb3
    cryptsetup luksClose encrypted
    ```
  3. owngr revised this gist Aug 17, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion repair_boot.md
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ Guides:
    cryptsetup luksOpen /dev/nvme0n1p3 encrypted
    vgchange -ay
    lvscan
    mkdir /media/linux
    mkdir -p /media/linux
    mount /dev/mapper/encrypted /media/linux/
    mount -o bind /proc /media/linux/proc
    mount -o bind /dev /media/linux/dev
  4. owngr revised this gist Aug 17, 2024. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions repair_boot.md
    Original file line number Diff line number Diff line change
    @@ -6,11 +6,11 @@ Guides:


    ```
    cryptsetup luksOpen /dev/nvme0n1p3 home_sdb3
    cryptsetup luksOpen /dev/nvme0n1p3 encrypted
    vgchange -ay
    lvscan
    mkdir /media/linux
    mount /dev/ubuntu-vg/root /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
    @@ -45,7 +45,7 @@ mount /dev/nvme0n1p1 /boot/efi
    ```
    mount -t efivarfs efivarfs /sys/firmware/efi/efivars
    grub-install /dev/nvme0n1
    **OR** grub-update
    **OR** update-grub
    umount /boot/efi
    umount /boot
  5. owngr revised this gist Apr 18, 2023. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions repair_boot.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ Guides:


    ```
    cryptsetup luksOpen /dev/nvme1n1p3 home_sdb3
    cryptsetup luksOpen /dev/nvme0n1p3 home_sdb3
    vgchange -ay
    lvscan
    mkdir /media/linux
    @@ -15,7 +15,7 @@ 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 /mnt/dev/pts/
    mount -t devpts pts /media/linux/dev/pts/
    chroot /media/linux /bin/bash
    ```
    @@ -32,19 +32,19 @@ Disklabel type: gpt
    Disk identifier: BFF47E0A-5412-4D63-A954-10275C9785F7
    Device Start End Sectors Size Type
    /dev/nvme1n1p1 2048 1050623 1048576 512M EFI System
    /dev/nvme1n1p2 1050624 2549759 1499136 732M Linux filesystem
    /dev/nvme1n1p3 2549760 1000214527 997664768 475.7G Linux filesystem
    /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
    ```

    ```
    mount /dev/nvme1n1p2 /boot
    mount /dev/nvme1n1p1 /boot/efi
    mount /dev/nvme0n1p2 /boot
    mount /dev/nvme0n1p1 /boot/efi
    ```

    ```
    mount -t efivarfs efivarfs /sys/firmware/efi/efivars
    grub-install /dev/nvme1n1
    grub-install /dev/nvme0n1
    **OR** grub-update
    umount /boot/efi
  6. owngr revised this gist Mar 22, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions repair_boot.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@ Guides:
    * https://stephentanner.com/restoring-grub-for-an-encrypted-lvm.html
    * https://askubuntu.com/questions/719409/how-to-reinstall-grub-from-a-liveusb-if-the-partition-is-encrypted-and-there-i
    * https://help.ubuntu.com/community/Grub2/Installing
    * https://unix.stackexchange.com/a/414289


    ```
  7. owngr revised this gist Mar 22, 2023. No changes.
  8. owngr revised this gist Mar 22, 2023. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions repair_boot.md
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,9 @@ mount /dev/ubuntu-vg/root /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 /mnt/dev/pts/
    chroot /media/linux /bin/bash
    ```

    @@ -39,6 +42,7 @@ mount /dev/nvme1n1p1 /boot/efi
    ```

    ```
    mount -t efivarfs efivarfs /sys/firmware/efi/efivars
    grub-install /dev/nvme1n1
    **OR** grub-update
  9. @OlivierWenger OlivierWenger revised this gist May 27, 2021. 1 changed file with 11 additions and 10 deletions.
    21 changes: 11 additions & 10 deletions repair_boot.md
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@ Guides:


    ```
    cryptsetup luksOpen /dev/sdb3 home_sdb3
    cryptsetup luksOpen /dev/nvme1n1p3 home_sdb3
    vgchange -ay
    lvscan
    mkdir /media/linux
    @@ -19,26 +19,27 @@ chroot /media/linux /bin/bash
    ```
    > fdisk -l:
    Disk /dev/sdb: 238.5 GiB, 256060514304 bytes, 500118192 sectors
    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: ED00E611-2AA0-40CB-BA69-97B8FAD3303E
    Disk identifier: BFF47E0A-5412-4D63-A954-10275C9785F7
    Device Start End Sectors Size Type
    /dev/sdb1 2048 1050623 1048576 512M EFI System
    /dev/sdb2 1050624 2050047 999424 488M Linux filesystem
    /dev/sdb3 2050048 500117503 498067456 237.5G Linux filesystem
    Device Start End Sectors Size Type
    /dev/nvme1n1p1 2048 1050623 1048576 512M EFI System
    /dev/nvme1n1p2 1050624 2549759 1499136 732M Linux filesystem
    /dev/nvme1n1p3 2549760 1000214527 997664768 475.7G Linux filesystem
    ```

    ```
    mount /dev/sdb2 /boot
    mount /dev/sdb1 /boot/efi
    mount /dev/nvme1n1p2 /boot
    mount /dev/nvme1n1p1 /boot/efi
    ```

    ```
    grub-install /dev/sdb
    grub-install /dev/nvme1n1
    **OR** grub-update
    umount /boot/efi
  10. @samuelcolvin samuelcolvin created this gist May 14, 2017.
    58 changes: 58 additions & 0 deletions repair_boot.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    Guides:
    * https://stephentanner.com/restoring-grub-for-an-encrypted-lvm.html
    * https://askubuntu.com/questions/719409/how-to-reinstall-grub-from-a-liveusb-if-the-partition-is-encrypted-and-there-i
    * https://help.ubuntu.com/community/Grub2/Installing


    ```
    cryptsetup luksOpen /dev/sdb3 home_sdb3
    vgchange -ay
    lvscan
    mkdir /media/linux
    mount /dev/ubuntu-vg/root /media/linux/
    mount -o bind /proc /media/linux/proc
    mount -o bind /dev /media/linux/dev
    mount -o bind /sys /media/linux/sys
    chroot /media/linux /bin/bash
    ```

    ```
    > fdisk -l:
    Disk /dev/sdb: 238.5 GiB, 256060514304 bytes, 500118192 sectors
    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: ED00E611-2AA0-40CB-BA69-97B8FAD3303E
    Device Start End Sectors Size Type
    /dev/sdb1 2048 1050623 1048576 512M EFI System
    /dev/sdb2 1050624 2050047 999424 488M Linux filesystem
    /dev/sdb3 2050048 500117503 498067456 237.5G Linux filesystem
    ```

    ```
    mount /dev/sdb2 /boot
    mount /dev/sdb1 /boot/efi
    ```

    ```
    grub-install /dev/sdb
    **OR** grub-update
    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 home_sdb3
    ```