Linux dual-system starting and upgrading method and device, equipment and medium
By verifying the main file system partition when the terminal device is started, and using the backup kernel and partition number to start the backup system when it fails, the problem of extended startup time and data corruption caused by data reading and writing during dual system upgrades in the existing technology is solved. , improves efficiency and success rate.
Patent Information
- Application Number
- CN202411349747.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-01-07
AI Technical Summary
When the existing dual-system boot solution is damaged during the upgrade process, it requires frequent reading and writing flash data, which leads to an extended startup time and increases the risk of data corruption, especially when the system is powered off, which may lead to data loss or corruption.
By verifying the main file system partition when the terminal device starts, if it fails, obtain the backup partition number of the backup file system partition, read the backup kernel and modify the kernel startup parameters to directly start the backup system, avoiding the connection between different partitions Read and write data, and use the backup system to upgrade files.
It improves the startup success rate of terminal devices and the efficiency of dual Linux system upgrades, reduces startup failures caused by power outages, and avoids the risk of data corruption during data reading and writing.
Smart Images

Figure CN119271460A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a Linux dual-system startup and upgrade method, device, equipment and medium. Background Art
[0002] The existing dual-system startup solutions basically read the backup file system partition content and write it to the main file system partition when Uboot starts after the main file system partition is damaged during the upgrade process, decompress the main file system partition content and read the kernel into the memory, and then run the kernel to start the main system in the main file system partition, and re-detect and upgrade after startup.
[0003] This method requires reading and writing the flash data in the partition at the same time during Uboot startup, which prolongs the startup time. In addition, frequent read and write operations also increase the risk of flash data corruption, especially when the system is powered off, which may cause data loss or corruption. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a Linux dual-system startup and upgrade method. When the main file system partition verification fails, the backup system is directly started by modifying the partition number, and the main system file and the backup system file are upgraded, so that the terminal device is started by the upgraded main system file or the backup system file, and there is no need to read and write flash data between different partitions, thereby improving the success rate of terminal device startup and the efficiency of Linux dual-system upgrade.
[0005] In a first aspect, an embodiment of the present invention provides a Linux dual-system startup and upgrade method, which is applied to a terminal device, wherein the terminal device includes a primary file system partition and a backup file system partition, and the method includes:
[0006] During the startup of the terminal device, the main file system partition is verified;
[0007] In the case where the primary file system partition verification fails, the backup partition number of the backup file system partition is obtained, and the backup kernel of the backup system is read from the backup system file stored in the backup file system partition;
[0008] Change the partition number parameter in the kernel startup parameters to the backup partition number. The default value of the partition number parameter is the primary partition number corresponding to the primary file system partition.
[0009] Based on the backup kernel, the modified kernel startup parameters and the backup system files, the backup system is started;
[0010] The main system files and the backup system files stored in the main file system partition are upgraded respectively through the backup system, so as to start the terminal device through the upgraded main system files or the backup system files.
[0011] In a preferred embodiment of the present invention, the verification of the primary file system partition includes:
[0012] Get the verification information of the main system file in the main file system partition;
[0013] Compare the verification information with the preset verification information to determine the comparison result;
[0014] When the comparison results are the same, it is determined that the primary file system partition verification is successful;
[0015] When the comparison result is different, it is determined that the primary file system partition verification has failed.
[0016] In a preferred embodiment of the present invention, the method further comprises:
[0017] When the primary file system partition is successfully verified, the primary kernel of the primary system is read from the primary system file stored in the primary file system partition;
[0018] Based on the main kernel, kernel startup parameters and main system files, start the main system;
[0019] The main system files and the backup system files stored in the main file system partition are upgraded respectively through the main system, so as to start the terminal device through the upgraded main system files or the backup system files.
[0020] In a preferred embodiment of the present invention, the main system files and the backup system files stored in the main file system partition are upgraded respectively, including:
[0021] Get the current size and initial size of the backup file system partition;
[0022] Determine the upgrade order based on the comparison result between the current size value and the initial size value;
[0023] According to the upgrade sequence, the main system files and backup system files stored in the main file system partition are upgraded respectively.
[0024] In a preferred embodiment of the present invention, the starting address of the backup file system partition is before the starting address of the primary file system partition. The above-mentioned determination of the upgrade order based on the comparison result of the current size value and the initial size value includes:
[0025] When the comparison result shows that the current size value is less than or equal to the initial size value, the upgrade sequence is determined as first upgrading the backup system files and then upgrading the main system files;
[0026] When the comparison result shows that the current size value is greater than the initial size value, the upgrade sequence is determined as first upgrading the main system files and then upgrading the backup system files.
[0027] In a preferred embodiment of the present invention, the step of reading the backup kernel of the backup system from the backup system file stored in the backup file system partition includes:
[0028] Decompressing the backup system files stored in the backup file system partition to obtain the decompressed backup system files;
[0029] Read the backup kernel of the backup system from the decompressed backup system file.
[0030] In a preferred embodiment of the present invention, the main kernel of the main system is read from the main system file stored in the main file system partition, including:
[0031] Decompressing the main system files stored in the main file system partition to obtain the decompressed main system files;
[0032] Read the main kernel of the main system from the decompressed main system file.
[0033] In a second aspect, an embodiment of the present invention further provides a Linux dual-system startup and upgrade device, which is applied to a terminal device, wherein the terminal device includes a primary file system partition and a backup file system partition, and the device includes:
[0034] The verification module is used to verify the main file system partition during the startup of the terminal device;
[0035] The first reading module is used to obtain the backup partition number of the backup file system partition when the primary file system partition verification fails, and read the backup kernel of the backup system from the backup system file stored in the backup file system partition;
[0036] A partition number modification module is used to modify the partition number parameter in the kernel startup parameter to the backup partition number; wherein the default value of the partition number parameter is the primary partition number corresponding to the primary file system partition;
[0037] A first startup module, used for starting the backup system based on the backup kernel, the modified kernel startup parameters and the backup system files;
[0038] The first upgrade module is used to upgrade the main system files and the backup system files stored in the main file system partition respectively through the backup system, so as to start the terminal device through the upgraded main system files or the backup system files.
[0039] In a third aspect, an embodiment of the present invention further provides an electronic device, including a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the Linux dual-system startup and upgrade method of the first aspect above.
[0040] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the Linux dual-system startup and upgrade method of the first aspect above.
[0041] The embodiments of the present invention bring the following beneficial effects:
[0042] The embodiment of the present invention provides a Linux dual-system startup and upgrade method. During the startup of a terminal device, the main file system partition is verified. When the verification of the main file system partition fails, the backup partition number of the backup file system partition is obtained, and the backup kernel of the backup system is read from the backup system file stored in the backup file system partition. By modifying the partition number parameter in the kernel startup parameter to the backup partition number, the backup kernel can directly start the backup system according to the kernel startup parameter and the backup system file, and the backup system is used to upgrade the main system file and the backup system file, without the need to read and write data between different partitions, thereby improving the efficiency of the Linux dual-system upgrade, avoiding the startup failure caused by power failure during the data reading and writing process between different partitions, and improving the success rate of the terminal device startup.
[0043] Other features and advantages of the present invention will be set forth in the following description, or some features and advantages may be inferred or unambiguously determined from the description, or may be learned by implementing the above-mentioned technology of the present invention.
[0044] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0046] Figure 1 A flowchart of a Linux dual-system startup and upgrade method provided by an embodiment of the present invention;
[0047] Figure 2 A flowchart of another Linux dual-system startup and upgrade method provided by an embodiment of the present invention;
[0048] Figure 3 A flowchart of another Linux dual-system startup and upgrade method provided by an embodiment of the present invention;
[0049] Figure 4 A schematic diagram of the structure of a Linux dual-system startup and upgrade device provided by an embodiment of the present invention;
[0050] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] The existing dual-system startup solutions basically read the backup file system partition content and write it to the main file system partition when Uboot starts after the main file system partition is damaged during the upgrade process, decompress the main file system partition content and read the kernel into the memory, and then run the kernel to start the main system in the main file system partition, and re-detect and upgrade after startup.
[0053] This approach requires reading the flash data in a partition and then writing the read flash data to a partition when Uboot is started. This not only affects the startup time due to reading and writing multiple flash blocks, but also has the risk of power failure again when writing flash.
[0054] Based on this, an embodiment of the present invention provides a Linux dual-system startup and upgrade method. During the startup of a terminal device, the main file system partition is verified. When the verification of the main file system partition fails, the backup partition number of the backup file system partition is obtained, and the backup kernel of the backup system is read from the backup system file stored in the backup file system partition. By modifying the partition number parameter in the kernel startup parameter to the backup partition number, the backup kernel can directly start the backup system according to the kernel startup parameter and the backup system file, and the backup system is used to upgrade the main system file and the backup system file, without the need to read and write data between different partitions, thereby improving the efficiency of the Linux dual-system upgrade and the efficiency of the terminal device startup, reducing the startup failure caused by power failure during the data reading and writing process between different partitions, and improving the success rate of the terminal device startup.
[0055] To facilitate understanding of this embodiment, a Linux dual-system startup and upgrade method disclosed in an embodiment of the present invention is first introduced in detail.
[0056] Example 1
[0057] The embodiment of the present invention provides a Linux dual system startup and upgrade method, Figure 1 The present invention provides a flowchart of a Linux dual-system startup and upgrade method. Figure 1 As shown, the Linux dual-system startup and upgrade method may include the following steps:
[0058] Step S101, during the process of starting the terminal device, verify the main file system partition.
[0059] The primary file system partition refers to the memory space in the terminal device's memory used to store the primary system files. The backup file system partition refers to the memory space in the terminal device's memory used to store the backup system files. The terminal device's memory includes at least the primary file system partition and the backup file system partition.
[0060] Specifically, when the terminal device is powered on, the boot system in the memory of the terminal device, that is, Uboot, is started. The main file system partition is verified through Uboot. Specifically, the main system files stored in the main file system partition are verified through Uboot to determine whether the main system files stored in the main file system partition are damaged or tampered with. If the main file system partition verification fails, it means that the main system files stored in the main file system partition are damaged or tampered with. If the main file system partition verification succeeds, it means that the main system files stored in the main file system partition are not damaged or tampered with.
[0061] Exemplarily, the verification method can be a CRC check: the main system file usually contains a checksum (such as a CRC or MD5 hash value) to ensure that there is no data corruption in the main system file. Uboot will recalculate these checksums after startup and compare them with the values in the main system file to confirm that there is no data corruption. It can also be a log check: some file systems (such as ext4) use logs to record all modification operations. Uboot reads the log at startup, verifies its integrity, and then restores the state of the file system based on the operations in the log. It can also be a space check: check the space used by the file system to ensure that it does not exceed the maximum available space allocated to the file system to prevent data loss or system crashes.
[0062] Step S102: when the primary file system partition verification fails, the backup partition number of the backup file system partition is obtained, and the backup kernel of the backup system is read from the backup system file stored in the backup file system partition.
[0063] The backup partition number is used to describe the location of the backup file system partition in the memory of the terminal device, and is a unique number used to identify the backup file system partition. The backup kernel is used to start and run the backup system. Specifically, the backup partition number can be determined by the mtdparts parameter in the Uboot parameter. Among them, the mtdparts parameter is used to specify the name and size of each partition in the memory of the terminal device. The partition number corresponding to each partition can be determined according to the arrangement order of each partition in the mtdparts parameter, and the arrangement order can start from 0. Exemplarily, the format of the mtdparts parameter can be expressed as follows: mtdparts = sfc: 256K (boot), 64K (env_back), 64K (syscfg), 64K (mcrc), 4096K (minis ys), 2816K (romfs), 5824K (user), 256K (custom), 2432K (ai), 512K (mtd). Among them, 256K, 64K, 4096K, 2816K, 5824K, 256K, 2432K, and 512K refer to the size of each partition in the memory of the terminal device, and boot, env_back, syscfg, mcrc, minisys, romfs, user, custom, ai, and mtd refer to the names of each partition in the memory of the terminal device. In this embodiment, the name of the backup file system partition is minisys, and its arrangement order in the mtdparts parameter is the fifth, so its corresponding partition number is mtdblock4, and the name of the main file system partition is romfs, and its arrangement order in the mtdparts parameter is the sixth, and its corresponding partition number is mtdblock5.
[0064] Specifically, when the primary file system partition verification fails, the backup file system partition arrangement order is determined by querying the mtdparts parameter in Uboot, and the backup partition number of the backup file system partition is obtained. According to the backup partition number, the location of the backup file system partition in the memory is located, and the backup kernel of the backup system is read from the backup system file stored in the backup file system partition into the memory of the terminal device.
[0065] Step S103, modify the partition number parameter in the kernel startup parameter to the backup partition number.
[0066] The default value of the partition number parameter is the primary partition number corresponding to the primary file system partition. The primary partition number is used to describe the location of the primary file system partition in the memory of the terminal device. The kernel startup parameter is a parameter stored in Uboot. The kernel startup parameter includes at least the partition number parameter, which is used to guide the kernel to start the system files stored in the partition corresponding to the partition number.
[0067] Exemplarily, the kernel boot parameter may be a bootargs parameter, wherein the parameter format and content for setting the partition number are as follows:
[0068] root = / dev / mtdblock5, where mtdblock5 is the primary partition number. The primary file system partition number can be changed to the backup partition number through the preset command.
[0069] Step S104, starting the backup system based on the backup kernel, the modified kernel startup parameters and the backup system files.
[0070] Specifically, Uboot runs the backup kernel, passes the modified kernel startup parameters in Uboot to the backup kernel, and the backup kernel runs the backup system files stored in the backup file system partition according to the kernel startup parameters passed by Uboot, and starts the backup system.
[0071] Step S105, respectively upgrading the main system files and the backup system files stored in the main file system partition through the backup system, so as to start the terminal device through the upgraded main system files or the backup system files.
[0072] After the backup system is started, the upgrade function is started to upgrade the main system files stored in the main file system partition and the backup system files stored in the backup file system partition. After the upgrade is completed, Uboot re-runs the upgraded main system files to start the terminal device, or re-runs the upgraded backup system files to start the terminal device.
[0073] Specifically, a backup system is run on the terminal device, and the backup system detects the network or other hardware interfaces to determine whether there are system files that need to be upgraded. When there are system files that need to be upgraded, the system files that need to be upgraded can be received through the network or other hardware interfaces, wherein the received system files that need to be upgraded include main file system upgrade data and backup file system upgrade data. The received main file system upgrade data is stored in the main file system partition to upgrade the main system files, and the received backup file system upgrade data is stored in the backup file system partition to upgrade the backup system files. It is understandable that the memory of the terminal device may also include other application partitions, and therefore, the received system files that need to be upgraded may also include other application upgrade data, and the other application upgrade data is stored in other application partitions to upgrade the system files stored in other application partitions.
[0074] The Linux dual-system startup and upgrade method provided by the embodiment of the present invention verifies the main file system partition during the startup of the terminal device. When the verification of the main file system partition fails, the backup partition number of the backup file system partition is obtained, and the backup kernel of the backup system is read from the backup system file stored in the backup file system partition. By modifying the partition number parameter in the kernel startup parameter to the backup partition number, the backup kernel can directly start the backup system according to the kernel startup parameter and the backup system file, and the backup system is used to upgrade the main system file and the backup system file, without the need to read and write data between different partitions, thereby improving the efficiency of the Linux dual-system upgrade and the efficiency of the terminal device startup, avoiding the startup failure caused by power failure during the data reading and writing process between different partitions, and improving the success rate of the terminal device startup.
[0075] Example 2
[0076] The embodiment of the present invention also provides another Linux dual-system startup and upgrade method; this method is implemented on the basis of the method in the above embodiment; this method focuses on describing the specific implementation method of verifying the main file system partition.
[0077] Figure 2 A flowchart of another Linux dual-system startup and upgrade method provided by an embodiment of the present invention is shown in FIG. Figure 2 As shown, the Linux dual-system startup and upgrade method may include the following steps:
[0078] Step S201, during the startup of the terminal device, obtaining verification information of the main system file in the main file system partition.
[0079] The verification information is used to determine whether the main system file is damaged or tampered with. In this embodiment, the verification information can be a CRC check value of the main system file. Specifically, during the startup of the terminal device, a CRC check value can be calculated for the main system file in the main file system partition, and the calculated CRC check value is used as the verification information of the main system file.
[0080] Step S202, comparing the verification information with the preset verification information to determine the comparison result.
[0081] The preset verification information refers to the CRC verification value of the main system file pre-stored before the terminal device is started. In the memory of the terminal device, a separate memory partition, such as a verification partition, can be established to store the preset verification information to improve the security of the preset verification information.
[0082] Specifically, Uboot can read preset verification information from the verification partition and compare it with the calculated verification information. If the preset verification information is the same as the verification information, the comparison result is determined to be the same. If the preset verification information is different from the verification information, the comparison result is determined to be different.
[0083] Step S203: When the comparison result is the same, it is determined that the primary file system partition verification is successful.
[0084] When the comparison result is the same, it indicates that the main system file is not damaged or tampered with, and the main file system partition verification is successful.
[0085] Step S204: When the comparison result is different, it is determined that the primary file system partition verification fails.
[0086] If the comparison result is different, it indicates that the main system file is damaged or tampered with, and it is determined that the main file system partition verification has failed.
[0087] Step S205: when the primary file system partition verification fails, the backup partition number of the backup file system partition is obtained, and the backup kernel of the backup system is read from the backup system file stored in the backup file system partition.
[0088] Specifically, step A 1 -Step A 2 Read the backup kernel of the backup system.
[0089] Step A 1 , decompress the backup system files stored in the backup file system partition to obtain the decompressed backup system files.
[0090] Uboot can decompress the backup system file stored in the backup file system partition by running a corresponding decompression tool or decompression instruction, and the obtained decompression result is the decompressed backup system file.
[0091] Step A 2 , read the backup kernel of the backup system from the decompressed backup system file.
[0092] The decompressed backup system file may be a plurality of files, and Uboot may identify the file containing the backup kernel from the decompressed backup system file, and load the backup kernel in the file. It is understandable that the file containing the backup kernel may be identified by identifying the name or tag of the file, and illustratively, the name or tag of the file may be "kernel".
[0093] Among them, the backup system is a mini file system, which only includes upgrade and network functions. Compared with the file system with full functions, the mini file system occupies less memory space, so when decompressing the backup system files, the decompression speed is faster; these all speed up the startup speed, reduce the risks that may be caused by power outages, and reduce the storage space requirements of the dual system. At the same time, because the mini file system only supports upgrade and network modules, it starts detecting and upgrading directly after startup, which also speeds up the update and upgrade of terminal devices.
[0094] Step S206, modify the partition number parameter in the kernel startup parameter to the backup partition number.
[0095] Step S207, starting the backup system based on the backup kernel, the modified kernel startup parameters and the backup system files.
[0096] Step S208, respectively upgrading the main system files and the backup system files stored in the main file system partition through the backup system, so as to start the terminal device through the upgraded main system files or the backup system files.
[0097] Specifically, step B 1 -Step B 3 The main system files and backup system files stored in the main file system partition are upgraded respectively.
[0098] Step B 1 , get the current size value and initial size value of the backup file system partition.
[0099] The current size value refers to the size of the memory space occupied by the backup file system partition after the backup file system is upgraded. The initial size value refers to the size of the memory space occupied by the backup file system partition before the backup file system is upgraded.
[0100] Specifically, the backup system can receive system files that need to be upgraded through a network or other hardware interface, wherein the received system files that need to be upgraded include main file system upgrade data and backup file system upgrade data. The backup system parses the backup file system upgrade data, reads the current size value, and reads the initial size value from the kernel startup parameters of Uboot.
[0101] Step B 2 , determine the upgrade order based on the comparison result between the current size value and the initial size value.
[0102] The current size value is compared with the initial size value to obtain a comparison result. Specifically, if the comparison result is that the current size value is less than or equal to the initial size value, it indicates that the backup file system partition has not increased in size, and the upgrade sequence is determined to upgrade the backup system files first and then the main system files.
[0103] If the comparison result shows that the current size value is greater than the initial size value, it indicates that the backup file system partition has become larger, and the upgrade sequence is determined to upgrade the main system files first and then the backup system files.
[0104] Step B 3 , respectively upgrade the main system files and backup system files stored in the main file system partition.
[0105] The received system files that need to be upgraded are stored in the primary file system partition and the backup file system partition in turn according to the upgrade sequence, so as to upgrade the primary system and the backup system.
[0106] In this embodiment, the starting address of the backup file system partition is before the starting address of the main file system partition. If the backup file system partition becomes larger, the starting address of the main file system partition will move backward. During the process of upgrading the main system, the system files that need to be upgraded and stored in the main file system partition will not overwrite the original backup file system partition. If the upgrade of the main system is abnormal, the backup system can be started at the next startup. If the upgrade of the backup system fails, the main system has been upgraded and can be started at the next startup.
[0107] If the backup file system partition does not become larger, the situation is just the opposite. You should upgrade the backup system files first. After the backup system files are upgraded, they will not step on the main file system partition. If the backup system upgrade fails, you can start the main system next time you start it. If the main system upgrade fails, the backup system has been upgraded and you can start the backup system when you start it again.
[0108] By judging whether the size of the backup file system partition has increased, the upgrade order of the main system files and the backup system files is determined according to the judgment result, and the upgrade is performed in the upgrade order. If an abnormality occurs at any stage during the upgrade process of the main system and the backup system, one of the systems can be guaranteed to be complete and usable, thereby improving the success rate of Linux dual-system startup.
[0109] Example 3
[0110] The embodiment of the present invention also provides another Linux dual-system startup and upgrade method; the method is implemented on the basis of the method in the above embodiment; the method focuses on describing the specific implementation method of the situation where the primary file system partition verification is successful.
[0111] Figure 3 A flowchart of another Linux dual-system startup and upgrade method provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the Linux dual-system startup and upgrade method may include the following steps:
[0112] Step S301, during the startup of the terminal device, obtaining verification information of the main system file in the main file system partition.
[0113] Step S302, comparing the verification information with the preset verification information to determine the comparison result.
[0114] Step S303: When the comparison result is the same, it is determined that the primary file system partition verification is successful.
[0115] Step S304: When the comparison result is different, it is determined that the primary file system partition verification fails.
[0116] Step S305: when the primary file system partition is successfully verified, the primary kernel of the primary system is read from the primary system file stored in the primary file system partition.
[0117] The primary partition number is used to describe the location of the primary file system partition in the memory of the terminal device. It is a unique number used to identify the primary file system partition. The main kernel is used to start and run the main system. Specifically, the primary partition number can be determined by the mtdparts parameter in the Uboot parameter.
[0118] Specifically, when the primary file system partition is successfully verified, the arrangement order of the primary file system partition is determined by querying the mtdparts parameter in Uboot, and the primary partition number of the primary file system partition is obtained. According to the primary partition number, the location of the primary file system partition in the memory is located, and the main kernel of the main system is read from the main system file stored in the primary file system partition into the memory of the terminal device.
[0119] Further, step C 1 -Step C 2 Read the backup kernel of the backup system.
[0120] Step C 1 , decompress the main system files stored in the main file system partition to obtain the decompressed main system files.
[0121] Uboot can decompress the main system file stored in the main file system partition by running a corresponding decompression tool or decompression instruction, and the decompression result obtained is the decompressed main system file.
[0122] Step C 2 , read the main kernel of the main system from the decompressed main system file.
[0123] The decompressed main system file may be multiple files, and Uboot may identify the file containing the main kernel from the decompressed main system file, and load the main kernel in the file. It is understandable that the file containing the main kernel may be identified by identifying the name or tag of the file, and illustratively, the name or tag of the file may be "kernel".
[0124] Step S306, starting the main system based on the main kernel, kernel startup parameters and main system files.
[0125] Specifically, Uboot runs the main kernel, passes the kernel startup parameters in Uboot to the main kernel, and the main kernel runs the main system files stored in the main file system partition according to the kernel startup parameters passed by Uboot, and starts the main system.
[0126] Step S307, the main system files and the backup system files stored in the main file system partition are upgraded respectively through the main system, so as to start the terminal device through the upgraded main system files or the backup system files.
[0127] After the main system is started, the upgrade function is started to upgrade the main system files stored in the main file system partition and the backup system files stored in the backup file system partition. After the upgrade is completed, Uboot re-runs the upgraded main system files to start the terminal device, or re-runs the upgraded backup system files to start the terminal device.
[0128] Specifically, the main system is run on the terminal device, and the main system detects the network or other hardware interfaces to determine whether there are system files that need to be upgraded. When there are system files that need to be upgraded, the main system can receive the system files that need to be upgraded through the network or other hardware interfaces, wherein the received system files that need to be upgraded include main file system upgrade data and backup file system upgrade data, and the received main file system upgrade data is stored in the main file system partition to upgrade the main system files, and the received backup file system upgrade data is stored in the backup file system partition to upgrade the backup system files. It can be understood that the memory of the terminal device can also include other application partitions, so the received system files that need to be upgraded can also include other application upgrade data, and the other application upgrade data is stored in other application partitions to upgrade the system files stored in other application partitions.
[0129] Further, the main system files and backup system files stored in the main file system partition are upgraded respectively, including: obtaining the current size value and the initial size value of the backup file system partition; determining the upgrade order according to the comparison result of the current size value and the initial size value; and upgrading the main system files and backup system files stored in the main file system partition according to the upgrade order. Wherein, when the comparison result is that the current size value is less than or equal to the initial size value, the upgrade order is determined to upgrade the backup system files first and then upgrade the main system files; when the comparison result is that the current size value is greater than the initial size value, the upgrade order is determined to upgrade the main system files first and then upgrade the backup system files.
[0130] The Linux dual-system startup and upgrade method provided by the embodiment of the present invention directly reads the main kernel of the main system to start the main system when the main file system partition verification is successful, and uses the main system to upgrade the main system files and the backup system files according to the upgrade sequence. When an abnormality occurs at any stage during the upgrade process of the main system and the backup system, it can ensure that one of the systems is complete and usable, thereby improving the success rate of the Linux dual-system startup.
[0131] Example 4
[0132] Corresponding to the above method embodiment, the embodiment of the present invention provides a Linux dual-system startup and upgrade device, Figure 4 A schematic diagram of the structure of a Linux dual-system startup and upgrade device provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, the Linux dual-system startup and upgrade device may include:
[0133] Verification module 401, used to verify the main file system partition during the startup of the terminal device;
[0134] The first reading module 402 is used to obtain the backup partition number of the backup file system partition when the primary file system partition verification fails, and read the backup kernel of the backup system from the backup system file stored in the backup file system partition;
[0135] The partition number modification module 403 is used to modify the partition number parameter in the kernel startup parameter to the backup partition number; wherein the default value of the partition number parameter is the primary partition number corresponding to the primary file system partition;
[0136] A first startup module 404, used to start the backup system based on the backup kernel, the modified kernel startup parameters and the backup system files;
[0137] The first upgrade module 405 is used to upgrade the main system files and the backup system files stored in the main file system partition respectively through the backup system, so as to start the terminal device through the upgraded main system files or the backup system files.
[0138] The Linux dual-system startup and upgrade device provided by the embodiment of the present invention verifies the main file system partition during the startup of the terminal device. When the verification of the main file system partition fails, the backup partition number of the backup file system partition is obtained, and the backup kernel of the backup system is read from the backup system file stored in the backup file system partition. By modifying the partition number parameter in the kernel startup parameter to the backup partition number, the backup kernel can directly start the backup system according to the kernel startup parameter and the backup system file, and use the backup system to upgrade the main system file and the backup system file, without the need to read and write data between different partitions, thereby improving the efficiency of the Linux dual-system upgrade and the efficiency of the terminal device startup, avoiding the startup failure caused by power failure during the data reading and writing process between different partitions, and improving the success rate of the terminal device startup.
[0139] In some embodiments, the verification module 401 includes:
[0140] A verification information acquisition unit, used to acquire verification information of a main system file in a main file system partition;
[0141] A comparison unit, used to compare the verification information with the preset verification information and determine a comparison result;
[0142] A first result unit, used to determine that the primary file system partition verification is successful when the comparison results are the same;
[0143] The second result unit is used to determine that the primary file system partition verification fails when the comparison result is different.
[0144] In some embodiments, the apparatus further comprises:
[0145] The second reading module is used to read the main kernel of the main system from the main system file stored in the main file system partition when the main file system partition is successfully verified;
[0146] A second startup module is used to start the main system based on the main kernel, kernel startup parameters and main system files;
[0147] The second upgrade module is used to upgrade the main system files and backup system files stored in the main file system partition respectively through the main system, so as to start the terminal device through the upgraded main system files or backup system files.
[0148] In some embodiments, the first upgrade module or the second upgrade module further includes:
[0149] A size value obtaining unit, used to obtain the current size value and the initial size value of the backup file system partition;
[0150] An upgrade sequence determination unit, used to determine the upgrade sequence according to a comparison result between the current size value and the initial size value;
[0151] The upgrade unit is used to upgrade the main system files and the backup system files stored in the main file system partition respectively according to the upgrade sequence.
[0152] In some embodiments, the starting address of the backup file system partition is before the starting address of the primary file system partition, and the upgrade order determination unit is specifically configured to:
[0153] When the comparison result shows that the current size value is less than or equal to the initial size value, the upgrade sequence is determined as first upgrading the backup system files and then upgrading the main system files;
[0154] When the comparison result shows that the current size value is greater than the initial size value, the upgrade sequence is determined as first upgrading the main system files and then upgrading the backup system files.
[0155] In some embodiments, the first reading module is specifically configured to:
[0156] Decompressing the backup system files stored in the backup file system partition to obtain the decompressed backup system files;
[0157] Read the backup kernel of the backup system from the decompressed backup system file.
[0158] In some embodiments, the second reading module is specifically configured to:
[0159] Decompressing the main system files stored in the main file system partition to obtain the decompressed main system files;
[0160] Read the main kernel of the main system from the decompressed main system file.
[0161] The device provided in the embodiment of the present invention has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0162] Example 5
[0163] The embodiment of the present invention also provides an electronic device for running the above Linux dual system startup and upgrade method; see Figure 5 A structural schematic diagram of an electronic device is shown, the electronic device includes a memory 500 and a processor 501, wherein the memory 500 is used to store one or more computer instructions, and the one or more computer instructions are executed by the processor 501 to implement the above-mentioned Linux dual-system startup and upgrade method.
[0164] Further, Figure 5 The electronic device shown further includes a bus 502 and a communication interface 503 , and the processor 501 , the communication interface 503 and the memory 500 are connected via the bus 502 .
[0165] The memory 500 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 503 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 502 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0166] The processor 501 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 501. The above processor 501 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 500, and the processor 501 reads the information in the memory 500 and completes the steps of the method of the above embodiment in combination with its hardware.
[0167] An embodiment of the present invention further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above-mentioned Linux dual-system startup and upgrade method. The specific implementation can be found in the method embodiment, which will not be repeated here.
[0168] The computer program product for the Linux dual-system startup and upgrade method provided in the embodiment of the present invention includes a computer-readable storage medium storing a non-volatile program code executable by a processor. The instructions included in the program code can be used to execute the method described in the previous method embodiment. The specific implementation can be referred to the method embodiment, which will not be repeated here.
[0169] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0170] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0171] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0172] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0173] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0174] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-mentioned embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A Linux dual system startup and upgrade method, characterized in that: Applied to a terminal device, the terminal device includes a primary file system partition and a backup file system partition, the method includes: During the startup of the terminal device, verifying the main file system partition; In the case where the primary file system partition verification fails, obtaining the backup partition number of the backup file system partition, and reading the backup kernel of the backup system from the backup system file stored in the backup file system partition; Modify the partition number parameter in the kernel startup parameter to the backup partition number; wherein the default value of the partition number parameter is the primary partition number corresponding to the primary file system partition; Starting the backup system based on the backup kernel, the modified kernel startup parameters and the backup system file; The main system file and the backup system file stored in the main file system partition are upgraded respectively through the backup system, so as to start the terminal device through the upgraded main system file or the backup system file.
2. The method according to claim 1, characterized in that The verifying the primary file system partition includes: Get the verification information of the main system file in the main file system partition; Comparing the verification information with preset verification information to determine a comparison result; When the comparison results are the same, determining that the primary file system partition verification is successful; When the comparison result is different, it is determined that the primary file system partition verification fails.
3. The method according to claim 2, characterized in that Also includes: If the primary file system partition is successfully verified, reading a primary kernel of the primary system from a primary system file stored in the primary file system partition; Based on the main kernel, the kernel startup parameters and the main system file, start the main system; The main system file and the backup system file stored in the main file system partition are upgraded respectively through the main system, so as to start the terminal device through the upgraded main system file or the backup system file.
4. The method according to claim 1 or 3, characterized in that: The main system files and the backup system files stored in the main file system partition are respectively upgraded, including: Obtaining a current size value and an initial size value of the backup file system partition; Determine an upgrade order according to a comparison result of the current size value and the initial size value; According to the upgrade sequence, the main system files and the backup system files stored in the main file system partition are upgraded respectively.
5. The method according to claim 4, characterized in that The starting address of the backup file system partition is before the starting address of the primary file system partition, and the determining the upgrade order according to the comparison result of the current size value and the initial size value includes: When the comparison result is that the current size value is less than or equal to the initial size value, the upgrade sequence is determined as first upgrading the backup system files and then upgrading the main system files; When the comparison result is that the current size value is greater than the initial size value, the upgrade sequence is determined as upgrading the main system files first and then upgrading the backup system files.
6. The method according to claim 1, characterized in that The step of reading a backup kernel of a backup system from a backup system file stored in the backup file system partition comprises: Decompressing the backup system files stored in the backup file system partition to obtain the decompressed backup system files; The backup kernel of the backup system is read from the decompressed backup system file.
7. The method according to claim 3, characterized in that The step of reading the main kernel of the main system from the main system file stored in the main file system partition comprises: Decompressing the main system files stored in the main file system partition to obtain the decompressed main system files; The main kernel of the main system is read from the decompressed main system file.
8. A Linux dual-system startup and upgrade device, characterized in that: Applied to a terminal device, the terminal device includes a primary file system partition and a backup file system partition, and the device includes: A verification module, used for verifying the main file system partition during the startup of the terminal device; A first reading module is used to obtain the backup partition number of the backup file system partition and read the backup kernel of the backup system from the backup system file stored in the backup file system partition when the primary file system partition verification fails; A partition number modification module, used to modify the partition number parameter in the kernel startup parameter to the backup partition number; wherein the default value of the partition number parameter is the primary partition number corresponding to the primary file system partition; A first startup module, used for starting the backup system based on the backup kernel, the modified kernel startup parameters and the backup system file; The first upgrade module is used to upgrade the main system file and the backup system file stored in the main file system partition respectively through the backup system, so as to start the terminal device through the upgraded main system file or the backup system file.
9. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the Linux dual-system startup and upgrade method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the Linux dual-system startup and upgrade method according to any one of claims 1 to 7.
Citation Information
Cited By
Satellite computing device control method, satellite computing device and system
CN120315781A