Method for recovering UEFI (Unified Extensible Firmware Interface) firmware boot exception
By introducing a boot exception recovery module in UEFI, detecting and recovering BootLoader boot exceptions, the problem of BootLoader boot exceptions under UEFI is solved, resulting in the operating system being unable to boot normally, and the effect of automatic recovery and normal boot is achieved.
Patent Information
- Application Number
- CN202311753986.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-19
- Publication Date
- 2025-06-20
AI Technical Summary
In the UEFI environment, when BootLoader boots abnormally, the existing technology is difficult to automatically detect and restore the boot partition, resulting in the operating system being unable to boot normally.
By adding a boot exception recovery module to UEFI, the BootLoader boot exception is detected using the watchdog status and startup status, the EFI boot partition recovery operation is performed, and the UEFI boot sequence is adjusted to ensure normal booting.
It realizes automatic recovery when BootLoader boot exceptions are not implemented in the UEFI environment, ensuring that the operating system can boot normally, the process is transparent to users, and avoids the risks of data loss and system corruption.
Smart Images

Figure CN120179437A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and particularly to a method for recovering from abnormal UEFI firmware boot. Background Art
[0002] UEFI (Unified Extensible Firmware Interface) is located between hardware and the operating system in the entire computer system. Its main functions are to implement hardware self-check and initialization, boot the installation of the operating system, and provide hardware information and hardware operation interfaces for the operating system. The UEFI boots the operating system through the boot loader BootLoader. Currently, Grub2 is widely used. BootLoader is a crucial software. However, due to some non-standard and incorrect operations by users, various abnormal situations are likely to occur in BootLoader. Some abnormalities may cause BootLoader to be unable to boot the operating system normally, resulting in abnormal operation. When encountering such a situation, one solution is to use a USB flash drive or optical drive to recreate a boot installation disk and enter the operating system in the installation disk to repair the boot partition. This recovery method requires users to have a certain technical foundation for the operating system. Otherwise, it is easy to cause data loss or system damage. Another solution is to directly reinstall the operating system. However, in actual work, such as for servers, reinstalling the system is unrealistic. Summary of the Invention
[0003] The present invention provides a method for recovering from abnormal UEFI firmware boot, so as to solve the technical problems of how to detect abnormal BootLoader boot under UEFI, how to implement boot partition recovery under UEFI, and how to modify the boot item under UEFI.
[0004] An embodiment of the present invention provides a method for recovering from abnormal UEFI firmware boot, including: the UEFI detects whether the boot loader BootLoader boots abnormally according to the watchdog state and the startup state; when the UEFI detects that the BootLoader boots abnormally, it performs an EFI (Extensible Firmware Interface) boot partition recovery operation and detects the result of the EFI boot partition recovery operation; if the UEFI detects that the result of the EFI boot partition recovery operation is partition recovery failure, it adjusts the UEFI boot order by polling all current boot items to ensure normal entry into the operating system next time.
[0005] Preferably, if the UEFI detects that the EFI boot partition recovery operation is successful, it further detects whether the BootLoader boots normally; when the UEFI further detects that the BootLoader boots normally, it turns off the watchdog and enters the operating system after the kernel boots successfully; when the UEFI further detects that the BootLoader boots abnormally, it sets the watchdog to an abnormal state after the watchdog times out and restarts to enter the UEFI.
[0006] Preferably, the UEFI adjusts the UEFI boot order by polling all current boot items, including: the UEFI polls all current boot items and obtains the device path of each boot item; the UEFI determines whether there is a BootLoader program in the boot device of each boot item according to the device path of each boot item, and adjusts the UEFI boot order according to the judgment result.
[0007] Preferably, adjusting the UEFI boot order according to the judgment result includes: if the judgment result is that there is a BootLoader program in the boot device of the boot item, the UEFI modifies the boot order BootOrder and sets the boot item of the BootLoader program as the first boot item; if the judgment result is that there is no BootLoader program in the boot device of the boot item, the UEFI sets the boot item of the Shell program as the first boot item or sets to directly enter the UEFI configuration interface at the next boot.
[0008] Preferably, the UEFI sets the boot item of the Shell program as the first boot item or sets to directly enter the UEFI configuration interface at the next boot, including: the UEFI further determines whether there is a Shell program in the boot device of the boot item; if it is determined that there is a Shell program in the boot device of the boot item, the UEFI sets the boot item of the Shell program as the first boot item; if it is determined that there is no Shell program in the boot device of the boot item, the UEFI sets to directly enter the UEFI configuration interface at the next boot.
[0009] Preferably, it further includes: creating a boot exception recovery module in the UEFI, and when the boot exception recovery module starts running, registering the callback function ReadyToBootCallBack of ReadyToBootEvent and
[0010] The callback function of the ExitBootServiceEvent, ExitBootServiceCallBack; after the UEFI enumerates the boot items in the BDS stage and triggers the ReadyToBootEvent, and after executing the callback function of the ReadyToBootEvent, ReadyToBootCallBack, start the watchdog, set the watchdog timeout action to restart, and register the watchdog timeout handling function to record the abnormal state to the non-volatile storage area; the ReadyToBootCallBack function determines whether the UEFI is starting for the first time and implements the backup of the EFI boot partition according to the judgment result.
[0011] Preferably, the callback function of the ReadyToBootEvent, ReadyToBootCallBack, implements the backup of the EFI boot partition according to the judgment result, including: when the judgment result is the first start, the callback function of the ReadyToBootEvent, ReadyToBootCallBack, obtains the starting logical block address LBA number and the ending LBA number of the EFI boot partition by parsing the logical sectors of the globally unique identifier partition table GPT, and according to the starting LBA number and the ending LBA number, backs up the EFI boot partition to the backup partition pre-created in the operating system; when the judgment result is not the first start, the callback function of the ReadyToBootEvent, ReadyToBootCallBack, reads the boot sector and the information sector of the boot partition, and when it is determined that the boot sector and the information sector of the boot partition are updated and the BootLoader was correctly booted last time, then re-back up the EFI boot partition to the backup partition pre-created in the operating system.
[0012] Preferably, it further includes: saving the backup recovery program UefiLoaderBackAndRecovery in the memory of the UEFI and further detecting whether the BootLoader is normal; when the UEFI detects that the BootLoader is normal, execute the EFI partition backup by executing the backup recovery program UefiLoaderBackAndRecovery–b command.
[0013] Preferably, it further includes: when the UEFI detects an abnormal BootLoader boot, it performs an EFI boot partition recovery operation by executing the backup recovery program UefiLoaderBackAndRecovery-r command, and detects the result of the EFI boot partition recovery operation; if the UEFI detects that the result of the EFI boot partition recovery operation is successful partition recovery, it exits the backup recovery program UefiLoaderBackAndRecovery-r command and continues to boot the operating system.
[0014] Preferably, it further includes: if the UEFI detects that the result of the EFI boot partition recovery operation is failed partition recovery, it adjusts the UEFI boot order by polling other UEFI boot items to ensure normal entry into the operating system next time.
[0015] The beneficial effect of the present invention is that by adding a boot exception recovery module in the UEFI, when the BootLoader has an exception, it can automatically recover the boot partition under the UEFI to ensure normal booting of the operating system, and this process is completely "invisible" to the user; when the boot kernel fails, it automatically polls other UEFI boot items, modifies the boot order, and prompts the user with an error message. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is a flowchart of a method for recovering UEFI firmware boot exception provided by the present invention;
[0017] Figure 2 is a specific flowchart of a method for recovering UEFI firmware boot exception provided by the present invention;
[0018] Figure 3 is a schematic diagram of a system for recovering UEFI firmware boot exception provided by the present invention;
[0019] Figure 4 is another specific flowchart of a method for recovering UEFI firmware boot exception provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0020] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. In the subsequent descriptions, suffixes such as "module", "component" or "unit" used to represent elements are only for the convenience of describing the present invention and have no specific meaning per se. Therefore, "module", "component" or "unit" can be used interchangeably.
[0021] Embodiment 1
[0022] Figure 1It is a flowchart of a method for recovering from UEFI firmware boot anomalies provided by the present invention. As Figure 1 shown, it includes:
[0023] Step S101: The UEFI detects whether the BootLoader is abnormally booted according to the watchdog status and the startup status;
[0024] Step S102: When the UEFI detects that the BootLoader is abnormally booted, it performs an EFI boot partition recovery operation and detects the result of the EFI boot partition recovery operation;
[0025] Step S103: If the UEFI detects that the result of the EFI boot partition recovery operation is a partition recovery failure, it adjusts the UEFI boot order by polling all current startup items to ensure normal entry into the operating system next time; wherein, the UEFI refers to the Unified Extensible Firmware Interface; and the EFI refers to the Extensible Firmware Interface.
[0026] The present invention also includes: If the UEFI detects that the result of the EFI boot partition recovery operation is a successful partition recovery, it further detects whether the BootLoader is normally booted; when the UEFI further detects that the BootLoader is normally booted, it turns off the watchdog and enters the operating system after successful kernel boot; when the UEFI further detects that the BootLoader is abnormally booted, it sets the watchdog to an abnormal state after the watchdog times out and restarts to enter the UEFI.
[0027] Further, the UEFI adjusts the UEFI boot order by polling all current startup items, including: The UEFI polls all current startup items and obtains the device path of each startup item; the UEFI determines whether there is a BootLoader program in the startup device of each startup item according to the device path of each startup item, and adjusts the UEFI boot order according to the judgment result.
[0028] Specifically, the UEFI adjusts the UEFI boot order according to the judgment result, including: If the judgment result is that there is a BootLoader program in the startup device of the startup item, the UEFI modifies the boot order BootOrder and sets the startup item of the BootLoader program as the first startup item; if the judgment result is that there is no BootLoader program in the startup device of the startup item, the UEFI sets the startup item of the Shell program as the first startup item or sets to directly enter the UEFI configuration interface for the next startup.
[0029] Among them, the UEFI setting the startup item of the Shell program as the first startup item or setting to directly enter the UEFI configuration interface for the next startup includes: the UEFI further determines whether there is a Shell program in the startup device of the startup item; if it is determined that there is a Shell program in the startup device of the startup item, the UEFI sets the startup item of the Shell program as the first startup item; if it is determined that there is no Shell program in the startup device of the startup item, the UEFI sets to directly enter the UEFI configuration interface for the next startup.
[0030] The present invention further includes: creating a boot exception recovery module in the UEFI, and when the boot exception recovery module starts to run, registering a callback function ReadyToBootCallBack of ReadyToBootEvent and
[0031] a callback function ExitBootServiceCallBack of ExitBootServiceEvent; after the UEFI enumerates startup items in the BDS stage, it triggers the ReadyToBootEvent, and after executing the callback function ReadyToBootCallBack of the ReadyToBootEvent, it enables the watchdog, sets the watchdog timeout action as reboot, and registers the watchdog timeout handling function as recording the abnormal state to the non-volatile storage area; the ReadyToBootCallBack function determines whether the UEFI is starting for the first time, and implements the backup of the EFI boot partition according to the judgment result.
[0032] Further, the callback function ReadyToBootCallBack of the ReadyToBootEvent implementing the backup of the EFI boot partition according to the judgment result includes: when the judgment result is the first startup, the callback function ReadyToBootCallBack of the ReadyToBootEvent obtains the starting logical block address LBA number and the ending LBA number of the EFI boot partition by parsing the logical sectors of the globally unique identifier partition table GPT, and backs up the EFI boot partition to a backup partition pre-created in the operating system according to the starting LBA number and the ending LBA number; when the judgment result is not the first startup, the callback function ReadyToBootCallBack of the ReadyToBootEvent reads the startup sector and the information sector of the boot partition, and when it is determined that the startup sector and the information sector of the boot partition are updated and the BootLoader was correctly booted last time, then re-backup the EFI boot partition to a backup partition pre-created in the operating system.
[0033] The present invention further includes: saving a backup recovery program UefiLoaderBackAndRecovery in the memory of UEFI, and further detecting whether the BootLoader is normal; when UEFI detects that the BootLoader is normal, performing EFI partition backup by executing the backup recovery program UefiLoaderBackAndRecovery -b command; when UEFI detects that the BootLoader boot is abnormal, performing EFI boot partition recovery operation by executing the backup recovery program UefiLoaderBackAndRecovery -r command, and detecting the result of the EFI boot partition recovery operation; if UEFI detects that the result of the EFI boot partition recovery operation is successful partition recovery, exiting the backup recovery program UefiLoaderBackAndRecovery -r command and continuing to boot the operating system; and if UEFI detects that the result of the EFI boot partition recovery operation is failed partition recovery, adjusting the UEFI boot order by polling other UEFI boot items to ensure normal entry into the operating system next time.
[0034] By adding a boot exception recovery module in UEFI, when the BootLoader has an exception, the boot partition can be automatically recovered in the boot exception recovery module of UEFI to ensure normal booting of the operating system, and this process is completely "invisible" to the user; when the boot kernel fails, other UEFI boot items are automatically polled, the boot order is modified, and an error message is prompted to the user.
[0035] Embodiment 2
[0036] The present invention provides a method for recovering UEFI firmware boot exception, including:
[0037] Step 21: Create a backup partition BackEFI under the operating system OS;
[0038] Step 22: Enable the watchdog in UEFI, set the watchdog timeout action to restart, and record the exception status in CMOS (Configuration Memory Operating System) or other non-volatile storage areas in the watchdog timeout handler;
[0039] Step 23: Add a DXE Driver in UEFI to implement boot exception recovery, and the module name is UefiLoaderBackAndRecovery;
[0040] Step 24: If it is determined to be the first boot, implement the backup of the EFI boot partition;
[0041] Step 25: Obtain the starting and ending LBA numbers of the EFI boot partition by parsing the logical sectors from LBA2 to LBA33 of the GPT partition entry; among them, the LBA number can identify the storage space of the boot partition on the disk.
[0042] Step 26: Implement the backup of the EFI boot partition to the backup partition BackEfI through the BlockRead and BlockWrite functions;
[0043] Step 27: Determine that it is not the first startup;
[0044] Step 28: The EFI boot partition is of the FAT32 type;
[0045] Step 29: Read the boot sector DBR (Dos Boot Record, partition boot sector) and the FSInfo (file system information sector) in the FAT32 partition;
[0046] Step 210: Determine whether the DBR and FSInfo of the boot partition have been updated;
[0047] Step 211: If there is an update and the BootLoader was successfully booted last time, re-backup the EFI boot partition to the backup partition / BackEfI;
[0048] Step 212: The DXE Driver monitors whether there is a boot anomaly through the watchdog status and the startup status;
[0049] The watchdog status is stored in the CMOS or non-volatile area and can be obtained by reading the CMOS or NV; the startup status exists in the variable area and can be obtained by using the GetVariable method.
[0050] Step 213: Restore the EFI boot partition from the backup partition after detecting an anomaly;
[0051] Step 214: The restoration fails or a boot anomaly is detected again after the restoration;
[0052] Step 215: Poll all the current boot options BootOptions;
[0053] Step 216: Obtain the device path DevicePath of each boot option;
[0054] Step 217: Determine the device type of the boot option according to the DevicePath;
[0055] Step 218: If the boot device is an HDD (Hard Disk Drive, mechanical hard disk), NVMe (NVM Express, Non-Volatile Memory Host Controller Interface), RAID (Redundant Arrays of Independent Disks), or a cloud disk, check whether there is a BootLoader program in the device. If there is, modify the BootOrder and set this boot item as the first boot item;
[0056] Step 219: If there is no valid boot item, set the Shell as the first boot item;
[0057] Step 220: If there is no Shell, set to directly enter the UEFI configuration interface at the next boot.
[0058] The present invention integrates a DXE Driver in the UEFI firmware to solve the problem of being unable to boot the operating system when the boot partition is damaged or corrupted. The present invention enables, in scenarios related to abnormal booting of the operating system, no longer being restricted to reinstalling the operating system or repairing the boot area by making a boot disk, which not only facilitates users but also avoids problems such as data loss and service interruption caused by improper operations during reinstalling the system or restoring by making an installation disk.
[0059] Embodiment 3
[0060] As Figure 2 shown, this embodiment provides a recovery solution for UEFI firmware boot anomalies, including the following steps:
[0061] Step 31: Create a backup partition BackEFI under the OS;
[0062] Step 32: Add a DXE Driver in the UEFI to implement boot anomaly recovery, with the module name UefiLoaderBackAndRecovery;
[0063] Step 33: The UefiLoaderBackAndRecovery module runs and registers two Event events respectively, the callback function ReadyToBootCallBack of the ReadyToBootEvent and the callback function ExitBootServiceCallBack of the ExitBootServiceEvent;
[0064] Step 34: Runs in the BDS (Boot Dev Select, Boot Device Selection) stage. After the boot item enumeration is completed, the ReadyToBootCallBack event is triggered;
[0065] Step 35: The ReadyToBootCallBack() function is executed to enable the watchdog, set the watchdog timeout action to restart, and record the abnormal status in the CMOS or other non-volatile storage areas in the watchdog timeout handling function; determine whether it is the first startup. If it is the first time, back up the boot partition; if it is not the first time, determine whether the boot partition has been updated and the BootLoader was correctly booted last time (BootKernelStatus = 1), and then back up the boot partition.
[0066] Step 36: If the watchdog status WatchDogTimeoutStatus = 1 and the startup status BootLoaderStatus = 1, it indicates an abnormality during the boot process, and the EFI partition is restored; otherwise, the partition restoration is not performed.
[0067] If WatchDogTimeoutStatus = 1 and BootLoaderStatus = 0, it indicates that the program is abnormal but not the BootLoader; if WatchDogTimeoutStatus = 0 and BootLoaderStatus = 1, it indicates that the program is not abnormal.
[0068] Step 37: When the BootLoader is in a non-abnormal state or the partition recovery is successful, the BootLoader is executed, and the startup status BootLoaderStatus = 1 is set.
[0069] Step 38: The BootLoader is executed to parse the configuration file, load the initrd and kernel files, and trigger the ExitBootServiceCallBack event. The ExitBootServiceCallBack() function is executed to disable the watchdog and set the current status BootKernelStatus = 1.
[0070] Step 39: The BootLoader is executed successfully, the kernel is booted successfully, and the jump is made to the entry of the kernel to enter the operating system.
[0071] Step 310: If the BootLoader execution fails, the abnormal status WatchDogTimeoutStatus = 1 is set after the watchdog times out, and the system is restarted.
[0072] Step 311: When the BootLoader is in an abnormal state and the partition recovery fails, the boot items are automatically polled, the UEFI boot order is adjusted to ensure that the operating system or the UEFI configuration interface can be entered normally next time, and an error message is prompted.
[0073] This embodiment provides a recovery solution for UEFI firmware boot anomalies. By integrating a DXE Driver into the UEFI firmware, it solves the problem of being unable to boot the operating system when the boot partition is damaged or corrupted. This invention enables, in scenarios related to abnormal booting of the operating system, not being restricted to reinstalling the operating system or repairing the boot area by creating a bootable disk, which not only facilitates users but also avoids problems such as data loss and service interruption caused by improper operations during reinstalling the system or restoring with a boot disk.
[0074] Embodiment 4
[0075] Based on Embodiment 3, the present invention also discloses a system for recovering UEFI firmware boot anomalies, including a watchdog module, an anomaly detection module, an anomaly backup module, an anomaly recovery module, and a boot order modification module. As Figure 3 shown.
[0076] Among them, the watchdog module is used to set a watchdog, set the timeout period and timeout actions, and add an anomaly status record in the timeout processing function. The anomaly detection module is used to detect whether the BootLoader executes abnormally. If it is determined that BootLoaderStatus = 1 and WatchDogTimeoutStatus = 1, it indicates a boot anomaly. The anomaly backup module is used to implement the backup of the EFI boot partition. When it is determined that the module is executed for the first time, or the EFI boot partition has been updated and the BootLoader executed normally last time (BootKernelStatus = 1), the EFI boot partition backup is performed. The anomaly recovery module is used to, after the anomaly detection module detects a BootLoader boot anomaly, recover data from the BackEfI backup partition to the EFI partition. The boot order modification module is used to, after the anomaly recovery module fails to execute, automatically poll other UEFI boot items, modify the boot order, and prompt the user with an error message.
[0077] This embodiment provides a system for recovering UEFI firmware boot anomalies, including a watchdog module, an anomaly detection module, an anomaly backup module, an anomaly recovery module, and a boot order modification module, which solves the problem of being unable to boot the operating system when the boot partition is damaged or corrupted. This invention enables, in scenarios related to abnormal booting of the operating system, not being restricted to reinstalling the operating system or repairing the boot area by creating a bootable disk, which not only facilitates users but also avoids problems such as data loss and service interruption caused by improper operations during reinstalling the system or restoring with a boot disk.
[0078] Embodiment 5
[0079] This embodiment discloses a recovery device for UEFI firmware boot exception. Referring to Embodiment 3, the DXE Driver in Embodiment 3 is modified to the application UefiLoaderBackAndRecovery of UEFI APPLICATION, the watchdog and BootLoader exception detection are removed, and only EFI partition backup, EFI partition recovery and UEFI boot order modification are retained. As Figure 4 shown, the recovery device includes a memory, and what is saved in the memory is the UEFI SHELL and the application UefiLoaderBackAndRecovery for backup and recovery, and the following steps are implemented.
[0080] Step 41: Create a backup partition BackEFI under the OS;
[0081] Step 42: Modify the first boot item in UEFI to the above-mentioned memory, generally a USB flash drive or an optical drive;
[0082] Step 43: Execute the UefiLoaderBackAndRecovery–b command to perform EFI partition backup;
[0083] Step 44: Modify the first boot item in UEFI to the device where the operating system is located;
[0084] Step 45: If the boot of the operating system is abnormal, restart and enter UEFI;
[0085] Step 46: Modify the first boot item in UEFI to the above-mentioned memory, generally a USB flash drive or an optical drive;
[0086] Step 47: Execute the UefiLoaderBackAndRecovery–r command to perform EFI partition recovery;
[0087] Step 48: If the execution is successful, exit and continue to boot the operating system. If the execution fails, automatically poll other boot items in UEFI, modify the boot order, and prompt the user with an error message.
[0088] This embodiment provides a recovery device for UEFI firmware boot exception, including a memory, and what is saved in the memory is the UEFI SHELL and the application for backup and recovery, which solves the problem that the operating system cannot be booted when the boot partition is damaged or corrupted. The present invention enables, in relevant scenarios where the boot of the operating system is abnormal, not to be restricted to reinstalling the operating system or repairing the boot area by making a boot disk, which not only facilitates the user, but also avoids problems such as data loss and service interruption caused by improper operations during reinstalling the system or making an installation disk for recovery.
[0089] The preferred embodiments of the present invention have been described above with reference to the accompanying drawings. The scope of the present invention is not limited thereby. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention shall fall within the scope of the present invention.
Claims
1. A method for recovering from UEFI firmware boot anomalies, characterized in that, Including: The UEFI detects whether the BootLoader boots abnormally according to the watchdog status and the startup status; When the UEFI detects that the BootLoader boots abnormally, it performs an EFI boot partition recovery operation and detects the result of the EFI boot partition recovery operation; If the UEFI detects that the result of the EFI boot partition recovery operation is partition recovery failure, it adjusts the UEFI startup order by polling all current startup items to ensure normal entry into the operating system next time; Wherein, the UEFI refers to the Unified Extensible Firmware Interface; the EFI refers to the Extensible Firmware Interface.
2. The method according to claim 1, characterized in that, Also including: If the UEFI detects that the result of the EFI boot partition recovery operation is partition recovery success, it further detects whether the BootLoader boots normally; When the UEFI further detects that the BootLoader boots normally, it turns off the watchdog and enters the operating system after the kernel boots successfully; When the UEFI further detects that the BootLoader boots abnormally, it sets the watchdog to an abnormal state after the watchdog times out and restarts to enter the UEFI.
3. The method according to claim 1, characterized in that, The UEFI adjusts the UEFI startup order by polling all current startup items, including: The UEFI polls all current startup items and obtains the device path of each startup item; The UEFI determines whether there is a BootLoader program in the startup device of each startup item according to the device path of each startup item, and adjusts the UEFI startup order according to the judgment result.
4. The method according to claim 3, characterized in that, The UEFI adjusts the UEFI startup order according to the judgment result, including: If the judgment result is that there is a BootLoader program in the startup device of the startup item, the UEFI modifies the boot order BootOrder and sets the startup item of the BootLoader program as the first startup item; If the judgment result is that there is no BootLoader program in the startup device of the startup item, the UEFI sets the startup item of the Shell program as the first startup item or sets to directly enter the UEFI configuration interface at the next startup.
5. The method according to claim 4, characterized in that, The UEFI sets the startup item of the Shell program as the first startup item or sets to directly enter the UEFI configuration interface at the next startup, including: The UEFI further determines whether there is a Shell program in the startup device of the startup item; If it is judged that there is a Shell program in the startup device of the startup item, the UEFI sets the startup item of the Shell program as the first startup item; If it is judged that there is no Shell program in the startup device of the startup item, the UEFI sets to directly enter the UEFI configuration interface at the next startup.
6. The method according to claim 1, characterized in that, Also including: Create a boot exception recovery module in the UEFI, and when the boot exception recovery module starts running, register the callback function ReadyToBootCallBack of the ReadyToBootEvent and the callback function ExitBootServiceCallBack of the ExitBootServiceEvent respectively; After the UEFI enumerates the boot items in the BDS stage and completes, it triggers the ReadyToBootEvent. After executing the callback function ReadyToBootCallBack of the ReadyToBootEvent, it enables the watchdog, sets the watchdog timeout action to reboot, and registers the watchdog timeout handling function to record the abnormal state to the non-volatile storage area; The ReadyToBootCallBack function determines whether the UEFI is booting for the first time and implements the backup of the EFI boot partition according to the determination result.
7. The method according to claim 6, characterized in that, The callback function ReadyToBootCallBack of the ReadyToBootEvent implements the backup of the EFI boot partition according to the determination result, including: When the determination result is the first boot, the callback function ReadyToBootCallBack of the ReadyToBootEvent obtains the starting logical block address LBA number and the ending LBA number of the EFI boot partition by parsing the logical sectors of the globally unique identifier partition table GPT, and backs up the EFI boot partition to the backup partition pre-created in the operating system according to the starting LBA number and the ending LBA number; When the determination result is not the first boot, the callback function ReadyToBootCallBack of the ReadyToBootEvent reads the boot sector and the information sector of the boot partition, and when it determines that the boot sector and the information sector of the boot partition are updated and the BootLoader was correctly booted last time, it re-backups the EFI boot partition to the backup partition pre-created in the operating system.
8. The method according to claim 1, characterized in that, It also includes: Save the backup and recovery program UefiLoaderBackAndRecovery in the memory of the UEFI, and further detect whether the BootLoader is normal; When the UEFI detects that the BootLoader is normal, it executes the EFI partition backup by executing the backup and recovery program UefiLoaderBackAndRecovery–b command.
9. The method according to claim 8, characterized in that, It also includes: When the UEFI detects that the BootLoader boot is abnormal, it executes the EFI boot partition recovery operation by executing the backup and recovery program UefiLoaderBackAndRecovery-r command and detects the result of the EFI boot partition recovery operation; If the UEFI detects that the result of the EFI boot partition recovery operation is successful partition recovery, it exits the backup and recovery program UefiLoaderBackAndRecovery-r command and continues to boot the operating system.
10. The method according to claim 9, characterized in that, It also includes: If the UEFI detects that the result of the EFI boot partition recovery operation is failed partition recovery, it adjusts the UEFI boot order by polling other UEFI boot items to ensure normal entry into the operating system next time.