Efi Grub reinstallation

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Post Reply
User avatar
kukamuumuka
Level 15
Level 15
Posts: 5973
Joined: Tue Sep 03, 2013 4:51 am
Location: Finland
Contact:

Efi Grub reinstallation

Post by kukamuumuka » Fri Sep 23, 2016 2:25 pm

f you have some problematic computer like HP Pavilion 17, Windows or windows-based malwares can destroy boot. If so, you need to install and configure via liveUSB, because boot-repair, etc. may not work with HP.

The process:
1. Boot using liveUSB, open Terminal and mount efi-partition under/mnt and open /mntas an administrator and copy /mnt/EFI/Microsoft/Bootto /mnt/EFI/Microsoft/Boot2 and rename/mnt/EFI/Microsoft/Boot/bootmgfw.efiand/mnt/EFI/Microsoft/Boot/bootmgr.efi files.

2. Copy/mnt/EFI/ubuntu/grubx64.efi (copy twice) and /mnt/EFI/ubuntu/grub.cfg files to the/mnt/EFI/Microsoft/Boot folder and rename grubx64.efi as bootmgr.efi and bootmgfw.efi.

3. Umount /mnt

4. Chroot to your linux-system (eg. /dev/sda7)

Code: Select all

sudo mount /dev/sda7 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /sys /mnt/sys
sudo mount --bind /proc /mnt/proc
sudo chroot /mnt
nano /etc/resolv.conf
... the contents
nameserver 8.8.8.8
.... save and quit
Ctrl o
Ctrl x

Code: Select all

apt-get update
apt-get install grub-efi-amd64
mount /dev/sda2 /boot/efi ### if the efi partition is /dev/sda2
apt-get install --reinstall grub-efi
update-grub
exit
sudo umount /mnt/dev
sudo umount /mnt/sys
sudo umount /mnt/proc
sudo umount /mnt
Now you should be able to boot into your linux-system.

For getting Windows to boot also, you need to make an /etc/grub.d/40_custom file, whose contents is

Code: Select all

#! /bin/sh
exec tail -n +3 $0

menuentry "Windows" {
    insmod part_gpt
    insmod chain
    set root='(hd0,gpt2)'
    chainloader /EFI/Microsoft/Boot2/bootmgfw.efi
} 
Notice that the path is /EFI/Microsoft/Boot2 !

After making run

Code: Select all

sudo update-grub
https://wiki.debian.org/GrubEFIReinstall

Post Reply

Return to “Tutorials”