UEFI management under linux

UEFI is used to replace the traditional BIOS boot operating system. It is also very important to learn to modify UEFI boot items. The full name of UEFI is: "Unified Extensible Firmware Interface" (Unified Extensible Firmware Interface). All newly purchased computers support UEFI firmware. , If you need to start the traditional MBR device, you need to open the CSM (Compatibility Support Module). Turning off CSM becomes a pure UEFI boot, and fully supports secure boot. Secure Boot (secure boot), secure boot is only applicable to operating systems that use UEFI to boot. If the computer wants to start a device that does not fully support UEFI, you must turn off Secure Boot and then turn on CSM. For Win7 system, CSM compatibility mode must be turned on. Windows 8 and above can support UEFI very well, and in order to set the system boot, you must manage UEFI startup items.

When the Linux system is directly installed on a domestic personal physical machine, a Windows system is generally installed to achieve dual systems, so that sometimes the system startup items are lost, mostly Linux systems

The solution is to use the efibootmgr command to add boot items, and the EasyUEFI software can be used under Windows.

1. If the system loses the Linux startup items, if it is a dual system, you can only enter Windows, but I don’t like to use EasyUEFI. At this time, you can choose a Linux liveCD system, such as Ubuntu, and
burn the Ubuntu liveCD into a U disk to start. The CD-ROM drive will start the system very slowly.

2. I use the efibootmgr command under Ubuntu (not liveCD), and the display is as follows:

pipci@ubuntu:~$ efibootmgr
BootCurrent: 0012
Timeout: 0 seconds
BootOrder: 0012,0010,0011,000F,000B,000A,0006,0007,0008,0009,000C,000D,000E
Boot0000 Setup
Boot0001 Boot Menu
Boot0002 Diagnostic Splash Screen
Boot0003 Lenovo Diagnostics
Boot0004 Rescue and Recovery
Boot0005 Startup Interrupt Menu
Boot0006* USB CD
Boot0007* USB FDD
Boot0008* ATAPI CD0
Boot0009* ATAPI CD1
Boot000A* ATA HDD0
Boot000B* ATA HDD1
Boot000C* ATA HDD2
Boot000D* USB HDD
Boot000E* PCI LAN
Boot000F* Windows Boot Manager
Boot0010* ubuntu
Boot0011* ubuntushim
Boot0012* opensuse-secureboot
pipci@ubuntu:~$

The list still shows the current boot item, boot timeout, and EFI boot sequence very intuitively. 0012 is the first boot item corresponding to the opensuse system, 0011 is the second boot item corresponding to the ubuntu system, this is manually added by me,
000F is four boot The corresponding Windows system of the item.

3. Find the system startup file, and each system will create its own startup file in the EFI partition.

pipci@ubuntu:~$ sudo fdisk -l #produce the partition where EFI is located

Sector Size type at the end of device Start
/dev/sdb1 2048 206847 204800 100M EFI System #The partition where EFI is located
/dev/sdb2 206848 468991 262144 128M Microsoft reserved
/dev/sdb3 468992 83888127 83419136 39.8G Microsoft basic data
/dev/sdb4 83888128 92276735 8388608 4G Microsoft basic data
/dev/sdb5 92276736 176168959 83892224 40G Microsoft basic data
/dev/sdb6 176168960 254294015 78125056 37.3G Linux filesystem
/dev/sdb7 254294016 262682623 8388608 4G Linux filesystem
/dev/sdb8 262682624 468860927 206178304 98.3G Microsoft basic data
pipci ubuntu:~$

4. Hang on the EFI partition

pipci@ubuntu:~$ sudo mount /dev/sdb1 /mnt/ #Mount the EFI partition to the /mnt directory

5. Enter the EFI partition
pipci@ubuntu:~$ cd /mnt/
bash: cd: /mnt/: insufficient permissions
pipci@ubuntu:~$ sudo -i #Run a login shell as root user
root@ubuntu:~# cd /mnt/

6. Produce EFI partition
root@ubuntu:/mnt# ls
EFI

7. Enter the EFI directory and view

root@ubuntu:/mnt# cd EFI/
root@ubuntu:/mnt/EFI# ls
Boot Microsoft opensuse ubuntu #You can see the installed system
root@ubuntu:/mnt/EFI#

8. Check the contents of each directory under EFI:
root@ubuntu:/mnt/EFI# ls Boot/
bootx64.efi
root@ubuntu:/mnt/EFI# ls Microsoft/
Boot
root@ubuntu:/mnt/EFI# ls opensuse/
boot .csv grub.cfg grub.efi grubx64.efi MokManager.efi shim.efi
root@ubuntu:/mnt/EFI# ls ubuntu/
fw fwupx64.efi grub.cfg grubx64.efi mmx64.efi shimx64.efi
root@ubuntu:/ mnt/EFI#

9. Add startup items

root@ubuntu:~# efibootmgr -c -w -L “BootOptionName” -d /dev/sda -p 1 -l \EFI\Boot\bootx64.efi

Replace BootOptionName with the name you set, -d is the hard disk where the boot partition is located (default is /dev/sda), -p is the location of the partition (default is 1), and -l is the path to start the efi file.
This adds the EFI boot item.
For example:
root@ubuntu:~# efibootmgr -c -w -L "BootOptionName" -d /dev/sdb -p 1 -l \EFI\Boot\bootx64.efi #The hard disk where my boot partition is located is /dev/sdb
BootCurrent: 0012
Timeout: 0 seconds
BootOrder: 0013,0012,0010,0011,000F,000B,000A,0006,0007,0008,0009,000C,000D,000E
Boot0000 Setup
Boot0001 Boot Menu
Boot0002 Diagnostic Splash Screen
Boot0003 Lenovo Diagnostics
Boot0004 Rescue and Recovery
Boot0005 Startup Interrupt Menu
Boot0006* USB CD
Boot0007* USB FDD
Boot0008* ATAPI CD0
Boot0009* ATAPI CD1
Boot000A* ATA HDD0
Boot000B* ATA HDD1
Boot000C* ATA HDD2
Boot000D* USB HDD
Boot000E* PCI LAN
Boot000F* Windows Boot Manager
Boot0010* ubuntu
Boot0011* ubuntushim
Boot0012* opensuse-secureboot
Boot0013* BootOptionName

Through the above operation, it can be seen that the startup item BootOptionName has been added, the number is 0013, and BootOrder: can be seen that it has become the first startup item.

If the boot item of the Linux system is missing, do not add the boot item /EFI/Boot/bootx64.efi, because this file may be replaced by the Windows system. After adding, it will directly enter the Windows system and
cannot enter the GRUB boot program. You can try to add /EFI/ Grubx64.efi, grub.efi, shim.efi, MokManager.efi and other files in the opensuse/ directory. The files in
the directory corresponding to each Linux distribution may be different. Add them according to the actual situation. My computer has 3 systems installed. Install The order is Windows Ubuntu openSUSE, so you need to add
the boot file corresponding to the last installed system, because the GRUB of the last installed system will add the previous system to it, and then you can manage multiple systems through one GRUB.

10. The command to delete the startup item is:

root@ubuntu:~# efibootmgr -b 0013 -B #Delete the BootOptionName startup item just added, the corresponding number is 0013
BootCurrent: 0012
Timeout: 0 seconds
BootOrder: 0012,0010,0011,000F,000B,000A,0006,0007 ,0008,0009,000C,000D,000E
Boot0000 Setup
Boot0001 Boot Menu
Boot0002 Diagnostic Splash Screen
Boot0003 Lenovo Diagnostics
Boot0004 Rescue and Recovery
Boot0005 Startup Interrupt Menu
Boot0006* USB CD
Boot0007* USB FDD
Boot0008* ATAPI CD0
Boot0009* ATAPI CD1
Boot000A* ATA HDD0
Boot000B* ATA HDD1
Boot000C* ATA HDD2
Boot000D* USB HDD
Boot000E* PCI LAN
Boot000F* Windows Boot Manager
Boot0010* ubuntu
Boot0011* ubuntushim
Boot0012* opensuse-secureboot

11. Delete redundant startup items and check the startup items again:
root@ubuntu:~# efibootmgr
BootCurrent: 0012
Timeout: 0 seconds
BootOrder: 0012,0010,0011,000F,000B,000C,000D
Boot0000 Setup
Boot0001 Boot Menu
Boot0002 Diagnostic Splash Screen
Boot0003 Lenovo Diagnostics
Boot0004 Rescue and Recovery
Boot0005 Startup Interrupt Menu
Boot000B* ATA HDD1
Boot000C* ATA HDD2
Boot000D* USB HDD
Boot000F* Windows Boot Manager
Boot0010* ubuntu
Boot0011* ubuntushim
Boot0012* opensuse-secureboot

12、修改boot 顺序
root@ubuntu:~# efibootmgr -o 0012,0010,0011,000F,000D,000C,000B
BootCurrent: 0012
Timeout: 0 seconds
BootOrder: 0012,0010,0011,000F,000D,000C,000B
Boot0000 Setup
Boot0001 Boot Menu
Boot0002 Diagnostic Splash Screen
Boot0003 Lenovo Diagnostics
Boot0004 Rescue and Recovery
Boot0005 Startup Interrupt Menu
Boot000B* ATA HDD1
Boot000C* ATA HDD2
Boot000D* USB HDD
Boot000F* Windows Boot Manager
Boot0010* ubuntu
Boot0011* ubuntushim
Boot0012* opensuse-secureboot
root@ubuntu:~#

Use the efibootmgr -o command to swap 000B and 000D. If you want to set the first boot, put the corresponding number at the top of the command, such as 0012 above

Guess you like

Origin blog.csdn.net/seaship/article/details/110671716