Skip to content

Instantly share code, notes, and snippets.

@arvati
Last active April 2, 2023 23:26
Show Gist options
  • Save arvati/4083ea881984a85d8a05e978b941985c to your computer and use it in GitHub Desktop.
Save arvati/4083ea881984a85d8a05e978b941985c to your computer and use it in GitHub Desktop.
Reinstall Grub2
if [ "${grub_platform}" == "efi" ]; then
menuentry "Google" {
insmod part_gpt
insmod fat
insmod chain
set root='(hd0,gpt12)'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt12 --hint-efi=hd0,gpt12 --hint-baremetal=ahci0,gpt12 7602-3D50
else
search --no-floppy --fs-uuid --set=root 7602-3D50
fi
chainloader /EFI/Boot/bootx64.efi
}
fi
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
GRUB_DISABLE_OS_PROBER="true"
sudo mount -t btrfs /dev/sdb /mnt/disk
cd /mnt/disk
sudo mount --bind /dev dev
sudo mount -t proc proc proc
sudo mount -t sysfs sysfs sys
sudo chroot ./
ls /dev/disk/by-uuid -alh
nano /etc/grub.d/40_custom
nano /etc/fstab
update-initramfs -u
update-grub
grub-install --force /dev/sdb
exit
sudo umount dev
sudo umount proc
sudo umount sys
cd ..
sudo umount /mnt/disk
sudo apt update
sudo apt install efibootmgr -y
efibootmgr -v
sudo mkdir /mnt/disk
sudo blkid
sudo blkid
sudo mount -t ext4 /dev/nvme0n1p6 /mnt/disk
sudo mount -t vfat /dev/nvme0n1p1 /mnt/disk/boot/efi
cd /mnt/disk
sudo mount --bind /dev dev
sudo mount --bind /dev/pts dev/pts
sudo mount -t proc proc proc
sudo mount -t sysfs sysfs sys
sudo mount --bind /sys/firmware/efi/efivars sys/firmware/efi/efivars
sudo chroot ./
ls /dev/disk/by-uuid -alh
nano /etc/grub.d/40_custom
nano /etc/fstab
update-initramfs -u
#grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=debian
grub-install --target=x86_64-efi /dev/nvme0n1
grub-install --recheck /dev/nvme0n1
update-grub2
exit
sudo umount dev/pts
sudo umount dev
sudo umount proc
sudo umount sys/firmware/efi/efivars
sudo umount sys
cd ..
sudo umount /mnt/disk/boot/efi
sudo umount /mnt/disk
efibootmgr -v
@arvati
Copy link
Author

arvati commented Feb 10, 2022

  1. Boot into Windows 10.
  2. Press the Windows + R keys to open the Run utility.
  3. Type cmd and press Ctrl + Shift + Enter to open an elevated Command Prompt.
  4. Now, type the following command and press Enter:
    bcdedit /set {bootmgr} path \EFI\debian\shimx64.efi
  5. After you run the above command, it will change the bootloader back to Grub.
  6. Restart your PC and you should be greeted with the Grub Menu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment