Last active
March 15, 2024 01:50
-
-
Save rasa/621c52b1bb7eb338520d51122003337b to your computer and use it in GitHub Desktop.
Reinstall grub menu with UEFI, lvm, and separate boot partition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
set -e | |
apt update | |
apt install lvm2 # this is already installed in Ubuntu 23.10 Live CD | |
fdisk -l | |
lvscan | |
mount /dev/vg0/lv-0 /mnt | |
cd /mnt | |
mount /dev/nvme0n1p5 boot # or nvme2n1p5 if using dock | |
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 | |
# 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 | |
# 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 | |
# echo GRUB_DISABLE_OS_PROBER=false >> /etc/default/grub | |
# apt install os-prober | |
# os-prober | |
# grub-install # needed? | |
# update-grub | |
# reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://wiki.debian.org/GrubEFIReinstall may have the answers