Method, system, terminal and storage medium for setting GRUB boot sequence
By enumerating PCI devices and installing BLOCK IO protocol handles during the BIOS startup phase, the GRUB kernel boot disk sequence can be adjusted, solving the problem of not being able to modify the GRUB boot disk sequence, realizing the loading of kernel programs for different storage device systems, reducing user costs and improving user experience.
Patent Information
- Application Number
- CN202411858948.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-04-08
AI Technical Summary
In some customer environments, hard restrictions prohibit any modifications to the operating system, resulting in the inability to modify the GRUB boot disk order, increasing user costs or reducing user experience.
Enumerate PCI devices through the BIOS startup phase, create storage device paths, and install BLOCK IO protocol handles. GRUB kernel boots disk order to obtain these handles, classify storage devices, arrange them in ascending order of device paths, and boots the kernel program according to configuration files and device order.
Users can adjust the order of the boot disk of the GRUB kernel in the BIOS stage without modifying the GRUB configuration files or programs, adapt to various storage device system needs, successfully loading the kernel program, reducing user costs and improving user experience.
Smart Images

Figure CN119781842A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Linux system setting, and more specifically to a method, system, terminal and storage medium for setting a GRUB boot sequence. Background Art
[0002] In Linux system, boot loader is very important. It is the middleware for computer to start operating system. Boot loader will load the kernel and RAM file system of operating system, transfer control to the kernel of operating system, and then the kernel will initialize other parts of operating system, such as drivers of various peripherals, chip integrated device drivers, desktop environment, etc.
[0003] GRUB (GRand Unified Bootloader) is the most common boot loader in Linux distributions. During the process of booting the kernel, GRUB reads the kernel and RAM file system of the operating system in sequence through a disk or other storage media, and then transfers control to the kernel of the operating system. When the system mounts multiple disks, there is a need to modify the GRUB boot disk order. The conventional kernel boot disk location modifies the GRUB configuration file after the Linux system starts. However, in some special customer environments, there is a hard restriction that prohibits any modification to the operating system. The above modification of the disk order for the kernel boot parameters is no longer allowed. In this case, when there is a need to modify the kernel boot disk order, it cannot be modified, which increases user costs or poor user experience. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method for setting the GRUB boot sequence, a system for setting the GRUB boot sequence, a terminal for setting the GRUB boot sequence and a computer-readable storage medium in view of the above-mentioned defects of the prior art.
[0005] The technical solution adopted by the present invention to solve its technical problem is:
[0006] A method for setting the GRUB boot sequence is constructed, which includes the following steps:
[0007] During the BIOS startup phase, PCI devices are enumerated and PCI device paths are created;
[0008] BIOS enumerates the mounted storage devices of the PCI device, creates the storage device path, and installs the storage device path to the storage device handle;
[0009] BIOS installs BLOCK IO protocol to storage device handle;
[0010] The GRUB kernel boot disk sequentially obtains all BLOCK IO protocol handles installed during the BIOS startup phase, finds the storage device path through the handle, and divides the storage device into multiple storage device classes;
[0011] GRUB arranges storage devices of multiple storage device classes in ascending order according to the device paths;
[0012] GRUB boots the kernel program according to the configuration file and device order;
[0013] Read the kernel program through the BLOCK IO protocol and run the kernel program.
[0014] The method for setting the GRUB boot sequence of the present invention further comprises the steps of:
[0015] During the BIOS startup phase, the storage device path parameters are modified to adjust the GRUB kernel boot disk sequence.
[0016] In the method for setting the GRUB boot sequence of the present invention, the step of modifying the storage device path parameter includes modifying the device subpath size or the device path type.
[0017] In the method for setting the GRUB boot sequence of the present invention, the storage device is divided into multiple storage device classes by:
[0018] Storage devices are divided into three major storage device categories, namely HARDDISK devices, CDROM devices and floppy drive devices.
[0019] A system for setting a GRUB boot sequence, wherein the system includes a BIOS module, a PCI device, a mounted storage device, and a GRUB module;
[0020] The BIOS module, during the startup phase, enumerates PCI devices and creates PCI device paths; enumerates mounted storage devices of PCI devices and creates storage device paths, installs storage device paths to storage device handles; and installs BLOCK IO protocols to storage device handles;
[0021] The GRUB module, in which the boot disk sequentially obtains all BLOCK IO protocol handles installed during the BIOS startup phase, finds the storage device path through the handle, and divides the storage device into multiple storage device classes; arranges the storage devices of the multiple storage device classes in ascending order according to the device path; and boots the kernel program according to the configuration file and the device sequence;
[0022] The BIOS module reads the kernel program through the BLOCK IO protocol and runs the kernel program.
[0023] In the system for setting the GRUB boot sequence of the present invention, the BIOS module modifies the storage device path parameters during the boot phase to adjust the GRUB kernel boot disk sequence.
[0024] In the system for setting the GRUB boot sequence of the present invention, the modification of the storage device path parameter includes modifying the device subpath size or the device path type.
[0025] The system for setting the GRUB boot sequence of the present invention, wherein the storage device is divided into multiple storage device classes using:
[0026] Storage devices are divided into three major storage device categories, namely HARDDISK devices, CDROM devices and floppy drive devices.
[0027] A terminal for setting a GRUB startup sequence comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0028] A computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the above method when executed by a processor.
[0029] The beneficial effect of the present invention is that: by applying the method of the present application, the user can adjust the GRUB kernel boot disk order at the BIOS stage without modifying the GRUB configuration file or program, can adapt to various system requirements for mounting different storage devices, smoothly load the kernel program, and well cope with the application scenario where the modification of the kernel boot parameter disk order is not allowed, thereby reducing user costs and improving user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the present invention will be further described below in conjunction with the accompanying drawings and embodiments. The drawings described below are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work:
[0031] Figure 1 is a flow chart of a method for setting the GRUB boot sequence according to a preferred embodiment of the present invention;
[0032] Figure 2 It is a flowchart of a method for setting the GRUB boot sequence and a GRUB boot system startup procedure of a preferred embodiment of the present invention;
[0033] Figure 3The present invention is a flow chart of a method for setting the GRUB boot sequence in a BIOS according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the following will be described clearly and completely in combination with the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are partial embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.
[0035] The method for setting the GRUB boot sequence in a preferred embodiment of the present invention is as follows: Figure 1 As shown, the following steps are included:
[0036] S01: Enumerate PCI devices during BIOS startup and create PCI device paths;
[0037] S02: BIOS enumerates the mounted storage device of the PCI device, creates a storage device path, and installs the storage device path to the storage device handle;
[0038] S03: BIOS installs the BLOCK IO protocol to the storage device handle;
[0039] S04: The GRUB kernel boots the disk and sequentially obtains all BLOCK IO protocol handles installed during the BIOS startup phase, finds the storage device path through the handle, and divides the storage device into multiple storage device classes;
[0040] S05: GRUB arranges storage devices of multiple storage device classes in ascending order according to the device paths;
[0041] S06: GRUB boots the kernel program according to the configuration file and device sequence;
[0042] S07: Read the kernel program through the BLOCK IO protocol and run the kernel program;
[0043] By applying the method of the present application, users can adjust the GRUB kernel boot disk order at the BIOS stage without modifying the GRUB configuration file or program. It can adapt to various system requirements for mounting different storage devices and load the kernel program smoothly. It can well cope with application scenarios where modification of kernel boot parameters and disk order are not allowed, thereby reducing user costs and improving user experience.
[0044] Specifically, Figure 2 As shown, BIOS and GRUB boot the system startup program:
[0045] 1. During the BIOS boot phase, PCI devices are enumerated, such as floppy / USB / SATA / NVME device controllers, and PCI device paths are created.
[0046] 2. BIOS enumerates floppy / USB / SATA / NVME controllers to mount storage devices and creates device paths, such as / ACPI(a0341d0,0) / PCI(0,17) / SATA(2,fff,0) / End Entire, and installs the device paths to the storage device handles.
[0047] 3.BIOS installs BLOCK IO protocol to the storage device handle.
[0048] 4. The GRUB kernel boots the disk to sequentially obtain all BLOCK IO protocol handles installed during the BIOS startup phase, find the device path through the handle, and divide the storage devices into three major storage device categories, namely HARDDISK devices; CDROM devices; floppy drive devices
[0049] 5.GRUB arranges the three major storage device categories in ascending order according to the device path.
[0050] 6.GRUB determines the kernel file location through the disk order, reads the kernel program through the BLOCK IO protocol, and runs the kernel program.
[0051] like Figure 3 As shown in the figure, the BIOS sets the GRUB disk boot order method:
[0052] 1. During the BIOS boot phase, PCI devices are enumerated, such as floppy / USB / SATA / NVME device controllers, and PCI device paths are created.
[0053] 2. BIOS enumerates floppy / USB / SATA / NVME controllers to mount storage devices and creates device paths, such as / ACPI(a0341d0,0) / PCI(0,17) / SATA(2,fff,0) / End Entire, modifies the device subpath size or device path type or other device path parameters of the device path, and sets the device path to the storage device handle after installation.
[0054] 3.BIOS installs BLOCK IO protocol to the storage device handle.
[0055] 4. The GRUB kernel boot disk sequentially obtains all BLOCK IO protocol handles installed during the BIOS startup phase, finds the device path through the handle, and divides the storage devices into three major storage device categories, namely HARDDISK devices; CDROM devices; and floppy drive devices;
[0056] 5.GRUB arranges the three major storage device categories in ascending order according to the device path.
[0057] 6.GRUB starts the kernel program according to the disk order after BIOS setting.
[0058] Through the present invention, the user can adjust the GRUB kernel boot disk sequence in the BIOS stage without modifying the GRUB configuration file or program, and can adapt to various system requirements for mounting different storage devices and smoothly load the kernel program.
[0059] A system for setting a GRUB boot sequence, the system comprising a BIOS module, a PCI device, a mounted storage device, and a GRUB module;
[0060] BIOS module, enumerates PCI devices during the startup phase and creates PCI device paths; enumerates the mounted storage devices of PCI devices, creates storage device paths, installs storage device paths to storage device handles; installs BLOCK IO protocol to storage device handles;
[0061] GRUB module, boot disk sequence to obtain all BLOCK IO protocol handles installed in the BIOS startup phase, find the storage device path through the handle, divide the storage device into multiple storage device classes; sort the storage devices of multiple storage device classes in ascending order according to the device path; boot the kernel program according to the configuration file and device sequence;
[0062] The BIOS module reads the kernel program through the BLOCK IO protocol and runs the kernel program;
[0063] By using the system of the present application, users can adjust the GRUB kernel boot disk order at the BIOS stage without modifying the GRUB configuration file or program. It can adapt to various system requirements for mounting different storage devices and load the kernel program smoothly. It can well cope with application scenarios where modification of kernel boot parameters and disk order are not allowed, thereby reducing user costs and improving user experience.
[0064] Specifically, Figure 2 As shown, BIOS and GRUB boot the system startup program:
[0065] 1. During the BIOS boot phase, PCI devices are enumerated, such as floppy / USB / SATA / NVME device controllers, and PCI device paths are created.
[0066] 2. BIOS enumerates floppy / USB / SATA / NVME controllers to mount storage devices and creates device paths, such as / ACPI(a0341d0,0) / PCI(0,17) / SATA(2,fff,0) / End Entire, and installs the device paths to the storage device handles.
[0067] 3.BIOS installs BLOCK IO protocol to the storage device handle.
[0068] 4. The GRUB kernel boots the disk to sequentially obtain all BLOCK IO protocol handles installed during the BIOS startup phase, find the device path through the handle, and divide the storage devices into three major storage device categories, namely HARDDISK devices; CDROM devices; floppy drive devices
[0069] 5.GRUB arranges the three major storage device categories in ascending order according to the device path.
[0070] 6.GRUB determines the kernel file location through the disk order, reads the kernel program through the BLOCK IO protocol, and runs the kernel program.
[0071] like Figure 3 As shown in the figure, the BIOS sets the GRUB disk boot order method:
[0072] 1. During the BIOS boot phase, PCI devices are enumerated, such as floppy / USB / SATA / NVME device controllers, and PCI device paths are created.
[0073] 2. BIOS enumerates floppy / USB / SATA / NVME controllers to mount storage devices and creates device paths, such as / ACPI(a0341d0,0) / PCI(0,17) / SATA(2,fff,0) / End Entire, modifies the device subpath size or device path type or other device path parameters of the device path, and sets the device path to the storage device handle after installation.
[0074] 3.BIOS installs BLOCK IO protocol to the storage device handle.
[0075] 4. The GRUB kernel boot disk sequentially obtains all BLOCK IO protocol handles installed during the BIOS startup phase, finds the device path through the handle, and divides the storage devices into three major storage device categories, namely HARDDISK devices; CDROM devices; and floppy drive devices;
[0076] 5.GRUB arranges the three major storage device categories in ascending order according to the device path.
[0077] 6.GRUB starts the kernel program according to the disk order after BIOS setting.
[0078] Through the present invention, the user can adjust the GRUB kernel boot disk sequence in the BIOS stage without modifying the GRUB configuration file or program, and can adapt to various system requirements for mounting different storage devices and smoothly load the kernel program.
[0079] A terminal for setting a GRUB startup sequence comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0080] A computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the above method when executed by a processor.
[0081] The method and technology for setting the GRUB disk boot order of this application are mainly used for servers, workstations or desktops (domestic - Tongxin UOS / INTEL / AMD) using GRUB to boot kernel devices.
[0082] It should be understood that those skilled in the art can make improvements or changes based on the above description, and all these improvements and changes should fall within the scope of protection of the appended claims of the present invention.
Claims
1. A method for setting the GRUB boot sequence, characterized in that: The following steps are involved: During the BIOS startup phase, PCI devices are enumerated and PCI device paths are created; BIOS enumerates the mounted storage devices of the PCI device, creates the storage device path, and installs the storage device path to the storage device handle; BIOS installs BLOCK IO protocol to storage device handle; The GRUB kernel boot disk sequentially obtains all BLOCK IO protocol handles installed during the BIOS startup phase, finds the storage device path through the handle, and divides the storage device into multiple storage device classes; GRUB arranges storage devices of multiple storage device classes in ascending order according to the device paths; GRUB boots the kernel program according to the configuration file and device order; Read the kernel program through the BLOCK IO protocol and run the kernel program.
2. The method for setting the GRUB boot sequence according to claim 1, characterized in that: The method further comprises the steps of: During the BIOS startup phase, the storage device path parameters are modified to adjust the GRUB kernel boot disk sequence.
3. The method for setting the GRUB boot sequence according to claim 2, characterized in that: The modifying of the storage device path parameter includes modifying the device sub-path size or the device path type.
4. The method for setting the GRUB boot sequence according to claim 1, characterized in that: The storage devices are divided into multiple storage device classes by: Storage devices are divided into three major storage device categories, namely HARDDISK devices, CDROM devices and floppy drive devices.
5. A system for setting the GRUB boot sequence, characterized in that: The system includes a BIOS module, a PCI device, a mounted storage device, and a GRUB module; The BIOS module enumerates PCI devices and creates PCI device paths during the startup phase; Enumerate the mounted storage devices of the PCI device, create the storage device path, install the storage device path to the storage device handle; install the BLOCK IO protocol to the storage device handle; The GRUB module, in which the boot disk sequentially obtains all BLOCK IO protocol handles installed during the BIOS startup phase, finds the storage device path through the handle, and divides the storage device into multiple storage device classes; arranges the storage devices of the multiple storage device classes in ascending order according to the device path; and boots the kernel program according to the configuration file and the device sequence; The BIOS module reads the kernel program through the BLOCK IO protocol and runs the kernel program.
6. The system for setting the GRUB boot sequence according to claim 5, characterized in that: The BIOS module modifies the storage device path parameters during the startup phase to adjust the GRUB kernel boot disk sequence.
7. The system for setting the GRUB boot sequence according to claim 6, characterized in that: The modifying of the storage device path parameter includes modifying the device sub-path size or the device path type.
8. The system for setting the GRUB boot sequence according to claim 5, characterized in that: The storage devices are divided into multiple storage device classes by: Storage devices are divided into three major storage device categories, namely HARDDISK devices, CDROM devices and floppy drive devices.
9. A terminal for setting a GRUB boot sequence, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.