Methods for visually configuring GRUB menu items and their boot parameters

By interacting between the front-end window process and the back-end daemon process, a visual interface is provided to configure GRUB menu items and their startup parameters. This solves the problems of complex and error-prone configuration in existing technologies, and enables user-friendly parameter modification and automatic validity detection, ensuring that parameters are effective in multi-architecture systems and are not overwritten.

CN120994275BActive Publication Date: 2026-01-30KYLIN CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511529741.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-24
Publication Date
2026-01-30
Estimated Expiration
2045-10-24

AI Technical Summary

Technical Problem

Existing methods for modifying GRUB menu items and their boot parameters are complex and not intuitive, especially for non-professional users, and can easily lead to system boot failures.

Method used

This paper provides a method for visually configuring GRUB menu items and their boot parameters. Through the interaction between the foreground window process and the backend daemon process, a user-friendly interface is implemented using the dbus interface. The method automatically detects the legality of the modified content and saves the modified parameters in a newly added configuration file grubParam.ini.

Benefits of technology

It implements user-friendly GRUB menu item parameter configuration, avoiding system boot failures due to modification errors, supports parameter effects on multiple architecture systems, and ensures that user modifications are not overwritten after system updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994275B_ABST
    Figure CN120994275B_ABST
Patent Text Reader

Abstract

This invention relates to a method for visually configuring GRUB menu items and their startup parameters. It involves configuring a front-end window process that interacts with the user and a back-end daemon process that interacts with the front-end window process. The front-end window process obtains the menu items and startup parameters by calling the back-end daemon process's interface. Simultaneously, the user can set and modify the corresponding menu items and startup parameters through the interactive interface, which are then passed to the back-end daemon process. The back-end daemon process provides a set of back-end interfaces for reading and writing GRUB menu items and startup parameters for the front-end window process to call in real time. This invention allows users to more conveniently modify the startup parameters of GRUB2 menu items and to more intuitively read the current parameter content. Furthermore, the graphical configuration automatically checks the validity of the user's modifications during the modification process, preventing system startup failures due to incorrect modifications.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of system startup visualization configuration, and particularly relates to a method for visualizing configuration of GRUB menu items and their startup parameters. BACKGROUND

[0002] GRUB (GNU GRand Unified Bootloader) is a multi-operating system startup program of the GNU project. GRUB2 has made many improvements and enhancements based on the flexibility and powerful functions of GRUB, and is widely used as a bootloader in modern computer systems.

[0003] The main usage scenarios of GRUB2 menu items include:

[0004] 1. Multi-system booting: GRUB2 is widely used in the boot configuration of dual or multi-systems. By configuring the grub.cfg file, the coexistence and booting of multiple operating systems can be achieved.

[0005] 2. System recovery and troubleshooting: GRUB2 provides a powerful command-line interface and advanced debugging functions, making it an important tool for system troubleshooting.

[0006] 3. Customized startup options: GRUB2 allows users to pass parameters to different operating system kernels to achieve specific startup behaviors. In addition, users can customize the startup screen and menu items to meet individual needs.

[0007] The booting process of GRUB2 can be roughly divided into the following stages:

[0008] 1. First stage: When the computer starts, the BIOS or UEFI firmware hands over control to the first-stage boot loader of GRUB2. This loader is usually located in the master boot record or the UEFI boot partition.

[0009] 2. Second stage: The first-stage loader loads the core image file of GRUB2, which contains necessary modules and file system drivers.

[0010] 3. Configuration file loading: The second-stage boot loader loads the GRUB2 configuration file (grub.cfg) and boots the operating system kernel according to the instructions in the configuration file.

[0011] GRUB2, as an important part of domestic operating systems, provides powerful and flexible booting functions for users, and plays an important role in customizing, upgrading kernels, backing up and restoring systems, and system fault repair.

[0012] GRUB2 is an important boot loader in domestic operating system, which is responsible for presenting the boot option menu when the system starts. To modify the boot parameters of GRUB2, there are usually two most direct ways to achieve:

[0013] 1. The official recommended method, that is, by modifying the configuration file / etc / default / grub, the detailed steps are as follows: first, open the / etc / default / grub file with root permission, modify the configurable parameters, such as GRUB_DEFAULT, which represents the default menu item; GRUB_TIMEOUT represents the menu display time, the unit is second; GRUB_CMDLINE_LINUX_DEFAULT represents the default value of the kernel startup parameter. After modification, save and close the configuration file. Finally, run the update-grub command to regenerate the grub.cfg file.

[0014] 2. Instant effect method, that is, directly editing the grub.cfg file, which can also modify the default menu item, menu display time, kernel startup parameter and so on as needed.

[0015] The above two methods have defects: method one through modifying the default configuration file has modification range limitation, part of the kernel startup parameters (such as the startup disk symbol) cannot be modified, and in the case of multiple kernels, it cannot configure differentiated parameters for multiple kernels; Method two directly modifies the grub.cfg file, which is more flexible and has a wider modification range, but it is not the official recommended method, because this file is automatically generated and may be overwritten in future system updates, and the path of this file is different in different architectures. Users directly modify it and it is easy to confuse; In addition, the above two methods are too complex for non-professional linux users, and some subtle error configurations may cause the system to fail to start. SUMMARY

[0016] To solve the problems in the prior art, the present application provides a method for visualizing configuration of GRUB menu items and their startup parameters, comprising:

[0017] configuring a front-end window process interacting with the user and a back-end daemon process interacting with the front-end window process, wherein

[0018] The front-end window process is integrated into the system settings in the form of a plug-in, which obtains the menu item and startup parameter content by calling the back-end interface of the back-end daemon process, and displays it to the user. At the same time, the user can set and modify the corresponding menu item and startup parameter through the interactive interface provided by the front-end window process, and then pass the menu item and startup parameter to the back-end daemon process in the form of calling the dbus interface;

[0019] The backend daemon process provides a set of backend interfaces for the front-end window process to read and write GRUB menu items and boot parameters in real time, and the backend interfaces are internally implemented by reading and writing GRUB related configuration files.

[0020] The process in which the user reads the default GRUB menu item from the backend daemon process through the front-end window process includes:

[0021] Step S11: The user opens the control panel corresponding to the front-end window process, and performs main window initialization of the front-end window process.

[0022] Step S12: The front-end window process is loaded.

[0023] Step S13: The front-end window process initializes and sets the control state of all control menu items.

[0024] Step S14: The front-end window process calls the backend interface provided by the backend daemon process through the dbus interface.

[0025] Step S15: The backend interface reads the / etc / default / grub configuration file, retrieves the GRUB_DEFAULT parameter value from the / etc / default / grub configuration file, and returns the GRUB_DEFAULT parameter value to the front-end window process.

[0026] Step S16: The front-end window process sets the corresponding menu item as "selected" according to the GRUB_DEFAULT parameter value.

[0027] The process in which the user sets and modifies the default menu item through the interactive interface provided by the front-end window process includes:

[0028] Step S21: The user opens the control panel corresponding to the front-end window process, and performs main window initialization of the front-end window process.

[0029] Step S22: The front-end window process is loaded.

[0030] Step S23: The front-end window process initializes and sets the control state of all control menu items.

[0031] Step S24: The front-end window process sets up a listener for control menu item click events, and specifies the corresponding event handling method.

[0032] Step S25: The user clicks on a new menu item, and the event handling method starts to execute.

[0033] Step S26: The front-end window process calls the backend interface provided by the backend daemon process through the dbus interface, and passes the index value of the menu item clicked by the user.

[0034] Step S27: The backend interface reads the / etc / default / grub configuration file, and writes the menu item index value into the GRUB_DEFAULT parameter value in the / etc / default / grub configuration file.

[0035] The process in which the user sets the menu item delay through the interactive interface provided by the front-end window process includes:

[0036] Step S31: The user opens the control panel corresponding to the front-end window process, and performs the main window initialization of the front-end window process.

[0037] Step S32: The front-end window process is loaded.

[0038] Step S33: The front-end window process initializes to set the control state of all control menu items.

[0039] Step S34: The front-end window process sets a listener for the control event related to the display of the control menu item, and specifies the corresponding event processing method.

[0040] Step S35: The user sets the delay of the menu item, and the event processing method starts to execute.

[0041] Step S36: The front-end window process calls the backend interface provided by the backend daemon process through the dbus interface, and passes the GRUB_TIMEOUT parameter value of the menu item set by the user.

[0042] Step S37: The backend daemon process reads the / etc / default / grub configuration file, and writes the GRUB_TIMEOUT parameter value into the / etc / default / grub configuration file.

[0043] The delay setting of the menu item by the user includes turning on the menu item delay or turning off the menu item delay, wherein the GRUB_TIMEOUT parameter value when the user turns on the menu item delay is greater than the GRUB_TIMEOUT parameter value when the user turns off the menu item delay.

[0044] When the front-end window process calls the backend daemon process interface to obtain the menu item and the startup parameter content and displays them to the user, the backend daemon process parses the menu item list and the corresponding startup parameters from the grub.cfg file, and returns the parsed menu item list and the corresponding startup parameters to the front-end window process, so that the front-end window process displays each menu item in the form of a main menu and a sub-menu.

[0045] The process of parsing the menu item list and corresponding boot parameters from the grub.cfg file by the backend daemon process includes:

[0046] Step S41: initializing the menu item list: initializing the menu stack for storing menu items; initializing the params stack for storing menu item parameters; initializing the primary menu serial number s_no=0 and the secondary menu serial number m_no=0;

[0047] Step S42: judging whether the grub.cfg file exists, if yes, executing step S43, if not, ending;

[0048] Step S43: reading the content of the grub.cfg file line by line, judging whether the current line read is the last line of the grub.cfg file: if yes, executing step S417, if not, executing step S44;

[0049] Step S44: judging whether the current line read is a menu item: if yes, executing step S45 to step S46, if not, executing step S47;

[0050] Step S45: pushing the content of the current line to the menu stack;

[0051] Step S46: judging whether the content of the current line starts with "submenu": if yes, resetting the secondary menu serial number m_no=0 and jumping to step S43; if not, directly jumping to step S43;

[0052] Step S47: judging whether the content of the current line is a menu item parameter line: if yes, executing step S48, if not, executing step S49;

[0053] Step S48: pushing the content of the current line to the params stack and jumping to step S43;

[0054] Step S49: judging whether the current line is the end line of a menu item: if yes, executing step S410, if not, jumping to step S43;

[0055] Step S410: determining the top element of the menu stack as the current menu item;

[0056] Step S411: judging whether the current menu item is a first-level menu item: if yes, recording the index value of the current menu item as the primary menu serial number s_no and simultaneously making s_no increment by 1; if not, recording the index value of the current menu item as s_no>m_no and simultaneously making m_no increment by 1;

[0057] Step S412: judging whether the current menu item is a submenu type: if yes, the current menu item is not a final menu item, and its start parameter is empty, then executing step S414; if no, the current menu item is a final menu item, i.e. the current menu item has start parameter, then executing step S413;

[0058] Step S413: judging whether the params stack is empty: if no, then executing step S414; if yes, the top element of the params stack is popped out as all parameter strings of the current menu item, and then executing step S414;

[0059] Step S414: constructing a string of the current menu item;

[0060] Step S415: if the current menu item is a submenu type, then inserting the string of the current menu item into the menu item list at a position of m_no from the end of the menu item list; if the current menu item is not a submenu type, then appending the string of the current menu item to the end of the menu item list;

[0061] Step S416: jumping to step S43;

[0062] Step S417: initializing the newly added configuration file grubParam.ini according to the menu item list;

[0063] Step S418: returning the configuration file grubParam.ini to obtain the processed menu item list and corresponding menu item parameters.

[0064] In step S44, whether the current line is a menu item is judged by judging whether the current line starts with “menuentry” or “submenu” and ends with “{”.

[0065] In step S49, whether the current line is an end line of a menu item is judged by judging whether the current line starts with “}” and the top element of the menu stack ends with “{”.

[0066] In step S414, the contents of constructing the string of the current menu item include: title, value of id key, index value, flag of whether it is a submenu, and default parameter value.

[0067] In step S417, the process of initializing the newly added configuration file grubParam.ini includes:

[0068] reading the DefaultSettings group, for the DefaultSettings group, traversing each menu item in the menu item list, taking it as the current menu item, if the value of the id key of the current menu item exists in the DefaultSettings group, the parameter information corresponding to the value of the id key of the current menu item existing in the DefaultSettings group is replaced with the parameter information of the current menu item; if the value of the id key of the current menu item does not exist in the DefaultSettings group, the value of the id key and the parameter information of the current menu item are stored in the DefaultSettings group as a key-value pair;

[0069] reading the LastestSettings group, for the LastestSettings group, traversing each menu item in the menu item list, taking it as the current menu item, judging whether the value of the id key of the current menu item exists in the LastestSettings group: if not, the value of the id key and the parameter information of the current menu item are stored in the LastestSettings group as a key-value pair.

[0070] reading the DisplaySettings group, for the DisplaySettings group, traversing each menu item in the menu item list, taking it as the current menu item, setting the display parameter for the current menu item in the DisplaySettings group.

[0071] The application provides a visual interface, which can make the user more convenient to modify the GRUB2 menu item parameters, and can more intuitively read the current parameter content, and the graphical configuration can automatically detect whether the user's modification content is legal in the process of user's use and modification, so as to avoid the situation that the system cannot be started due to modification errors. BRIEF DESCRIPTION OF DRAWINGS

[0072] Figure 1 The figure is an interactive interface provided for the front-end window process of the application.

[0073] Figure 2 The figure is another interactive interface provided for the front-end window process of the application.

[0074] Figure 3 The figure is a process of reading the default GRUB menu item from the back-end daemon process through the front-end window process of the application.

[0075] Figure 4 The figure is a process of modifying the default menu item through the interactive interface provided by the front-end window process of the application. DETAILED DESCRIPTION

[0076] In order to have a further understanding of the technical solutions and beneficial effects of the present application, the technical solutions of the present application and the beneficial effects thereof will be described in detail below with reference to the drawings.

[0077] Embodiment 1

[0078] The method for visualizing configuration of GRUB menu items and their startup parameters of the present application mainly realizes the visualizing configuration function of GRUB menu items and their startup parameters through two parts, which respectively involve a front-end window process for interacting with a user and a back-end daemon process for interacting with the front-end window process, and all of which are realized through Qt.

[0079] The front-end window process is integrated into the system settings in the form of a plug-in, obtains the menu item and startup parameter content by calling the back-end interface of the back-end daemon process, and shows them to the user. Meanwhile, the user can set and modify the corresponding menu item and startup parameter through the interactive interface provided by the front-end window process, and then pass the menu item and startup parameter to the back-end daemon process in the form of calling the dbus interface. The back-end daemon process provides a set of back-end interfaces for reading and writing GRUB menu items and startup parameters for real-time calling by the front-end window process, and the back-end interfaces are internally realized by reading and writing GRUB-related configuration files.

[0080] The present application can be used for visualizing configuration of GRUB2 menu items and their startup parameters in actual use.

[0081] The interactive interface displays the list of GRUB2 menu items of the current system. Since the GRUB2 menu items are divided into two categories: main menu (menuentry) and submenu (submenu), and the submenu may contain multiple main menu (menuentry) items, both the main menu and the submenu have corresponding display titles, but only the main menu (menuentry) has parameters such as kernel and hard disk symbol. Therefore, during the running of GRUB2, only after the user selects the main menu, the corresponding kernel and operating system will be entered. According to the above classification of GRUB2 menu items, only the title of the submenu needs to be displayed, while the main menu item displays a computer icon and a title to distinguish them. In addition, the menu item can be set as the default menu item by being clicked by the user, and the corresponding parameter list can also be modified by the user, so the right side of the menu item displays whether it is selected as the default menu item and the button for editing the parameter list. Since the submenu can contain multiple menu items, the submenu can be selected in two states: folded or unfolded. When the submenu is in the unfolded state, the menu items belonging to the submenu are normally displayed, otherwise they are not displayed.

[0082] Figure 1The interface for user to edit the parameter list of a certain GRUB2 menu item, here lists all the parameters of the current menu item except the kernel. For the parameters that do not need to edit the parameter value, only the parameter name is displayed, and the delete and switch buttons are displayed, clicking the delete button can delete the parameter, and clicking the switch button can turn off or turn on the parameter. For editable parameters, the parameter name that cannot be modified and the editable parameter value are displayed, and the delete and switch buttons are displayed. The final effect of deleting and closing the parameter is the same, that is, removing the parameter in the corresponding menu item, but the deleted parameter will not be displayed on the interface, while the closed parameter will still be displayed on the interface.

[0083] Figure 1 The "add" button in the interface can allow the user to add a custom parameter, after clicking "add", the user can input the new parameter in the input box, the value of the parameter is separated by "=", after inputting, the user can click the delete button to delete the parameter, or click the confirm button to confirm the addition of the custom parameter. Figure 2

[0084] Figure 1 The "restore default" button in the interface can allow the user to restore the current parameter list to the initial state of the system.

[0085] Embodiment 2:

[0086] The process in which the user reads the default GRUB menu item from the backend daemon process through the frontend window process, please refer to the figure shown in Figure 3 , including the following steps:

[0087] 1. The user (Actor in Figure 3 ) opens the control panel corresponding to the frontend window process, and performs the initialization of the main window (mainwindow in Figure 3 ) of the frontend window process.

[0088] 2. Load the frontend window process (Load boot plug-in in Figure 3 );

[0089] 3. The frontend window process initializes the control state of all control menu items displayed (Interface control initialization in Figure 3 ); all controls for displaying control menu items, including but not limited to control buttons, labels for displaying text, and switches for indicating certain states.

[0090] 4. The frontend window process calls the backend interface provided by the backend daemon process through the dbus interface (Get default menu item index interface in Figure 3 );

[0091] ​5. The backend interface reads the / etc / default / grub configuration file, retrieves the GRUB_DEFAULT parameter value from the / etc / default / grub configuration file, and returns it to the frontend window process;

[0092] 6. The foreground window process sets the corresponding menu item to "selected" based on the GRUB_DEFAULT parameter value. Figure 3 (In the settings interface, display default menu items).

[0093] Example 3:

[0094] The process of a user modifying default menu items through the interactive interface provided by the foreground window process, please refer to... Figure 4 As shown, it includes the following steps:

[0095] 1. User ( Figure 4 The "Actor" command opens the control panel corresponding to the foreground window process and executes the main window of the foreground window process. Figure 4 Initialize "mainwindow" in the middle;

[0096] 2. Load the foreground window process ( Figure 4 (Load boot plugin)

[0097] 3. Initialize the front-end window process to set the state of all controls that control the display of menu items. Figure 4 (In the "Interface Control Initialization" section)

[0098] 4. The front-end window process sets up listeners for control events related to clicking menu items and specifies the corresponding event handling methods;

[0099] 5. When the user clicks a new menu item, the event handler begins to execute;

[0100] 6. The foreground window process calls the backend interface provided by the backend daemon process through the dbus interface, passing the index value of the menu item clicked by the user (corresponding to...). Figure 4 (In the "Passing parameters: new menu item index number").

[0101] 7. Backend Interface ( Figure 4 The "Default Menu Item Index Interface" reads the / etc / default / grub configuration file and writes the menu item index value into the GRUB_DEFAULT parameter value in the / etc / default / grub configuration file.

[0102] Example 4:

[0103] The process by which a user sets the delay for menu items through the interactive interface provided by the foreground window process includes:

[0104] 1. The user opens the control panel corresponding to the front-end window process, and performs the main window initialization of the front-end window process;

[0105] 2. The front-end window process is loaded;

[0106] 3. The front-end window process initializes to set the control state of all control menu items displayed;

[0107] 4. The front-end window process sets up a listener for the control events related to the control menu item display, and specifies the corresponding event processing method;

[0108] 5. The user performs the delay setting of the menu item, and the event processing method starts to execute;

[0109] 6. The front-end window process calls the back-end interface provided by the back-end daemon process through the dbus interface, and passes the GRUB_TIMEOUT parameter value of the menu item for which the user performs the delay setting;

[0110] 7. The back-end daemon process reads the / etc / default / grub configuration file, and writes the GRUB_TIMEOUT parameter value into the / etc / default / grub configuration file.

[0111] The user's delay setting of the menu item includes opening the menu item delay or closing the menu item delay, wherein the GRUB_TIMEOUT parameter value when the user opens the menu item delay (for example, 5 seconds, indicating that the GRUB menu waiting time is 5 seconds) is greater than the GRUB_TIMEOUT parameter value when the user closes the menu item delay (for example, 1 second, indicating that the GRUB menu waiting time is 1 second).

[0112] An example of a GRUB startup parameter configuration file grubParam.ini of the present application: There are three groups in the configuration file: "DefaultSettings" represents the initial default settings of the system, "LatestSettings" represents the settings after the last modification by the user, and "DisplaySettings" represents the settings that need to be displayed by the graphical interface after the current user modification. The parameter name under all groups is the id of each menu item of the current system, the parameter value under the "DefaultSettings" group is the parameter string of the corresponding menu item in the grub.cfg file generated by the system initially; the parameter value under the "LatestSettings" group is the menu item parameter string updated by the user last time, and the grub.cfg file is regenerated after the system is upgraded or a kernel is added, and the parameter string is synchronized to the grub.cfg file; the parameter value under the "DisplaySettings" group connects all menu item parameters into a string in the format of "parameter: type=value", wherein "parameter" is the single parameter name of the current menu item, "type" represents the display state (delete, close, open) of the current parameter in the graphical interface, and "=value" is an optional option, which exists only when the current parameter value can be customized and modified.

[0113] Embodiment 5

[0114] In the present application, when the front-end window process calls the back-end daemon process interface to obtain the menu item and startup parameter content and shows it to the user, the back-end daemon process parses the menu item list and corresponding startup parameters from the grub.cfg file and returns the parsed menu item list and corresponding startup parameters to the front-end window process, so that the front-end window process displays each menu item in the form of a main menu and a submenu.

[0115] The process of parsing the menu item list and corresponding startup parameters from the grub.cfg file by the back-end daemon process includes:

[0116] 1. Initialize the menu item list: initialize the menu stack for storing menu items (including submenu and menuentry); initialize the params stack for storing menu item parameters; initialize the first-level menu serial number s_no=0 and the second-level menu serial number m_no=0;

[0117] 2. Determine whether the grub.cfg file exists and can be read, if yes, execute step 3, if not, end;

[0118] 3. Read the content of the grub.cfg file line by line, determine whether the current line read is the last line of the grub.cfg file: if yes, execute step 17, if not, execute step 4;

[0119] 4. Determine whether the current line is a menu item (i.e. whether it starts with "menuentry" or "submenu" and ends with "{") : if yes, go to step 5 to step 6, if no, go to step 7;

[0120] 5. Push the content of the current line to the menu stack;

[0121] 6. Determine whether the content of the current line starts with "submenu" : if yes, reset the secondary menu number m_no = 0 and go to step 3; if no, go to step 3 directly;

[0122] 7. Determine whether the content of the current line is a menu item parameter line (in this embodiment, it is determined by judging whether the content of the current line starts with "linux") : if yes, go to step 8, if no, go to step 9;

[0123] 8. Push the content of the current line to the params stack and go to step 3;

[0124] 9. Determine whether the current line is the end line of a menu item (i.e. whether it starts with "}" and the top element of the menu stack ends with "{") : if yes, go to step 10, if no, go to step 3;

[0125] 10. Determine that the top element of the menu stack is the current menu item (i.e. put the top element of the menu stack into a temporary variable items, and subsequently determine the conditions related to the current menu item through the items variable) ; the "current menu item" in this step is the same as the "menu item" determined in step 9;

[0126] 11. Determine whether the current menu item is a first-level menu item (i.e. whether the menu stack is empty) : if yes, record the index value of the current menu item as the primary menu number s_no and make s_no increment by 1; if no, record the index value of the current menu item as s_no > m_no and make m_no increment by 1;

[0127] 12. Determine whether the current menu item is a submenu (i.e. whether the top element represented by the items variable starts with "submenu") : if yes, the current menu item is not a final-level menu item and its starting parameter is empty, go to step 14; if no, the current menu item is a final-level menu item and the menu item should have a starting parameter, go to step 13;

[0128] 13. judging whether the params stack is empty: if not, going to step 14; if yes, popping the top element of the params stack as all parameter strings of the current menu item, and then going to step 14;

[0129] 14. constructing a string of the current menu item, the content of the string including: title, value of id key, index value (serial number), mark of whether being a submenu (i.e. whether being submenu), and default parameter value, all of which are separated by "'' ";

[0130] 15. putting the string into the menu item list according to the index value, and the specific principle is: if the current menu item is a submenu, the string of the menu item is inserted into the position of m_no from the end of the menu item list (i.e. before the corresponding second-level menu); if the current menu item is not a submenu, the string of the menu item is appended to the end of the menu item list;

[0131] 16. jumping to step 3;

[0132] 17. initializing the newly added configuration file grubParam.ini according to the menu item list;

[0133] 18. returning the configuration file grubParam.ini to obtain the menu item list and corresponding parameters, and the process ends; the menu item parameters are returned in the form of strings, and the strings of the parameters of each menu item are separated by ",".

[0134] Before step 17 (i.e. embodiment 6) is executed, the parameter information in all menu items in the obtained menu item list is the system default information, and after the processing of step 17 (i.e. embodiment 6), all menu items in the menu item list are updated with the latest menu item parameter information according to the user modification record.

[0135] In the present application, grub.cfg is generally automatically generated by the system, and can be modified by the user, but has the risk of being automatically overwritten; / etc / default / grub can be freely set and modified by the user, and the corresponding modification can be synchronized to grub.cfg by the grub related system tool.

[0136] Embodiment 6:

[0137] The process of initializing the newly added configuration file grubParam.ini of the present application includes the following steps:

[0138] For the initial default setting of the system:

[0139] 1-1. opening the grubParam.ini file in read-write mode (if not existing, creating), and starting to read the DefaultSettings group (if not existing, creating the group);

[0140] 1-2, for the current DefaultSettings group, traverse all menu items in the menu item list, respectively as the current menu item, if the traversal is completed, end reading the DefaultSettings group into 1-3, if the traversal is not completed, execute 1-3;

[0141] 1-3, get the value of the id key of the current menu item and the parameter information;

[0142] 1-4, judge whether the value of the current menu item id key exists in the current DefaultSettings group:

[0143] If it exists, replace the parameter information of the current menu item with the parameter information corresponding to the value of the id key corresponding to the current menu item in the current DefaultSettings group;

[0144] If it does not exist, store the value of the id key and the parameter information of the current menu item as a key-value pair in the current DefaultSettings group;

[0145] 1-5, return to step 1-2.

[0146] For the settings modified by the user last time:

[0147] 2-1, start reading the LatestSettings group;

[0148] 2-2, for the current LatestSettings group, traverse all menu items in the menu item list, respectively as the current menu item, if the traversal is completed, end reading the LatestSettings group into 3-1, if the traversal is not completed, execute 2-3;

[0149] 2-3, get the value of the id key of the current menu item and the parameter information;

[0150] 2-4, judge whether the value of the current menu item id key exists in the current LatestSettings group: if it does not exist, store the value of the id key and the parameter information of the current menu item as a key-value pair in the current LatestSettings group;

[0151] 2-5, return to step 2-2

[0152] For the settings modified by the user last time:

[0153] 3-1, start reading the DisplaySettings group;

[0154] 3-2, for the current DisplaySettings group, traverse all menu items in the menu item list, respectively as the current menu item, if the traversal is completed, end reading the DisplaySettings group, and the process ends, if not, execute 3-3;

[0155] 3-3, get the value of the id key of the current menu item and the parameter information;

[0156] 3-4, determine whether the current DisplaySettings group exists the value of the current menu item id key:

[0157] If it exists, the parameter corresponding to the value of the current menu item id key in the current DisplaySettings group is taken as the display parameter of the current menu item;

[0158] If it does not exist, the display parameter is obtained from the default parameter information of the current menu item, and the id and the default parameter of the current menu item are added to the DisplaySettings group in the form of key-value pair as the display parameter of the current menu item;

[0159] 3-5, return to step 3-2.

[0160] Embodiment 7:

[0161] After the user modifies a menu item parameter through the front-end window, the daemon process called by the back-end daemon process implements the whole process of updating the new parameter to grubParams.ini and grub.cfg as follows: steps 1-6.

[0162] 1, the back-end daemon process receives the parameters transmitted by the front-end window process: the value of the id key of the GRUB2 menu item modified by the user (later represented by id), and the GRUB2 menu item parameter content modified by the user (later represented by params), detects the legality of the new parameter content, if legal, enter step 2, otherwise return.

[0163] 2, read the grubParams.ini configuration file.

[0164] 3, write the key-value pair (id, params) to the "DisplaySettings" group.

[0165] 4, write the key-value pair (id, processed params) to the "LatestSettings" group, where the params string is processed to remove the type value of each parameter item.

[0166] 5, call the script for updating GRUB2 parameters.

[0167] 6. Traverse the grubParams.ini configuration file line by line, filter out the content in the "LatestSettings" group, and update the parameter content of the corresponding id in grub.cfg according to the key-value pair of each line.

[0168] Step 6 is a specific step of calling the script in step 5, and the specific operation of updating grub.cfg is as follows:

[0169] 6-1. Determine the current system architecture, and then determine the grub.cfg path to be updated according to the architecture;

[0170] 6-2. Read the grubParams.ini configuration file line by line;

[0171] 6-3. Determine whether the current read line content is "[LatestSettings]": if yes, go to step 6-4, otherwise go to step 6-5;

[0172] 6-4. Set the start flag to true and return to step 6-2;

[0173] 6-5. Determine whether the start flag is true and whether the current read line content starts with "[": if yes, go to step 6-6, otherwise go to step 6-7;

[0174] 6-6. Set the end flag to true and return to step 6-2;

[0175] 6-7. Determine whether the start flag is true, i.e., whether the start flag is true: if yes, go to step 6-8, otherwise return to step 6-2;

[0176] 6-8. Determine whether the end flag is true: if yes, return to step 6-2, if no, go to step 6-9;

[0177] 6-9. Parse the (id, parameter) key-value pair;

[0178] 6-10. Search for id in grub.cfg, and replace the parameter value of the (id, parameter) key-value pair parsed in 6-9 with the parameter value in grub.cfg;

[0179] 6-11. Jump to step 6-2.

[0180] The technical effects of the present application are as follows:

[0181] 1、The application realizes the function of adding and modifying GRUB2 menu item parameters through visual interface design, and retains the fallback and special display functions of initial parameters in details. The initial parameters of the system are retained in DefaultSettings in grubParams.ini, and the function of resetting parameters through the front-end window can restore the parameters in grub.cfg to the initial parameters. Figure 1

[0182] 2、The application distinguishes the actual effective paths of grub.cfg under different architectures to ensure that the GRUB2 menu item parameters modified by the user through the visual window can indeed take effect in the boot process in any architecture system. In step 6 of embodiment 7, the system architecture is determined in the script for updating the menu item parameters, and the actual path of grub.cfg is determined according to the determination result. This also avoids the problem that the traditional method of modifying GRUB2 startup parameters (directly modifying grub.cfg) may not take effect due to path errors.

[0183] 3、The application saves the GRUB2 startup parameter content modified by the user last time through the newly added configuration file, and adds an executable script for synchronizing the user modified parameters to grub.cfg. The script will be executed every time the user confirms the modification of GRUB2 menu item parameters through the visual window or the system regenerates grub.cfg due to other reasons. This part is realized by modifying the original official script update-grub, and the call of the script for modifying grub.cfg added by the application is added in update-grub, so as to avoid the user's custom GRUB2 related settings being overwritten after executing the update-grub script.

[0184] 4、The application provides a visual interface, which can make it more convenient for users to modify GRUB2 menu item parameters, and can also more intuitively read the current parameter content. The graphical configuration will automatically detect whether the user's modification content is legal in the process of user use and modification, so as to avoid the situation that the system cannot start due to modification errors.

[0185] ​5、Compared with the existing method of modifying the parameter of GRUB2 menu item, i.e. modifying the default configuration file or directly modifying grub.cfg, the former has a limited range of modified parameters, the latter cannot guarantee that the modification is always effective, and both of the above two methods are not simple and intuitive, and the wrong modification may cause the defect of system startup failure; the present application can allow users to modify or increase all parameter contents except kernel files for different menu items, and the GRUB2 configuration modified by the user is immediately synchronized to grub.cfg;

[0186] Compared with the method of modifying the default configuration file and then calling to regenerate grub.cfg, the present application provides a larger modification range for users, such as users can re-specify the hard disk symbol of system startup;

[0187] Compared with the method of directly modifying grub.cfg, the present application can further reduce the system startup problem caused by some wrong modifications by increasing the legality constraint of user modified parameters and processing the storage path of grub.cfg of different architectures, and can guarantee that the user modified content will not be covered when the system is updated in the future.

[0188] Although the present application has been described by using the above preferred embodiments, it is not intended to limit the protection scope of the present application, and any person skilled in the art can make various changes and modifications to the above embodiments without departing from the spirit and scope of the present application, which are still within the protection scope of the present application, therefore the protection scope of the present application is defined by the claims.

Claims

1. A method of visualizing configuration of GRUB menu items and their boot parameters, characterized by The method comprises the following steps: A front-end window process configured to interact with a user and a back-end daemon process configured to interact with the front-end window process, wherein The front-end window process is integrated into the system settings in the form of a plug-in, obtains menu items and startup parameter contents by calling a back-end interface of the back-end daemon process, and displays them to the user; meanwhile, the user sets and modifies the corresponding menu items and startup parameters through an interactive interface provided by the front-end window process, and then passes the menu items and startup parameters to the back-end daemon process in the form of calling a dbus interface; The back-end daemon process provides a set of back-end interfaces for reading and writing GRUB menu items and startup parameters for the front-end window process to call in real time, and the back-end interfaces are internally implemented by reading and writing GRUB-related configuration files.

2. The method of visualizing configuration of GRUB menu items and their startup parameters according to claim 1, wherein The process in which the user reads the default GRUB menu items from the back-end daemon process through the front-end window process comprises the following steps: Step S11: The user opens a control panel corresponding to the front-end window process, and performs main window initialization of the front-end window process; Step S12: The front-end window process is loaded; Step S13: The front-end window process initializes to set the control state of all control menu items; Step S14: The front-end window process calls a back-end interface provided by the back-end daemon process through a dbus interface; Step S15: The back-end interface reads an / etc / default / grub configuration file, retrieves a GRUB_DEFAULT parameter value from the / etc / default / grub configuration file, and returns the GRUB_DEFAULT parameter value to the front-end window process; Step S16: The front-end window process sets the corresponding menu item as "selected" according to the GRUB_DEFAULT parameter value.

3. The method of visualizing configuration of GRUB menu items and their startup parameters according to claim 1, wherein The process in which the user sets and modifies the default menu items through the interactive interface provided by the front-end window process comprises the following steps: Step S21: The user opens a control panel corresponding to the front-end window process, and performs main window initialization of the front-end window process; Step S22: The front-end window process is loaded; Step S23: The front-end window process initializes to set the control state of all control menu items; Step S24: The front-end window process sets up a listener for a control event related to a control menu item click, and specifies a corresponding event handling method; Step S25: The user clicks a new menu item, and the event handling method starts to execute; Step S26: The front-end window process calls a back-end interface provided by the back-end daemon process through a dbus interface, and passes an index value of the menu item clicked by the user; Step S27: The back-end interface reads an / etc / default / grub configuration file, and writes the index value of the menu item into a GRUB_DEFAULT parameter value in the / etc / default / grub configuration file.

4. The method of visualizing configuration of GRUB menu items and their startup parameters according to claim 1, wherein The process of setting the menu item delay by the user through the interactive interface provided by the front-end window process includes: Step S31: The user opens the control panel corresponding to the front-end window process, and performs the main window initialization of the front-end window process; Step S32: The front-end window process is loaded; Step S33: The front-end window process initializes to set the control state of all control menu items displayed; Step S34: The front-end window process sets a listener for the control event related to the control menu item display, and specifies the corresponding event processing method; Step S35: The user sets the delay of the menu item, and the event processing method starts to execute; Step S36: The front-end window process calls the back-end interface provided by the back-end daemon process through the dbus interface, and transmits the GRUB_TIMEOUT parameter value of the menu item set by the user; Step S37: The back-end daemon process reads the / etc / default / grub configuration file, and writes the GRUB_TIMEOUT parameter value into the / etc / default / grub configuration file.

5. The method of visualizing configuration GRUB menu items and their boot parameters of claim 4, wherein: The delay setting of the menu item by the user includes opening the menu item delay or closing the menu item delay, wherein the GRUB_TIMEOUT parameter value when the user opens the menu item delay is greater than the GRUB_TIMEOUT parameter value when the user closes the menu item delay.

6. The method of visualizing configuration GRUB menu items and their boot parameters of claim 1, wherein: When the front-end window process calls the interface of the back-end daemon process to obtain the menu item and the start parameter content, and shows it to the user, the back-end daemon process parses the menu item list and the corresponding start parameter from the grub.cfg file, and returns the parsed menu item list and the corresponding start parameter to the front-end window process, so that the front-end window process displays each menu item in the form of a main menu and a sub-menu.

7. The method of visualizing configuration GRUB menu items and their boot parameters as claimed in claim 6, wherein: The process of parsing the menu item list and the corresponding start parameter from the grub.cfg file by the back-end daemon process includes: Step S41: Initialize the menu item list: initialize the menu stack for storing the menu item, initialize the params stack for storing the menu item parameter, initialize the first-level menu serial number s_no=0, and initialize the second-level menu serial number m_no=0; Step S42: Determine whether the grub.cfg file exists, if yes, execute step S43, if not, end; Step S43: Read the content of the grub.cfg file line by line, and determine whether the current line read is the last line of the grub.cfg file: if yes, execute step S417, if not, execute step S44; Step S44: Determine whether the current line read is a menu item: if yes, execute steps S45 to S46, if not, execute step S47; Step S45: Push the content of the current line to the menu stack; Step S46: Determine whether the content of the current line starts with "submenu": if yes, reset the second-level menu serial number m_no=0, and jump to step S43; if not, directly jump to step S43; Step S47: judging whether the current line is a menu item parameter line: if yes, then executing step S48, if not, then executing step S49; Step S48: pushing the current line to the params stack, and jumping to step S43; Step S49: judging whether the current line is the end line of a menu item: if yes, then executing step S410, if not, then jumping to step S43; Step S410: determining the top element of the menu stack as the current menu item; Step S411: judging whether the current menu item is a first level menu item: if yes, then recording the index value of the current menu item as the first level menu number s_no, and making s_no increment 1; if not, then recording the index value of the current menu item as s_no>m_no, and making m_no increment 1; Step S412: judging whether the current menu item is a submenu: if yes, then the current menu item is not a final level menu item, and its start parameter is empty, executing step S414; if not, then the current menu item is a final level menu item, i.e. the current menu item has a start parameter, executing step S413; Step S413: judging whether the params stack is empty: if not, then executing step S414; if yes, then popping the top element of the params stack as all parameter strings of the current menu item, and then executing step S414; Step S414: constructing a string of the current menu item; Step S415: if the current menu item is a submenu, then inserting the string of the current menu item into the menu item list at a position of m_no from the end of the menu item list; if the current menu item is not a submenu, then appending the string of the current menu item to the end of the menu item list; Step S416: jumping to step S43; Step S417: initializing the newly added configuration file grubParam.ini according to the menu item list; Step S418: returning the configuration file grubParam.ini, and obtaining the processed menu item list and corresponding menu item parameters.

8. The method of visualizing configuration GRUB menu items and their start parameters according to claim 7, characterized in that: in step S44, whether the current line is a menu item is judged by judging whether the current line starts with "menuentry" or "submenu", and ends with "{"; in step S49, whether the current line is the end line of a menu item is judged by judging whether the current line starts with "}", and the top element of the menu stack ends with "{".

9. The method of visualizing configuration GRUB menu items and their boot parameters of claim 7, wherein: in step S414, the contents of constructing the string of the current menu item include: title, value of id key, index value, flag of whether a submenu, and default parameter value.

10. The method of visualizing configuration GRUB menu items and their boot parameters of claim 7, wherein: the process of initializing the newly added configuration file grubParam.ini includes: reading the DefaultSettings group, for the DefaultSettings group, traversing each menu item in the menu item list, taking it as the current menu item, if the value of the id key of the current menu item exists in the DefaultSettings group, then the parameter information corresponding to the value of the id key of the current menu item existing in the DefaultSettings group is replaced with the parameter information of the current menu item; if the value of the id key of the current menu item does not exist in the DefaultSettings group, then the value of the id key and the parameter information of the current menu item are stored in the DefaultSettings group as a key-value pair; reading the LastestSettings group, for the LastestSettings group, traversing each menu item in the menu item list, taking it as the current menu item, judging whether the value of the id key of the current menu item exists in the LastestSettings group: if not, then the value of the id key and the parameter information of the current menu item are stored in the LastestSettings group as a key-value pair; reading the DisplaySettings group, for the DisplaySettings group, traversing each menu item in the menu item list, taking it as the current menu item, setting the display parameter for the current menu item in the DisplaySettings group.

Citation Information

Patent Citations

  • Manufacturing method and device of GNOME read-only desktop system

    CN110489168A

  • System and method for switching working modes of equipment

    CN113507384A