Skip to content

Instantly share code, notes, and snippets.

@rasa
Last active March 15, 2024 01:50

Revisions

  1. rasa revised this gist Mar 15, 2024. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,8 @@ lvscan
    mount /dev/vg0/lv-0 /mnt
    cd /mnt
    mount /dev/nvme0n1p5 boot # or nvme2n1p5 if using dock
    mount /dev/nvme0n1p1 boot/efi # or nvme2n1p7 if using dock
    for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
    mount /dev/nvme0n1p1 boot/efi # or nvme2n1p1 if using dock
    for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do mount -B $i /mnt$i; done
    cp /etc/resolv.conf etc
    chroot .
    # unneeded: apt update
  2. rasa revised this gist Mar 15, 2024. 1 changed file with 11 additions and 9 deletions.
    20 changes: 11 additions & 9 deletions reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    #!/use/bin/env bash
    # burn Ubuntu Live CD nearest to the installed system
    # undock, connect network cable, Live CD, and boot off it
    sudo -i
    # sudo -i
    set -e
    apt update
    apt install lvm2 # this is already installed in Ubuntu 23.10 Live CD
    fdisk -l
    @@ -20,12 +22,12 @@ grub-install /dev/nvme0n1 # or nvme2n1 if using dock
    # uneeded: grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy /dev/nvme0n1
    update-grub
    exit # chroot env
    reboot
    # reboot
    # after reboot:
    sudo -i
    echo GRUB_DISABLE_OS_PROBER=false >> /etc/default/grub
    apt install os-prober
    os-prober
    grub-install # needed?
    update-grub
    reboot
    # sudo -i
    # echo GRUB_DISABLE_OS_PROBER=false >> /etc/default/grub
    # apt install os-prober
    # os-prober
    # grub-install # needed?
    # update-grub
    # reboot
  3. rasa revised this gist Mar 10, 2024. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    # undock, connect network cable, and power on
    # burn Ubuntu Live CD nearest to the installed system
    # undock, connect network cable, Live CD, and boot off it
    sudo -i
    apt update
    apt install lvm2 # this is already installed in Ubuntu 23.10 Live CD
  4. rasa revised this gist Mar 10, 2024. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -22,8 +22,9 @@ exit # chroot env
    reboot
    # after reboot:
    sudo -i
    apt install os-prober
    echo GRUB_DISABLE_OS_PROBER=false >> /etc/default/grub
    apt install os-prober
    os-prober
    grub-install # needed?
    update-grub
    reboot
  5. rasa revised this gist Mar 10, 2024. 1 changed file with 12 additions and 6 deletions.
    18 changes: 12 additions & 6 deletions reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -11,13 +11,19 @@ mount /dev/nvme0n1p1 boot/efi # or nvme2n1p7 if using dock
    for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
    cp /etc/resolv.conf etc
    chroot .
    apt update # ?
    apt install linux-modules-6.5.0-9-generic linux-modules-extra-6.5.0-9-generic
    modprobe efivarsfs # always fails
    # unneeded: apt update
    # unneeded: apt install linux-modules-6.5.0-9-generic linux-modules-extra-6.5.0-9-generic
    # unneeded: modprobe efivarsfs # always fails
    apt install --reinstall grub-efi
    grub-install /dev/nvme0n1 # or nvme2n1 if using dock
    # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy /dev/nvme0n1
    # uneeded: grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy /dev/nvme0n1
    update-grub
    exit # chroot env
    reboot
    # after reboot:
    sudo -i
    apt install os-prober
    echo GRUB_DISABLE_OS_PROBER=false >> /etc/default/grub
    grub-install # needed?
    update-grub
    exit
    reboot

  6. rasa revised this gist Mar 10, 2024. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,9 @@ apt update # ?
    apt install linux-modules-6.5.0-9-generic linux-modules-extra-6.5.0-9-generic
    modprobe efivarsfs # always fails
    apt install --reinstall grub-efi
    # grub-install /dev/nvme0n1 # or nvme2n1 if using dock
    grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy /dev/nvme0n1
    grub-install /dev/nvme0n1 # or nvme2n1 if using dock
    # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy /dev/nvme0n1
    update-grub
    # reboot
    exit
    reboot

  7. rasa revised this gist Mar 10, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ mount /dev/vg0/lv-0 /mnt
    cd /mnt
    mount /dev/nvme0n1p5 boot # or nvme2n1p5 if using dock
    mount /dev/nvme0n1p1 boot/efi # or nvme2n1p7 if using dock
    for i in dev dev/pts proc sys; do mount --bind /$i $i; done
    for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done
    cp /etc/resolv.conf etc
    chroot .
    apt update # ?
  8. rasa revised this gist Mar 10, 2024. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # undock, and power on
    # undock, connect network cable, and power on
    sudo -i
    apt update
    apt install lvm2 # this is already installed in Ubuntu 23.10 Live CD
  9. rasa revised this gist Mar 10, 2024. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    # undock, and power on
    sudo -i
    apt update
    apt install lvm2 # this is already installed in Ubuntu 23.10 Live CD
  10. rasa revised this gist Mar 10, 2024. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -17,5 +17,4 @@ apt install --reinstall grub-efi
    # grub-install /dev/nvme0n1 # or nvme2n1 if using dock
    grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy /dev/nvme0n1
    update-grub
    umount .
    reboot
    # reboot
  11. rasa revised this gist Mar 10, 2024. 1 changed file with 9 additions and 6 deletions.
    15 changes: 9 additions & 6 deletions reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -5,14 +5,17 @@ fdisk -l
    lvscan
    mount /dev/vg0/lv-0 /mnt
    cd /mnt
    mount /dev/nvme2n1p5 boot
    mount /dev/nvme2n1p1 boot/efi
    mount /dev/nvme0n1p5 boot # or nvme2n1p5 if using dock
    mount /dev/nvme0n1p1 boot/efi # or nvme2n1p7 if using dock
    for i in dev dev/pts proc sys; do mount --bind /$i $i; done
    cp /etc/resolv.conf etc
    chroot /mnt
    modprobe efivarsfs
    chroot .
    apt update # ?
    apt install linux-modules-6.5.0-9-generic linux-modules-extra-6.5.0-9-generic
    modprobe efivarsfs # always fails
    apt install --reinstall grub-efi
    grub-install /dev/nvme2n1
    # grub-install /dev/nvme0n1 # or nvme2n1 if using dock
    grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ubuntu --recheck --no-floppy /dev/nvme0n1
    update-grub
    umount /mnt
    umount .
    reboot
  12. rasa revised this gist Mar 10, 2024. 1 changed file with 9 additions and 10 deletions.
    19 changes: 9 additions & 10 deletions reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,18 @@
    sudo -i
    apt update
    apt install lvm2
    apt install lvm2 # this is already installed in Ubuntu 23.10 Live CD
    fdisk -l
    lvscan
    mount /dev/vg0/dm-0 /mnt
    modprobe efivars
    mount /dev/nvme2n1p5 /mnt/boot
    mount /dev/nvme2n1p1 /mnt/boot/efi
    mount --bind /dev /mnt/dev
    mount --bind /dev/pts /mnt/dev/pts
    mount --bind /proc /mnt/proc
    mount --bind /sys /mnt/sys
    cp /etc/resolv.conf /mnt/etc/
    mount /dev/vg0/lv-0 /mnt
    cd /mnt
    mount /dev/nvme2n1p5 boot
    mount /dev/nvme2n1p1 boot/efi
    for i in dev dev/pts proc sys; do mount --bind /$i $i; done
    cp /etc/resolv.conf etc
    chroot /mnt
    modprobe efivarsfs
    apt install --reinstall grub-efi
    grub-install /dev/nvme2n1
    update-grub
    umount /mnt
    reboot
  13. rasa revised this gist Mar 10, 2024. No changes.
  14. rasa created this gist Mar 10, 2024.
    19 changes: 19 additions & 0 deletions reinstall-grub.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    sudo -i
    apt update
    apt install lvm2
    fdisk -l
    lvscan
    mount /dev/vg0/dm-0 /mnt
    modprobe efivars
    mount /dev/nvme2n1p5 /mnt/boot
    mount /dev/nvme2n1p1 /mnt/boot/efi
    mount --bind /dev /mnt/dev
    mount --bind /dev/pts /mnt/dev/pts
    mount --bind /proc /mnt/proc
    mount --bind /sys /mnt/sys
    cp /etc/resolv.conf /mnt/etc/
    chroot /mnt
    apt install --reinstall grub-efi
    update-grub
    umount /mnt
    reboot