PDA

View Full Version : How to reinstall Grub EFI in Fedora with Fedora-Workstation-Live media



jonathonp
16th March 2017, 03:13 PM
How to reinstall Grub EFI in Fedora with Fedora-Workstation-Live media & also remove EFI boot entries


1. Boot Fedora Workstation live media

2. Open gnome terminal and locate the Fedora partitions:

lsblk -f

You could also use fdisk

su

fdisk -l

3. Mount the Fedora installation partitions:
[liveuser@localhost-live ~]$
su
[root@localhost-live liveuser]#
mount /dev/sda5 /mnt
[root@localhost-live liveuser]#
mount /dev/sda4 /mnt/boot
[root@localhost-live liveuser]#
mount /dev/sda1 /mnt/efi


4. Bind the required parts of the file system:
[root@localhost-live liveuser]#
mount --bind /dev /mnt/dev
[root@localhost-live liveuser]#
mount --bind /proc /mnt/proc
[root@localhost-live liveuser]#
mount --bind /sys /mnt/sys

Enable network access in chroot:
[root@localhost-live liveuser]#
mount -o bind /run /mnt/run

NOTE: "mount -o bind /etc/resolv.conf /mnt/etc/resolv.conf" has been deprecated from what i understand.

5. Change root
[root@localhost-live liveuser]#
chroot /mnt


6. Reinstall grub efi:
[root@localhost-live /]#
dnf reinstall grub2-efi grub2-efi-modules shim
Last metadata expiration check: 3:55:40 ago on Thu Mar 16 20:21:06 2017.
No match for argument: grub2-efi-modules
Dependencies resolved.
================================================== ==============================
Package Arch Version Repository Size
================================================== ==============================
Reinstalling:
grub2-efi x86_64 1:2.02-0.38.fc25 updates 1.1 M
shim x86_64 0.8-10 fedora 634 k

Transaction Summary
================================================== ==============================

Total download size: 1.7 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): shim-0.8-10.x86_64.rpm 341 kB/s | 634 kB 00:01
(2/2): grub2-efi-2.02-0.38.fc25.x86_64.rpm 473 kB/s | 1.1 MB 00:02
--------------------------------------------------------------------------------
Total 183 kB/s | 1.7 MB 00:09
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Reinstalling: shim-0.8-10.x86_64 1/4
Reinstalling: grub2-efi-1:2.02-0.38.fc25.x86_64 2/4
Erasing : shim-0.8-10.x86_64 3/4
Erasing : grub2-efi-1:2.02-0.38.fc25.x86_64 4/4
Verifying : grub2-efi-1:2.02-0.38.fc25.x86_64 1/4
Verifying : shim-0.8-10.x86_64 2/4
Verifying : grub2-efi-1:2.02-0.38.fc25.x86_64 3/4
Verifying : shim-0.8-10.x86_64 4/4

Reinstalled:
grub2-efi.x86_64 1:2.02-0.38.fc25 shim.x86_64 0.8-10

Complete!

7. Update grub efi:
[root@localhost-live /]#
grub2-mkconfig -o /efi/EFI/fedora/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.9.13-201.fc25.x86_64
Found initrd image: /boot/initramfs-4.9.13-201.fc25.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-374c398df90b4840ba6534b92ae530ed
Found initrd image: /boot/initramfs-0-rescue-374c398df90b4840ba6534b92ae530ed.img
Found Windows Boot Manager on /dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi
Found Arch on /dev/sda8
Found Ubuntu 16.10 (16.10) on /dev/sdb1
Found CentOS Linux release 7.3.1611 (Core) on /dev/sdb13
Found unknown Linux distribution on /dev/sdb3
Found Solus (2017.01.01.0) on /dev/sdb5
done
[root@localhost-live /]#
exit
[root@localhost-live /]#
reboot

_______________________________
EFI Boot Manager example (used this on my laptop)

1. To read man pages:

man efibootmgr

[jonathon@localhost ~]$ su
Password:

2. Use the following command to view boot entries.

[root@localhost jonathon]#
efibootmgr -v
BootCurrent: 0002
Timeout: 1 seconds
BootOrder: 0003,0002,0004,0001,0000
Boot0000* Windows Boot Manager HD(1,GPT,dc17ccb7-ce74-4f27-8e7d-902fc30ed04f,0x800,0xfa000)/File(\EFI\MICROSOFT\BOOT\BOOTMGFW.EFI)WINDOWS..... ....x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}....................
Boot0001* arch HD(1,GPT,dc17ccb7-ce74-4f27-8e7d-902fc30ed04f,0x800,0xfa000)/File(\EFI\ARCH\GRUBX64.EFI)
Boot0002* Fedora HD(1,GPT,dc17ccb7-ce74-4f27-8e7d-902fc30ed04f,0x800,0xfa000)/File(\EFI\FEDORA\SHIM.EFI)
Boot0003* ubuntu HD(1,GPT,dc17ccb7-ce74-4f27-8e7d-902fc30ed04f,0x800,0xfa000)/File(\EFI\UBUNTU\SHIMX64.EFI)
Boot0004* Linux Boot Manager HD(1,GPT,dc17ccb7-ce74-4f27-8e7d-902fc30ed04f,0x800,0xfa000)/File(\EFI\GOOFIBOOT\GOOFIBOOTX64.EFI)


3. Delete an entry:

[root@localhost jonathon]#
efibootmgr -b 0001 -B
BootCurrent: 0002
Timeout: 1 seconds
BootOrder: 0003,0002,0004,0000
Boot0000* Windows Boot Manager
Boot0002* Fedora
Boot0003* ubuntu
Boot0004* Linux Boot Manager

Delete an entry:
[root@localhost jonathon]#
efibootmgr -b 0004 -B
BootCurrent: 0002
Timeout: 1 seconds
BootOrder: 0003,0002,0000
Boot0000* Windows Boot Manager
Boot0002* Fedora
Boot0003* ubuntu
[root@localhost jonathon]#

As you can see the 2 entries Boot0001* arch and Boot0004* Linux Boot Manager have been removed.


Recently i decided to change from Legacy mode to UEFI mode and see if there is any benefit in doing things this way when running multiple Linux installations. I'm sticking with efi mode Jonathon :cool: