OSTree rollback method and device and storage medium

By using watchdogs to monitor the startup status of the new version of the system on Linux devices, and automatically roll back to the original version of the system when the number of restarts exceeds the threshold, the problem of problems in the new version of the system cannot be used normally is solved, and the reliability of the device is improved.

CN119883302AActive Publication Date: 2025-04-25KYLIN CORP

Patent Information

Application Number
CN202510352671.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-04-25
Estimated Expiration
2045-03-25

AI Technical Summary

Technical Problem

After the Linux device is upgraded using OSTree, there are problems with the new version of the system and cannot be used normally, resulting in serious reliability risks.

Method used

When the new version system is started for the first time, the preset watchdog monitoring system startup status is used to count the number of restarts. When the threshold is exceeded, it will automatically roll back to the original version system, and delete the new version related content through OSTree.

Benefits of technology

Ensure that when there is a problem with the new version of the system, it will automatically roll back to the original version of the system to avoid affecting the normal operation of the system and improve the reliability of the equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883302A_ABST
    Figure CN119883302A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an OSTree rollback method and device and a storage medium, and the method comprises the steps: when a new version is started for the first time after being correctly configured, starting a new version system according to a starting menu item identifier, and triggering restarting by using a preset watchdog when the starting of the new version system exceeds a timing parameter; a preset counting variable is used for counting the number of restarting times, and when the number of restarting times exceeds a preset restarting threshold value, the new-version starting menu item identification is set to be false; starting the original version system according to the starting menu item identifier, querying the rollback identifier after the original version system is normally started, deleting the content associated with the new version in the kernel, the temporary system file system and the root file system from the memory by using the OSTree when the rollback identifier is true, and deleting the configuration file corresponding to the new version. And meanwhile, modifying the priority content in the configuration file name corresponding to the original version system to form an original version system starting menu.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of OSTree technology, and in particular to an OSTree rollback method, device and storage medium. Background Art

[0002] In the field of industrial control and robot control, the use of Linux embedded operating systems is increasing. However, after the Linux system is deployed to the terminal device, the update and upgrade of the system image usually requires physical redeployment, which cannot ensure the best operating experience and system uptime. In order to improve the upgrade experience of the Linux system, it is important to achieve secure remote OTA upgrades.

[0003] OStree is a technology for operating system and container binary deployment and update. It combines a Git-like model to submit and download bootable file system trees, and has a mechanism for deploying them and managing boot program configuration. The Linux upgrade system based on OSTree has secure remote OTA upgrades, and the amount of data transmitted during the upgrade process is very small.

[0004] After OSTree is upgraded to a new version, if the new version has problems and cannot enter the system normally, the user needs to manually select the old version of the system boot menu to enter the original system. However, in reality, there are a large number of users who directly access Linux devices, which is very inconvenient. For such devices, once the upgraded new version has problems, it will cause serious reliability risks. Summary of the invention

[0005] The embodiment of the present invention provides an OSTree rollback method, device and storage medium to solve the technical problem in the prior art that Linux devices adopt OSTree upgrade and cannot be used normally due to problems in the new version system.

[0006] In a first aspect, an embodiment of the present invention provides an OSTree rollback method, comprising: When the new version is started for the first time after being correctly configured, the new version system is started according to the boot menu item identifier, and the preset watchdog is used to trigger a restart when the new version system startup exceeds the timing parameter; Counting the number of restarts using a preset counting variable, when the number exceeds a preset restart threshold, setting the new version startup menu item flag to false, setting the original version system startup menu item flag to true, and setting the rollback flag to true; The original version system is started according to the boot menu item identifier. After the original version system is started normally, the rollback identifier is queried. When the rollback identifier is true, OSTree is used to delete the kernel, the startup temporary system file system and the content associated with the new version in the root file system from the storage, and the configuration file corresponding to the new version is deleted. At the same time, the priority content in the configuration file name corresponding to the original version system is modified to form the boot menu of the original version system.

[0007] In a second aspect, an embodiment of the present invention further provides an OSTree rollback device, including: The identification module is used to start the new version system according to the boot menu item identification when the new version is started for the first time after being correctly configured, and to trigger a restart when the new version system starts for more than a timing parameter by using a preset watchdog; A setting module, used for counting the number of restarts using a preset counting variable, and when the number exceeds a preset restart threshold, setting the new version startup menu item flag to false, setting the original version system startup menu item flag to true, and setting the rollback flag to true; The deletion module is used to start the original version system according to the boot menu item identifier. After the original version system is started normally, the rollback identifier is queried. When the rollback identifier is true, OSTree is used to delete the kernel, the startup temporary system file system and the content associated with the new version in the root file system from the storage, and the configuration file corresponding to the new version is deleted. At the same time, the priority content in the configuration file name corresponding to the original version system is modified to form the boot menu of the original version system.

[0008] In a third aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the OSTree rollback method provided in the above embodiment.

[0009] The OSTree rollback method, device and storage medium provided by the embodiment of the present invention start the new version system according to the boot menu item identifier when the new version is correctly configured for the first time, and trigger the restart by using the preset watchdog when the new version system starts exceeding the timing parameter; use the preset counting variable to count the number of restarts, and when exceeding the preset restart threshold, set the new version boot menu item identifier to false, set the original version system boot menu item identifier to true, and set the rollback identifier to true; start the original version system according to the boot menu item identifier, and after the original version system starts normally, query the rollback identifier, and when the rollback identifier is true, use OSTree to delete the contents associated with the new version in the kernel, the startup temporary system file system and the root file system from the memory, and delete the configuration file corresponding to the new version, and modify the priority content in the configuration file name corresponding to the original version system to form the original version system boot menu. The boot menu item of the new version system is formed by the configuration information of the new version system, and the new version system can be automatically started, and the watchdog compiled by the kernel is used to monitor the startup of the new version. When the new version system cannot start normally, OSTree is used to eliminate the influence of the new version system. And modify the system startup menu again, and use the original version system as the new system startup item, so that when problems occur in the new version system, the original version system can be used to continue to be used. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings: Figure 1 It is a flowchart of the OSTree rollback method provided in the first embodiment of the present invention; Figure 2 It is a flowchart of the OSTree rollback method provided in the second embodiment of the present invention; Figure 3 It is a schematic diagram of the structure of the OSTree rollback device provided in the third embodiment of the present invention. DETAILED DESCRIPTION

[0011] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0012] Embodiment 1 Figure 1: is a flowchart of the OSTree rollback method provided in the first embodiment of the present invention. This embodiment is applicable to the situation where a new version is upgraded using Ostree in a Linux system, and when the new version system is abnormal, the system automatically rolls back to the original version. The method can be executed by an OSTree rollback device, and specifically includes the following steps: Step 110, when the new version is started for the first time after being correctly configured, the new version system is started according to the boot menu item identifier, and a preset watchdog is used to trigger a restart when the new version system starts for more than a timing parameter.

[0013] In this embodiment, the server stores the OSTree remote warehouse, the Linux embedded operating system runs the original version system normally, and can pull the OSTree file of the new version system from the server, and configure it after the pull is completed. Taking the new version system as VersionC as an example, the following method is used to achieve pull and configuration: ostreepullVersionC ostreedeployversionC.

[0014] After correct configuration, the startup item of the new version system can be generated, and the startup menu item identifier added in the boot loader can be used to determine whether to start the original version system or the new version system according to the startup menu item identifier. Using the startup menu item identifier, it is recognized that the new version system needs to be started, and the new version system is started.

[0015] Accordingly, a watchdog program can be set in the kernel, and the watchdog program can trigger a restart of the system when the system starts up and times out. Accordingly, the method further includes: adding a system service in the system, which is used to start in the early startup phase, is responsible for feeding the watchdog regularly, and monitors the status of systemd and other startup services. When the system can start normally, the watchdog is fed regularly to avoid restarting.

[0016] Step 120, using a preset counting variable to count the number of restarts, when the number exceeds a preset restart threshold, the new version startup menu item flag is set to false, the original version system startup menu item flag is set to true, and the rollback flag is set to true.

[0017] In this system, a counting variable can be added to the system startup program to count the number of restarts. And determine whether the counting variable exceeds the preset restart threshold, which can be set based on experience, and can be set to 5 for example. When it exceeds, the new version startup menu item identifier set in the startup program can be set to false, and the original version system startup menu item identifier can be set to true accordingly, and the newly added rollback identifier in the startup program can be set to true, so that when the system is started again, it can be determined to be in a rollback state by searching for the rollback identifier. Since the original version system can be started normally, and the rollback operation can only be performed after the system is started normally. Otherwise, the new version system is still started normally according to the new version startup menu item identifier and the rollback identifier.

[0018] Step 130, start the original version system according to the boot menu item identifier. After the original version system starts normally, query the rollback identifier. When the rollback identifier is true, use OSTree to delete the kernel, the startup temporary system file system and the content associated with the new version in the root file system from the storage, and delete the configuration file corresponding to the new version. At the same time, modify the priority content in the configuration file name corresponding to the original version system to form the boot menu of the original version system.

[0019] Each time the system is started, first determine that the current version of the system is the original version based on the boot menu item identifier in the system startup program, and then start the original version of the system normally. After the original version of the system is started normally, query the rollback identifier. When the rollback identifier is true, use OSTree to delete the content associated with the new version in the kernel, the boot temporary system file system, and the root file system from the memory. Exemplarily, the OSTree command can be used to delete the content associated with the new version in the kernel, the temporary root file system initramfs, and the root file system rootfs from the memory. And delete the startup configuration file entries / ostree-1-*.conf corresponding to the new version of the system. The modification of the priority content in the name of the configuration file corresponding to the new version can include: naming the configuration file entries / ostree-2-*.conf corresponding to the original version of the system as entries / ostree-1-*.conf, and resetting the startup menu item according to the configuration file so that only the startup menu of the original version of the system will exist in the startup menu item.

[0020] The above method can ensure the rollback is successful and eliminate the impact of the problematic new version system on the startup system. The startup menu is modified so that the original version system can be started normally each time it is started later, ensuring that the system can automatically complete the rollback of the problematic version system and ensure the normal operation of the system.

[0021] This embodiment starts the new version system according to the boot menu item identifier when the new version is correctly configured and starts for the first time, and triggers a restart by using a preset watchdog when the new version system starts for more than a timing parameter; uses a preset counting variable to count the number of restarts, and when it exceeds a preset restart threshold, sets the new version boot menu item identifier to false, sets the original version system boot menu item identifier to true, and sets the rollback identifier to true; starts the original version system according to the boot menu item identifier, and after the original version system starts normally, queries the rollback identifier, and when the rollback identifier is true, uses OSTree to delete the contents associated with the new version in the kernel, the startup temporary system file system, and the root file system from the memory, and deletes the configuration file corresponding to the new version, and at the same time modifies the priority content in the configuration file name corresponding to the original version system, so as to form a boot menu of the original version system. The boot menu item of the new version system is formed by the configuration information of the new version system, and the new version system can be automatically started, and the watchdog compiled by the kernel is used to monitor the startup of the new version, and when the new version system cannot start normally, OSTree is used to eliminate the influence of the new version system. And modify the system startup menu again, and use the original version system as the new system startup item, so that when problems occur in the new version system, the original version system can be used to continue to be used.

[0022] In a preferred implementation of this embodiment, before the first startup after the new version is correctly configured, the method can also add the following steps: after the new version system is pulled and configured, parse the startup configuration file generated when ostree deploys the new version, and read the new version startup attribute element; use the template of the startup menu item to fill the startup attribute element as a parameter to generate a new version startup menu item; set the new version startup menu item identifier to true. Exemplarily, the startup configuration file entries / ostree-1-*.conf generated when ostree deploys the new version system can be parsed, and the new version of the startup menu name, kernel path, kernel command line parameters, initial RAM file system path, rootfs path and other elements included therein can be read according to the template of the startup menu item, and the elements read in the previous step are used as parameters to generate a standard startup menu item. That is, the startup menu entry of the new version system. The above method can automatically generate a startup menu item, use the startup menu item to realize the normal startup of the new version system, and facilitate later adjustment to start the original version system.

[0023] In another preferred implementation of this embodiment, the method may further add the following steps: enabling the soft lock and hard lock exception detection functions during kernel compilation, and adding hardware watchdog timing parameters to the kernel startup parameters; using initramfs to start the software watchdog, using the initramfs script to add instructions and parameters to enable the initramfs watchdog, and correspondingly adding instructions to stop the initramfs watchdog. Exemplarily, multiple types of watchdogs can be enabled in the system, including kernel, initramfs, and service watchdogs. Optionally, start the kernel watchdog, enable the softlockup and hardlockup functions when compiling the kernel, and add "watchdog_thresh=20" in the kernel startup parameters. If the kernel does not respond for more than 20 seconds, it will automatically trigger a system restart. Start the initramfs software watchdog, add 30 to / dev / watchdog at the beginning of the initramfs script to enable the initramfs watchdog, and write stop to / dev / watchdog / at the end of the script to stop the initramfs watchdog. If there is no response for more than 30 seconds during the execution of initramfs, it will automatically trigger a system restart.

[0024] Embodiment 2 Figure 2 It is a flow chart of the OSTree rollback method provided in the second embodiment of the present invention. This embodiment is optimized based on the above embodiment, and the method can also add the following steps: create an automatic rollback abstract class to encapsulate the processing logic corresponding to the OSTree rollback method, and open the external interface of the key element startup count, startup restriction and trigger condition abstract elements; read the configuration file of the system service, read the agreed boot loader type therein; set the type processing method in the automatic rollback abstract class according to the agreed boot loader type.

[0025] See also Figure 2 , the OSTree rollback method comprises: Step 210, create an automatic rollback abstract class to encapsulate the processing logic corresponding to the OSTree rollback method, and open external interfaces of key element start count, start limit and trigger condition abstract elements.

[0026] Because the boot loaders of the devices are different, such as grub, uboot, pmon, and openSBI, and they pass information to the system service in different ways, the OSTree rollback method provided in the above embodiment may not be applicable to devices with different architectures. Therefore, in this embodiment, this is optimized.

[0027] Exemplarily, an automatic rollback abstract class can be created, which can be instantiated to implement the OSTree rollback method. The above processing logic is encapsulated through this class. At the same time, in order to facilitate users to flexibly customize the rollback conditions, corresponding interfaces are reserved to facilitate users to input some key elements. For example, abstract elements such as boot count, boot limit and trigger conditions. That is, the number of restarts of the new version of the system, the timing parameters of the watchdog and the trigger conditions for restart, etc. Utilizing the design structure, the key factors affecting the automatic rollback, such as the boot count and boot limit, are abstracted to form an abstract class bootloader_state, and different boot loaders implement bootloader_state_uboot_ext by defining their own specific classes. This specific class describes the methods of different boot loader characteristics to solve the device independence problem. Define the abstract class bootloader_state, which contains the following key elements: Boot counter (bootcounter): records the number of times the system boots.

[0028] Boot limit: Set the maximum number of failed boots allowed.

[0029] Rollback trigger condition (rollbacktrigger): When the number of startup times exceeds the startup limit, a rollback operation is triggered.

[0030] Step 220, read the configuration file of the system service, read the agreed boot loader type therein; and set the type processing method in the automatic rollback abstract class according to the agreed boot loader type.

[0031] When starting the system service, read the configuration file of the system service, which stipulates the boot loader type, and create the corresponding bootloader_state_uboot_ext method according to this, and get the corresponding value from / boot / uboot.cnt.

[0032] Step 230: Instantiate an object corresponding to the type using the type processing method.

[0033] The content returned by the type processing method can be used to determine the boot loader used by the current system. The corresponding class is instantiated to process objects related to the boot loader. Exemplarily, it can include: initializing the boot pointer to a null value, the boot pointer is used to point to the state object of the agreed boot loader; determining the type of the object according to the direction of the boot pointer. Utilize the type of object in memory pointed to by the pointer. The code first initializes a pointer named bootloader (of type bootloader_state*) to NULL. The function of this pointer is to point to the created boot loader state object in the future. Then, based on the different values ​​of the bootloader_type string variable, it is decided which boot loader state class instance to create. For example: based on the characteristics of different boot loaders, define specific classes to implement the functions of the abstract class bootloader_state. For example: bootloader_state_grub: For the GRUB boot loader, reads and writes boot counters via the grubenv configuration file.

[0034] bootloader_state_uboot: Reads and writes boot counters for the U-Boot bootloader via environment variables or configuration files.

[0035] bootloader_state_pmon: For the PMON bootloader, reads and writes boot counters from the specified file.

[0036] bootloader_state_opensbi: Reads and writes boot counters via NVMe or other storage media for the OpenSBI bootloader.

[0037] Step 240, when the new version is started for the first time after being correctly configured, the new version system is started according to the boot menu item identifier, and a preset watchdog is used to trigger a restart when the new version system startup exceeds a timing parameter.

[0038] Step 250, using a preset counting variable to count the number of restarts, when the preset restart threshold is exceeded, the new version startup menu item flag is set to false, the original version system startup menu item flag is set to true, and the rollback flag is set to true.

[0039] Step 260, start the original version system according to the boot menu item identifier. After the original version system starts normally, query the rollback identifier. When the rollback identifier is true, use OSTree to delete the kernel, the startup temporary system file system and the content associated with the new version in the root file system from the memory, and delete the configuration file corresponding to the new version. At the same time, modify the priority content in the configuration file name corresponding to the original version system to form the boot menu of the original version system.

[0040] This embodiment adds the following steps: creating an automatic rollback abstract class to encapsulate the processing logic corresponding to the OSTree rollback method, and opening the external interface of the key element startup count, startup limit and trigger condition abstract elements; reading the configuration file of the system service, reading the agreed boot loader type therein; setting the type processing method in the automatic rollback abstract class according to the agreed boot loader type; and using the type processing method to instantiate the object corresponding to the type. Using the type processing method to instantiate the object corresponding to the type. The OSTree rollback method can be implemented for different platforms to achieve cross-platform universality.

[0041] Embodiment 3 Figure 3 is a schematic diagram of the structure of the OSTree rollback device provided in the third embodiment of the present invention, see Figure 3 , the OSTree rollback device comprises: The identification module 310 is used to start the new version system according to the boot menu item identifier when the new version is started for the first time after being correctly configured, and to trigger a restart when the new version system starts for more than a timing parameter by using a preset watchdog; A setting module 320 is used to count the number of restarts using a preset counting variable, and when the number exceeds a preset restart threshold, set the new version startup menu item flag to false, set the original version system startup menu item flag to true, and set the rollback flag to true; The deletion module 330 is used to start the original version system according to the boot menu item identifier. After the original version system is normally started, the rollback identifier is queried. When the rollback identifier is true, OSTree is used to delete the kernel, the startup temporary system file system and the content associated with the new version in the root file system from the storage, and the configuration file corresponding to the new version is deleted. At the same time, the priority content in the configuration file name corresponding to the original version system is modified to form the boot menu of the original version system.

[0042] The OSTree rollback device provided in this embodiment starts the new version system according to the boot menu item identifier when the new version is correctly configured and starts for the first time, triggers a restart when the new version system starts for more than the timing parameter by using a preset watchdog; counts the number of restarts by using a preset counting variable, and sets the new version boot menu item identifier to false when the preset restart threshold is exceeded, sets the original version system boot menu item identifier to true, and sets the rollback identifier to true; starts the original version system according to the boot menu item identifier, queries the rollback identifier after the original version system starts normally, and uses OSTree to delete the contents associated with the new version in the kernel, the boot temporary system file system, and the root file system from the memory when the rollback identifier is true, deletes the configuration file corresponding to the new version, and modifies the priority content in the configuration file name corresponding to the original version system to form the boot menu of the original version system. The boot menu item of the new version system is formed by the configuration information of the new version system, and the new version system can be automatically started, and the watchdog compiled by the kernel is used to monitor the startup of the new version. When the new version system cannot start normally, OSTree is used to eliminate the influence of the new version system. And modify the system startup menu again, and use the original version system as the new system startup item, so that when problems occur in the new version system, the original version system can be used to continue to be used.

[0043] Based on the above embodiments, the device further includes: The parsing module is used to parse the startup configuration file generated when ostree deploys the new version after the new version system is configured, and read the new version startup attribute elements; A filling module is used to use the template of the startup menu item to fill the startup attribute elements as parameters to generate a new version of the startup menu item; The setting module is used to set the new version startup menu item flag to true.

[0044] Based on the above embodiments, the device further includes: Added a module to enable soft and hard lockup exception detection during kernel compilation, and added hardware watchdog timing parameters to the kernel startup parameters; The startup module is used to start the software watchdog using initramfs, use the initramfs script to add instructions and parameters to enable the initramfs watchdog, and correspondingly add instructions to stop the initramfs watchdog.

[0045] Based on the above embodiments, the judgment module further includes: The service item addition module is used to add settings in the system service, which is used to start in the early startup phase. It is responsible for regular dog feeding and monitoring the status of systemd and other startup services.

[0046] Based on the above embodiments, the deletion module includes: The naming unit is used to name the configuration file entries / ostree-2-*.conf corresponding to the original version system as entries / ostree-1-*.conf, and reset the startup menu item according to the configuration file so that only the startup menu of the original version system will exist in the startup menu item.

[0047] Based on the above embodiments, the device further includes: The class creation module is used to create an automatic rollback abstract class, which is used to encapsulate the processing logic corresponding to the OSTree rollback method and open the external interfaces of the key elements of start count, start limit and trigger condition abstract elements; A reading module is used to read the configuration file of the system service and read the agreed boot loader type therein; A method setting module, used for guiding the loader type to set the type processing method in the automatic rollback abstract class according to the convention; The instantiation module is used to instantiate an object corresponding to the type using the type processing method.

[0048] Based on the above embodiments, the instantiation module includes: an initialization unit, used for initializing a boot pointer to a null value, wherein the boot pointer is used for pointing to a state object of a predetermined boot loader; The pointing unit is used to determine the type of the object according to the pointing of the guide pointer.

[0049] Based on the above embodiments, the instantiation module further includes: A first reading and writing unit, for reading and writing a boot counter for a GRUB boot loader via a grubenv configuration file; A second reading and writing unit is used for reading and writing a boot counter through an environment variable or a configuration file for a U-Boot boot loader; A third reading and writing unit is used for reading and writing a startup counter through a specified file for the PMON boot loader; The fourth read and write unit is used to read and write the boot counter for the OpenSBI boot loader through NVMe or other storage media.

[0050] The OSTree rollback device provided in the embodiment of the present invention can execute the OSTree rollback method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0051] Embodiment 4 Embodiment 4 of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions, when executed by a computer processor, are used to execute the OSTree rollback method as described in any one of the above embodiments.

[0052] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.

[0053] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0054] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0055] Computer program code for performing the operation of the present invention may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or device. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0056] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may also include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. An OSTree rollback method, characterized in that: include: When the new version is started for the first time after being correctly configured, the new version system is started according to the boot menu item identifier, and the preset watchdog is used to trigger a restart when the new version system startup exceeds the timing parameter; Counting the number of restarts using a preset counting variable, when the number exceeds a preset restart threshold, setting the new version startup menu item flag to false, setting the original version system startup menu item flag to true, and setting the rollback flag to true; The original version system is started according to the boot menu item identifier. After the original version system is started normally, the rollback identifier is queried. When the rollback identifier is true, OSTree is used to delete the kernel, the startup temporary system file system and the content associated with the new version in the root file system from the storage, and the configuration file corresponding to the new version is deleted. At the same time, the priority content in the configuration file name corresponding to the original version system is modified to form the boot menu of the original version system.

2. The method according to claim 1, characterized in that Before starting the new version for the first time after it is correctly configured, the method further includes: After the new version system is configured, parse the startup configuration file generated when ostree deploys the new version and read the new version startup attribute elements; Using the template of the startup menu item, fill the startup attribute elements as parameters to generate a new version of the startup menu item; The new version startup menu item flag is set to true.

3. The method according to claim 1, characterized in that The method further comprises: Enable soft lockup and hard lockup exception detection functions when compiling the kernel, and add hardware watchdog timing parameters to the kernel startup parameters; Use initramfs to start the software watchdog, use the initramfs script to add instructions and parameters to enable the initramfs watchdog, and correspondingly add instructions to stop the initramfs watchdog.

4. The method according to claim 3, characterized in that The method further comprises: Add settings to the system service in the system to start in the early startup phase, responsible for regular dog feeding, monitoring the status of systemd and other startup services.

5. The method according to claim 1, characterized in that The modification of the priority content in the configuration file name corresponding to the new version includes: The configuration file entries / ostree-2-*.conf corresponding to the original version system is renamed as entries / ostree-1-*.conf, and the startup menu item is reset according to the configuration file so that only the startup menu of the original version system will exist in the startup menu item.

6. The method according to claim 1, characterized in that The method further comprises: Create an automatic rollback abstract class to encapsulate the processing logic corresponding to the OSTree rollback method, and open external interfaces for the key elements of start count, start limit, and trigger condition abstract elements; Read the configuration file of the system service and read the agreed boot loader type; According to the convention, the bootloader type sets the type processing method in the automatic rollback abstract class; The object corresponding to the type is instantiated using the type processing method.

7. The method according to claim 6, characterized in that The instantiation of an object corresponding to a type by using the type processing method includes: Initialize a boot pointer to a null value, wherein the boot pointer is used to point to a state object of a predetermined boot loader; The type of the object is determined according to the direction of the guide pointer.

8. The method according to claim 7, characterized in that The type processing method in the automatic rollback abstract class of the boot loader type setting according to the convention includes: For the GRUB boot loader, read and write boot counters through the grubenv configuration file; For the U-Boot boot loader, read and write the boot counter via environment variables or configuration files; For the PMON boot loader, read and write the boot counter through the specified file; Read and write boot counters via NVMe or other storage media for OpenSBI bootloader.

9. An OSTree rollback device, characterized in that: include: The identification module is used to start the new version system according to the boot menu item identification when the new version is started for the first time after being correctly configured, and to trigger a restart when the new version system starts for more than a timing parameter by using a preset watchdog; A setting module, used for counting the number of restarts using a preset counting variable, and when the number exceeds a preset restart threshold, setting the new version startup menu item flag to false, setting the original version system startup menu item flag to true, and setting the rollback flag to true; The deletion module is used to start the original version system according to the boot menu item identifier. After the original version system is started normally, the rollback identifier is queried. When the rollback identifier is true, OSTree is used to delete the kernel, the startup temporary system file system and the content associated with the new version in the root file system from the storage, and the configuration file corresponding to the new version is deleted. At the same time, the priority content in the configuration file name corresponding to the original version system is modified to form the boot menu of the original version system.

10. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to perform the OSTree rollback method as described in any one of claims 1-8 when executed by a computer processor.

Citation Information

Patent Citations

  • System upgrading method and device in Internet of Things equipment, equipment and storage medium

    CN112527322A

  • Linux kernel automatic rollback recovery method based on embedded system

    CN115794237A

  • Method and device for Loongson PMON platform to support OSTree-based system, and storage medium

    CN117591170A

  • Cross-release version replacement system of Linux operating system

    CN118170401A

  • Cloud native operating system mirror image construction method and system supporting U-Boot

    CN118567667A

Cited By

  • System upgrading method based on OSTree

    CN120743310A

  • OSTree-based system upgrade method

    CN120743310B