CN119271460A - A Linux dual-system startup and upgrade method, device, equipment and medium - Google Patents
A Linux dual-system startup and upgrade method, device, equipment and medium Download PDFInfo
- Publication number
- CN119271460A CN119271460A CN202411349747.8A CN202411349747A CN119271460A CN 119271460 A CN119271460 A CN 119271460A CN 202411349747 A CN202411349747 A CN 202411349747A CN 119271460 A CN119271460 A CN 119271460A
- Authority
- CN
- China
- Prior art keywords
- backup
- main
- partition
- file
- file system
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1415—Saving, restoring, recovering or retrying at system level
- G06F11/1435—Saving, restoring, recovering or retrying at system level using file system or storage system metadata
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1415—Saving, restoring, recovering or retrying at system level
- G06F11/1417—Boot up procedures
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44536—Selecting among different versions
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- Computer Security & Cryptography (AREA)
- Library & Information Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a method, a device, equipment and a medium for starting and upgrading a linux double system, which relate to the technical field of computers and comprise the steps of checking a main file system partition in the starting process of terminal equipment; under the condition that the verification of the main file system partition fails, the backup partition number of the backup file system partition is obtained, a backup kernel of the backup system is read from backup system files stored in the backup file system partition, partition number parameters in kernel starting parameters are modified to be the backup partition number, the backup system is started based on the backup kernel, the modified kernel starting parameters and the backup system files, and the main system files and the backup system files stored in the main file system partition are updated through the backup system respectively, so that terminal equipment is started through the updated main system files or the backup system files. The embodiment of the invention can improve the success rate of starting the terminal equipment and the efficiency of upgrading the linux dual systems.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a method, a device, equipment and a medium for starting and upgrading a linux double system.
Background
The existing dual-system starting scheme is basically that when Uboot is started after a main file system partition is damaged in the upgrading process, the partition content of a backup file system is read and written into the main file system partition, the partition content of the main file system is decompressed, a kernel is read into a memory, then the kernel is operated to start the main system in the main file system partition, and the upgrading is detected again after the starting.
According to the method, flash data in the partition are required to be read and written simultaneously during Uboot starting, so that starting time is prolonged. In addition, frequent read-write operations also increase the risk of flash data corruption, which may result in data loss or corruption, particularly when the system is powered down.
Disclosure of Invention
In view of the above, the present invention is directed to providing a method for starting and upgrading a linux dual system, in which under the condition that verification of a partition of a main file system fails, a backup system is directly started by modifying the partition number, so as to upgrade the main system file and the backup system file, and a terminal device is started by the upgraded main system file or backup system file without performing flash data read-write between different partitions, thereby improving the success rate of starting the terminal device and the efficiency of upgrading the linux dual system.
In a first aspect, an embodiment of the present invention provides a method for starting and upgrading a linux dual system, which is applied to a terminal device, where the terminal device includes a main file system partition and a backup file system partition, and the method includes:
in the starting process of the terminal equipment, checking the main file system partition;
under the condition that the verification of the main file system partition fails, a backup partition number of the backup file system partition is obtained, and a backup kernel of the backup system is read from backup system files stored in the backup file system partition;
modifying partition number parameters in the kernel starting parameters into backup partition numbers, wherein the default value of the partition number parameters is a main partition number corresponding to a main file system partition;
Starting a backup system based on the backup kernel, the modified kernel starting parameters and the backup system files;
And upgrading the main system files and the backup system files stored in the main file system partition through the backup system respectively, so as to start the terminal equipment through the upgraded main system files or backup system files.
In a preferred embodiment of the present invention, the verifying the partition of the main file system includes:
acquiring verification information of a main system file in a main file system partition;
Comparing the verification information with preset verification information, and determining a comparison result;
if the comparison results are the same, determining that the partition of the main file system is successfully checked;
and when the comparison result is different, determining that the partition verification of the main file system fails.
In a preferred embodiment of the present invention, the method further comprises:
under the condition that the partition check of the main file system is successful, reading a main kernel of the main system from a main system file stored in the partition of the main file system;
starting a main system based on the main kernel, the kernel starting parameters and the main system file;
and upgrading the main system files and the backup system files stored in the main file system partition through the main system respectively, so as to start the terminal equipment through the upgraded main system files or backup system files.
In a preferred embodiment of the present invention, upgrading a main system file and a backup system file stored in a main file system partition, respectively, includes:
obtaining a current size value and an initial size value of a partition of a backup file system;
Determining an upgrading sequence according to a comparison result of the current size value and the initial size value;
and respectively upgrading the main system files and the backup system files stored in the main file system partition according to the upgrading sequence.
In a preferred embodiment of the present invention, determining the upgrade order according to the comparison result between the current size value and the initial size value before the start address of the primary file system partition includes:
when the comparison result is that the current size value is smaller than or equal to the initial size value, determining the upgrading sequence as upgrading the backup system file firstly and then upgrading the main system file;
And when the comparison result is that the current size value is larger than the initial size value, determining the upgrading sequence as that the main system file is upgraded firstly, and then upgrading the backup system file.
In a preferred embodiment of the present invention, the reading the backup kernel of the backup system from the backup system files stored in the backup file system partition includes:
Decompressing the backup system files stored in the backup file system partition to obtain decompressed backup system files;
and reading the backup kernel of the backup system from the decompressed backup system file.
In a preferred embodiment of the present invention, the reading the main kernel of the main system from the main system file stored in the main file system partition includes:
Decompressing the main system file stored in the main file system partition to obtain a decompressed main system file;
And reading the main kernel of the main system from the decompressed main system file.
In a second aspect, an embodiment of the present invention further provides a linux dual-system startup and upgrade apparatus, applied to a terminal device, where the terminal device includes a main file system partition and a backup file system partition, and the apparatus includes:
The verification module is used for verifying the main file system partition in the starting process of the terminal equipment;
the first reading module is used for acquiring the backup partition number of the backup file system partition under the condition that the verification of the main file system partition fails, and reading the backup kernel of the backup system from the backup system file stored in the backup file system partition;
The partition number modification module is used for modifying the partition number parameter in the kernel starting parameter into a backup partition number, wherein the default value of the partition number parameter is a main partition number corresponding to a main file system partition;
The first starting module is used for starting the backup system based on the backup kernel, the modified kernel starting parameters and the backup system files;
the first upgrading module is used for upgrading the main system files and the backup system files stored in the main file system partition through the backup system respectively so as to start the terminal equipment through the upgraded main system files or backup system files.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a processor and a memory, where the memory stores computer executable instructions that can be executed by the processor, where the processor executes the computer executable instructions to implement the linux dual-system startup and upgrade method of the first aspect.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium, where computer executable instructions are stored, where the computer executable instructions, when invoked and executed by a processor, cause the processor to implement the linux dual system startup and upgrade method of the first aspect.
The embodiment of the invention has the following beneficial effects:
The embodiment of the invention provides a linux dual-system starting and upgrading method, which is characterized in that in the starting process of terminal equipment, a main file system partition is checked, under the condition that the main file system partition fails to check, a backup partition number of a backup file system partition is obtained, and a backup kernel of a backup system is read from backup system files stored in the backup file system partition. By modifying the partition number parameter in the kernel starting parameter into the backup partition number, the backup kernel can directly start the backup system according to the kernel starting parameter and the backup system file, the backup system is utilized to upgrade the main system file and the backup system file, data reading and writing between different partitions are not needed, the efficiency of the linux double-system upgrade is improved, the starting failure caused by power failure in the data reading and writing process between different partitions is avoided, and the starting success rate of the terminal equipment is improved.
Additional features and advantages of the invention will be set forth in the description which follows, or in part will be obvious from the description, or may be learned by practice of the invention.
In order to make the above objects, features and advantages of the present invention more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are needed in the description of the embodiments or the prior art will be briefly described, and it is obvious that the drawings in the description below are some embodiments of the present invention, and other drawings can be obtained according to the drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a linux dual-system starting and upgrading method provided by an embodiment of the present invention;
FIG. 2 is a flowchart of another method for starting and upgrading a linux dual system according to an embodiment of the present invention;
FIG. 3 is a flowchart of another method for starting and upgrading a linux dual system according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a linux dual-system starting and upgrading device according to an embodiment of the present invention;
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The existing dual-system starting scheme is basically that when Uboot is started after a main file system partition is damaged in the upgrading process, the partition content of a backup file system is read and written into the main file system partition, the partition content of the main file system is decompressed, a kernel is read into a memory, then the kernel is operated to start the main system in the main file system partition, and the upgrading is detected again after the starting.
When the Uboot is started, the flash data in one partition is read, and then the read flash data is written into one partition, so that the time consumption for starting is affected by reading and writing a plurality of flash, the flash is written, and the risk of power failure is also increased.
Based on this, in the method for starting and upgrading the linux dual system provided by the embodiment of the invention, in the process of starting the terminal equipment, the main file system partition is checked, and under the condition that the main file system partition fails to check, 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 starting parameter into the backup partition number, the backup kernel can directly start the backup system according to the kernel starting parameter and the backup system file, the backup system is utilized to upgrade the main system file and the backup system file, data reading and writing between different partitions are not needed, the efficiency of upgrading the linux double systems and the starting efficiency of the terminal equipment are improved, the occurrence of starting failure caused by power failure in the process of data reading and writing between different partitions is reduced, and the starting success rate of the terminal equipment is improved.
For the sake of understanding the present embodiment, a detailed description will be given of a method for starting and upgrading a linux dual system disclosed in the present embodiment.
Example 1
The embodiment of the invention provides a method for starting and upgrading a linux double system, and fig. 1 is a flow chart of the method for starting and upgrading the linux double system. As shown in fig. 1, the linux dual system starting and upgrading method may include the following steps:
step S101, in the process of starting the terminal equipment, checking the main file system partition.
The main file system partition refers to a memory space in a memory of the terminal device, where the memory space is used for storing a main system file. The backup file system partition refers to a memory space in a memory of the terminal device, where the memory space is used to store backup system files. The memory of the terminal equipment at least comprises a main file system partition and a backup file system partition.
Specifically, when the terminal device is powered on and started, a guiding system in the memory of the terminal device, namely Uboot, is started. The method comprises the steps of verifying a main file system partition through Uboot, and specifically verifying a main system file stored in the main file system partition through Uboot, wherein the main system file is used for judging whether the main system file stored in the main file system partition is damaged or tampered. If the verification of the main file system partition fails, the main file system file stored in the main file system partition is damaged or tampered, and if the verification of the main file system partition succeeds, the main file system file stored in the main file system partition is not damaged or tampered.
By way of example, the method of verification may be a CRC check, in which the main system file typically contains a checksum (e.g., CRC or MD5 hash) to ensure that the main system file is not corrupted by data. The Uboot will recalculate these checksums after startup and compare with the values in the main system file to confirm that there is no data corruption. It may also be a log check that some file systems (e.g., ext 4) use the log to record all modification operations. The Uboot will read the log at startup, verify its integrity, and then recover the state of the file system according to the operations in the log. And space verification, namely checking the space used by the file system, ensuring that the maximum available space allocated to the file system is not exceeded, and preventing data loss or system breakdown.
Step S102, under the condition that 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 files stored in the backup file system partition.
The backup partition number is used for describing the position of the backup file system partition in the memory of the terminal device, and is a unique number for identifying the backup file system partition. The backup kernel is used for starting and running the backup system. Specifically, the backup partition number may be determined by mtdparts parameters among parameters of the Uboot. The mtdparts parameter is used for specifying the name and the size of each partition in the memory of the terminal device. The partition numbers corresponding to the respective partitions may be determined according to the arrangement order of the respective partitions in the mtdparts parameter, and the arrangement order may start from 0. For example, the format of mtdparts parameters may be expressed as :mtdparts=sfc:256K(boot),64K(env_back),64K(syscfg),64K(mcrc),4096K(minis ys),2816K(romfs),5824K(user),256K(custom),2432K(ai),512K(mtd)., where 256K, 64K, 4096K, 2816K, 5824K, 256K, 2432K, 512K refer to the sizes of the respective partitions in the memory of the terminal device, boot, env_ back, syscfg, mcrc, minisys, romfs, user, custom, ai, mtd refer to the names of the respective partitions in the memory of the terminal device, in this embodiment, the names of the backup file system partitions are minisys, the arrangement order in mtdparts is the fifth, and thus the corresponding partition numbers are mtdblock4, the names of the primary file system partitions are romifs, and the arrangement order in mtdparts is the sixth, and the corresponding partition numbers are mtdblock5.
Specifically, under the condition that the verification of the main file system partition fails, the arrangement sequence of the backup file system partition is determined by inquiring mtdparts parameters in Uboot, and the backup partition number of the backup file system partition is obtained. And according to the backup partition number, positioning the position of the backup file system partition in the memory, and reading the backup kernel of the backup system from the backup system file stored in the backup file system partition into the memory of the terminal equipment.
Step S103, the partition number parameter in the kernel starting parameter is modified into a backup partition number.
The default value of the partition number parameter is the main partition number corresponding to the main file system partition. The main partition number is used to describe the location of the main file system partition in the memory of the terminal device. The kernel starting parameter is a parameter stored in the Uboot, and at least comprises a partition number parameter used for guiding the kernel to start the system file stored in the partition corresponding to the partition number.
Illustratively, the kernel initiation parameter may be bootargs parameters, where the parameter format and content of setting the partition number are as follows:
root=/dev/mtdblock, wherein mtdblock5 is the main partition number. The primary file system partition number can be modified to a backup partition number by a preset instruction.
Step S104, starting the backup system based on the backup kernel, the modified kernel starting parameters and the backup system files.
Specifically, the Uboot operates a backup kernel, the modified kernel starting parameters in the Uboot are transmitted to the backup kernel, and the backup kernel operates backup system files stored in a backup file system partition according to the kernel starting parameters transmitted by the Uboot, so that a backup system is started.
Step S105, the main system file and the backup system file stored in the main file system partition are respectively upgraded through the backup system, so that the terminal equipment is started through the upgraded main system file or backup system file.
After the backup system is started, an upgrading function is started and used for upgrading 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 finished, the Uboot rerun the upgraded main system file to realize the start of the terminal equipment, or rerun the upgraded backup system file to realize the start of the terminal equipment.
Specifically, a backup system is operated on a terminal device, the backup system detects a network or other hardware interfaces to determine whether a system file to be upgraded exists, and when the system file to be upgraded exists, the system file to be upgraded can be received through the network or other hardware interfaces, wherein the received system file to be upgraded comprises main file system upgrading data and backup file system upgrading data, the received main file system upgrading data is stored in a main file system partition to upgrade the main file system, and the received backup file system upgrading data is stored in the backup file system partition to upgrade the backup system file. It can be understood that the memory of the terminal device may further include other application partitions, so that the received system file to be upgraded may also report other application upgrade data, and store the other application upgrade data into the other application partitions, thereby implementing the upgrade of the system file stored in the other application partitions.
In the linux dual-system starting and upgrading method provided by the embodiment of the invention, in the starting process of the terminal equipment, the main file system partition is checked, under the condition that the main file system partition fails to check, 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 starting parameter into the backup partition number, the backup kernel can directly start the backup system according to the kernel starting parameter and the backup system file, the backup system is utilized to upgrade the main system file and the backup system file, data reading and writing between different partitions are not needed, the efficiency of upgrading the linux double systems and the starting efficiency of the terminal equipment are improved, the starting failure caused by power failure in the process of reading and writing the data between different partitions is avoided, and the starting success rate of the terminal equipment is improved.
Example 2
The embodiment of the invention also provides another linux double-system starting and upgrading method, which is realized on the basis of the method of the embodiment, and the method mainly describes a specific implementation mode for checking the main file system partition.
Fig. 2 is a flowchart of another method for starting and upgrading a linux dual system according to an embodiment of the present invention, as shown in fig. 2, the method for starting and upgrading a linux dual system may include the following steps:
step S201, in the process of starting the terminal equipment, acquiring verification information of the main system file in the main file system partition.
The verification information is used for judging whether the main system file is damaged or tampered. In this embodiment, the check information may be a CRC check value of the main system file. Specifically, in the process of starting the terminal device, a CRC check value may be calculated for a main system file in the main file system partition, and the calculated CRC check value is used as check information of the main system file.
Step S202, comparing the verification information with preset verification information, and determining a comparison result.
The preset check information refers to a pre-stored CRC value of the main system file before the terminal device is started, and a memory partition, for example, a check partition, may be separately established in the memory of the terminal device, where the memory partition is used to store the preset check information, so as to improve the security of the preset check information.
Specifically, the Uboot may read preset check information from the check partition, compare the preset check information with the calculated check information, and if the preset check information is the same as the check information, determine that the comparison result is the same. If the preset check information is different from the check information, the comparison result is determined to be different.
And step S203, when the comparison results are the same, determining that the partition verification of the main file system is successful.
And when the comparison results are the same, indicating that the main file system is not damaged or tampered, and determining that the partition of the main file system is successfully checked.
And step S204, determining that the partition verification of the main file system fails when the comparison result is different.
And when the comparison result is different, indicating that the main system file is damaged or tampered, and determining that the main file system partition check fails.
Step S205, under the condition that 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 files stored in the backup file system partition.
Specifically, the backup kernel of the backup system may be read through steps a 1 -a 2.
And step A 1, decompressing the backup system files stored in the backup file system partition to obtain decompressed backup system files.
The Uboot can decompress the backup system files 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 files.
And step A 2, reading a backup kernel of the backup system from the decompressed backup system file.
The decompressed backup system file may be a plurality of files, and the Uboot may identify a file containing a backup kernel from the decompressed backup system file, and load the backup kernel in the file. It will be appreciated that the file containing the backup kernel may be identified by identifying the name or tag of the file, which may be, for example, "kernel".
The backup system is a mini file system and only comprises an upgrading function and a network function, and compared with a file system with a complete function, the mini file system occupies smaller memory space, so that when the backup system files are decompressed, the decompression speed is higher, the starting speed is increased, the risk possibly caused by power failure is reduced, meanwhile, the requirement of a double system on the storage space is reduced, meanwhile, because the mini file system only supports upgrading and a network module, the upgrading is directly detected after the mini file system is started, and the updating and upgrading speed of terminal equipment is also increased.
Step S206, the partition number parameter in the kernel starting parameter is modified into the backup partition number.
Step S207, starting the backup system based on the backup kernel, the modified kernel starting parameters and the backup system files.
Step S208, the main system file and the backup system file stored in the main file system partition are respectively upgraded through the backup system, so that the terminal equipment is started through the upgraded main system file or backup system file.
Specifically, the primary system files and the backup system files stored in the primary file system partition may be upgraded by steps B 1 -B 3, respectively.
And step B 1, obtaining the current size value and the initial size value of the backup file system partition.
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.
Specifically, the backup system may receive a system file to be upgraded through a network or other hardware interfaces, where the received system file to be upgraded includes main file system upgrade data and backup file system upgrade data, and the backup system parses the backup file system upgrade data, reads a current value, and reads an initial value from a kernel start parameter of the Uboot.
And step B 2, determining the upgrading sequence according to the comparison result of the current size value and the initial size value.
And comparing the current magnitude value with the initial magnitude value to obtain a comparison result. Specifically, if the comparison result is that the current size value is smaller than or equal to the initial size value, indicating that the backup file system partition is not enlarged, determining that the upgrading sequence is to upgrade the backup file system first and then upgrade the main file system.
If the comparison result shows that the current size value is larger than the initial size value, indicating that the backup file system partition is enlarged, determining the upgrading sequence to upgrade the main system file first and then upgrade the backup file system.
And step B 3, upgrading the main system files and the backup system files stored in the main file system partition respectively.
And sequentially storing the received system files to be upgraded into the main file system partition and the backup file system partition according to the upgrading sequence, so as to upgrade the main system and the backup system.
In this embodiment, before the start address of the backup file system partition is located at the start address of the main file system partition, if the backup file system partition becomes larger, the start address of the main file system partition will move backward, in the process of upgrading the main system, the system file to be upgraded stored in the main file system partition will not cover the original backup file system partition, if the upgrading main system is abnormal, the backup system can be started up next time, if the upgrading of the backup system fails, the main system is already upgraded, and when the main system is started up again, the main system can be started up.
If the backup file system partition is not enlarged, the situation is contrary, the backup file system is updated first, and the backup file system is not stepped on the main file system partition after the backup file system is updated. If the backup system is updated abnormally, the next starting can start the main system, if the main system is not updated, the backup system is already updated, and the backup system can be started when the backup system is started again.
By judging whether the partition size of the backup file system is enlarged or not, determining the upgrading sequence of the main system file and the backup file system according to the judging result, and upgrading according to the upgrading sequence, one of the systems can be ensured to be complete and usable when abnormality occurs at any stage in the upgrading process of the main system and the backup system, and the success rate of starting the linux double systems is improved.
Example 3
The embodiment of the invention also provides another linux double-system starting and upgrading method, which is realized on the basis of the method of the embodiment, and the method mainly describes a specific implementation mode of the condition that the partition of the main file system is successfully checked.
Fig. 3 is a flowchart of another method for starting and upgrading a linux dual system according to an embodiment of the present invention, as shown in fig. 3, the method for starting and upgrading a linux dual system may include the following steps:
Step S301, in the process of starting the terminal device, obtaining verification information of the main system file in the main file system partition.
Step S302, comparing the verification information with preset verification information, and determining a comparison result.
And step S303, when the comparison results are the same, determining that the partition verification of the main file system is successful.
And step S304, determining that the partition verification of the main file system fails when the comparison result is different.
In step S305, under the condition that the verification of the partition of the main file system is successful, the main kernel of the main system is read from the main system file stored in the partition of the main file system.
The main partition number is used for describing the position of the main file system partition in the memory of the terminal device, and is a unique number for identifying the main file system partition. The main kernel is used for starting and running the main system. Specifically, the primary partition number may be determined by mtdparts parameters among parameters of the Uboot.
Specifically, under the condition that the partition of the main file system is successfully checked, the arrangement sequence of the partitions of the main file system is determined by inquiring mtdparts parameters in Uboot, and the main partition numbers of the partitions of the main file system are obtained. And according to the main partition number, positioning the position of the main file system partition in the memory, and reading the main kernel of the main system from the main system file stored in the main file system partition into the memory of the terminal equipment.
Further, the backup kernel of the backup system may be read through steps C 1 -C 2.
And step C 1, decompressing the main system file stored in the main file system partition to obtain the decompressed main system file.
The Uboot can decompress the main system file stored in the main file system partition by running a corresponding decompression tool or a decompression instruction, and the obtained decompression result is the decompressed main system file.
And step C 2, reading a main kernel of the main system from the decompressed main system file.
The decompressed main system file may be a plurality of files, and the Uboot may identify a file containing a main kernel from the decompressed main system file, and load the main kernel in the file. It will be appreciated that a file containing the primary kernel may be identified by identifying the name or tag of the file, which may be, for example, "kernel".
Step S306, starting the main system based on the main kernel, the kernel starting parameters and the main system file.
Specifically, the Uboot operates a main kernel, kernel starting parameters in the Uboot are transmitted to the main kernel, and the main kernel operates a main system file stored in a main file system partition according to the kernel starting parameters transmitted by the Uboot, so as to start a main system.
Step S307, upgrade the main system file and the backup system file stored in the main file system partition through the main system, so as to start the terminal device through the upgraded main system file or backup system file.
After the main system is started, an upgrading function is started and is used for upgrading 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 finished, the Uboot rerun the upgraded main system file to realize the start of the terminal equipment, or rerun the upgraded backup system file to realize the start of the terminal equipment.
Specifically, a main system is operated on a terminal device, the main system detects a network or other hardware interfaces to determine whether a system file to be upgraded exists, and when the system file to be upgraded exists, the main system can receive the system file to be upgraded through the network or other hardware interfaces, wherein the received system file to be upgraded comprises main file system upgrading data and backup file system upgrading data, the received main file system upgrading data is stored in a main file system partition to upgrade the main system file, and the received backup file system upgrading data is stored in a backup file system partition to upgrade the backup system file. It may be understood that the memory of the terminal device may further include other application partitions, so that the received system file to be upgraded may further include other application upgrade data, and the other application upgrade data is stored in the other application partitions, so as to implement an upgrade of the system file stored in the other application partitions.
Further, the method comprises the steps of respectively upgrading the main system file and the backup system file stored in the main file system partition, obtaining the current size value and the initial size value of the backup file system partition, determining an upgrading sequence according to the comparison result of the current size value and the initial size value, and respectively upgrading the main system file and the backup system file stored in the main file system partition according to the upgrading sequence. And when the comparison result is that the current size value is greater than the initial size value, determining the upgrading sequence as upgrading the main system file firstly and then upgrading the backup system file.
According to the method for starting and upgrading the linux double system, provided by the embodiment of the invention, under the condition that the partition verification of the main file system is successful, the main kernel of the main system is directly read, the main system is started, the main system file and the backup system file are upgraded according to the upgrading sequence by utilizing the main system, one of the systems can be ensured to be complete and usable when the main system and the backup system are abnormal at any stage in the upgrading process, and the success rate of starting the linux double system is improved.
Example 4
Corresponding to the above method embodiment, the embodiment of the present invention provides a linux dual-system starting and upgrading device, and fig. 4 is a schematic structural diagram of the linux dual-system starting and upgrading device provided by the embodiment of the present invention, as shown in fig. 4, where the linux dual-system starting and upgrading device may include:
The verification module 401 is configured to verify the main file system partition during the starting process of the terminal device;
The first reading module 402 is configured to obtain a backup partition number of a backup file system partition when verification of a main file system partition fails, and read a backup kernel of the backup system from a backup system file stored in the backup file system partition;
the partition number modification module 403 is configured to modify a partition number parameter in the kernel start parameter into a backup partition number, where a default value of the partition number parameter is a main partition number corresponding to a main file system partition;
a first starting module 404, configured to start a backup system based on the backup kernel, the modified kernel starting parameter, and the backup system file;
the first upgrade module 405 is configured to upgrade, by using the backup system, the main system file and the backup system file stored in the main file system partition, respectively, so as to start the terminal device by using the upgraded main system file or backup system file.
In the linux dual-system starting and upgrading device provided by the embodiment of the invention, in the starting process of the terminal equipment, the main file system partition is checked, under the condition that the main file system partition fails to check, 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 starting parameter into the backup partition number, the backup kernel can directly start the backup system according to the kernel starting parameter and the backup system file, the backup system is utilized to upgrade the main system file and the backup system file, data reading and writing between different partitions are not needed, the efficiency of upgrading the linux double systems and the starting efficiency of the terminal equipment are improved, the starting failure caused by power failure in the process of reading and writing the data between different partitions is avoided, and the starting success rate of the terminal equipment is improved.
In some embodiments, the verification module 401 includes:
the verification information acquisition unit is used for acquiring the verification information of the main system file in the main file system partition;
The comparison unit is used for comparing the check information with preset check information and determining a comparison result;
The first result unit is used for determining that the partition of the main file system is successfully checked when the comparison results are the same;
and the second result unit is used for determining that the partition verification of the main file system fails when the comparison result is different.
In some embodiments, the apparatus further comprises:
The second reading module is used for reading a main kernel of the main system from the main system file stored in the main file system partition under the condition that the main file system partition is successfully checked;
The second starting module is used for starting the main system based on the main kernel, the kernel starting parameters and the main system file;
and the second upgrading module is used for upgrading the main system file and the backup system file stored in the main file system partition through the main system respectively so as to start the terminal equipment through the upgraded main system file or backup system file.
In some embodiments, the first upgrade module or the second upgrade module further comprises:
a magnitude value acquisition unit configured to acquire a magnitude value, the method comprises the steps of obtaining a current size value and an initial size value of a backup file system partition;
the upgrading sequence determining unit is used for determining the upgrading sequence according to the comparison result of the current size value and the initial size value;
And the upgrading unit is used for upgrading the main system file and the backup system file stored in the main file system partition according to the upgrading sequence.
In some embodiments, the starting address of the backup file system partition precedes the starting address of the primary file system partition, and the upgrade order determining unit is specifically configured to:
when the comparison result is that the current size value is smaller than or equal to the initial size value, determining the upgrading sequence as upgrading the backup system file firstly and then upgrading the main system file;
And when the comparison result is that the current size value is larger than the initial size value, determining the upgrading sequence as that the main system file is upgraded firstly, and then upgrading the backup system file.
In some embodiments, the first reading module is specifically configured to:
Decompressing the backup system files stored in the backup file system partition to obtain decompressed backup system files;
and reading the backup kernel of the backup system from the decompressed backup system file.
In some embodiments, the second reading module is specifically configured to:
Decompressing the main system file stored in the main file system partition to obtain a decompressed main system file;
And reading the main kernel of the main system from the decompressed main system file.
The device provided by the embodiment of the present invention has the same implementation principle and technical effects as those of the foregoing method embodiment, and for the sake of brevity, reference may be made to the corresponding content in the foregoing method embodiment where the device embodiment is not mentioned.
Example 5
The embodiment of the invention also provides an electronic device for running the above-mentioned linux dual-system starting and upgrading method, referring to a structural schematic diagram of the electronic device shown in fig. 5, the electronic device comprises a memory 500 and a processor 501, wherein the memory 500 is used for storing one or more computer instructions, and the one or more computer instructions are executed by the processor 501 to realize the above-mentioned linux dual-system starting and upgrading method.
Further, the electronic device shown in fig. 5 further includes a bus 502 and a communication interface 503, and the processor 501, the communication interface 503, and the memory 500 are connected by the bus 502.
The memory 500 may include a high-speed random access memory (RAM, random Access Memory), and may further include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the system network element and at least one other network element is implemented via at least one communication interface 503 (which may be wired or wireless), which may use the internet, a wide area network, a local network, a metropolitan area network, etc. Bus 502 may be an ISA bus, a PCI bus, an EISA bus, or the like. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 5, but not only one bus or type of bus.
The processor 501 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuitry in hardware or instructions in software in the processor 501. The Processor 501 may be a general-purpose Processor, including a central processing unit (Central Processing Unit, CPU), a network Processor (Network Processor, NP), a digital signal Processor (DIGITAL SIGNAL Processor, DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable gate array (FPGA) or other Programmable logic device, discrete gate or transistor logic device, or discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be embodied directly in the execution of a hardware decoding processor, or in the execution of a combination of hardware and software modules in a decoding processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in the memory 500, and the processor 501 reads the information in the memory 500, and in combination with its hardware, performs the steps of the method of the previous embodiment.
The embodiment of the invention also provides a computer readable storage medium, which stores computer executable instructions that, when being called and executed by a processor, cause the processor to implement the above-mentioned linux dual-system starting and upgrading method, and the specific implementation can be referred to the method embodiment and will not be described herein.
The computer program product for performing the linux dual-system startup and upgrade method provided by the embodiment of the present invention includes a computer readable storage medium storing non-volatile program code executable by a processor, where the program code includes instructions for executing the method described in the foregoing method embodiment, and specific implementation may refer to the method embodiment and will not be described herein.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of 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.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. The storage medium includes a U disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, an optical disk, or other various media capable of storing program codes.
It should be noted that the foregoing embodiments are merely illustrative embodiments of the present invention, and not restrictive, and the scope of the invention is not limited to the embodiments, and although the present invention has been described in detail with reference to the foregoing embodiments, it should be understood by those skilled in the art that any modification, variation or substitution of some of the technical features of the embodiments described in the foregoing embodiments may be easily contemplated within the scope of the present invention, and the spirit and scope of the technical solutions of the embodiments do not depart from the spirit and scope of the embodiments of the present invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.
Claims (10)
1. A linux dual system starting and upgrading method, which is characterized by being applied to a terminal device, wherein the terminal device comprises a main file system partition and a backup file system partition, and the method comprises the following steps:
In the starting process of the terminal equipment, checking the main file system partition;
Under the condition that the verification of the main file system partition fails, acquiring a backup partition number of the backup file system partition, and reading a backup kernel of a backup system from backup system files stored in the backup file system partition;
modifying partition number parameters in kernel starting parameters into the backup partition numbers, wherein the default value of the partition number parameters is a main partition number corresponding to a main file system partition;
starting a backup system based on the backup kernel, the modified kernel starting parameters and the backup system files;
And upgrading the main system files and the backup system files stored in the main file system partition through the backup system respectively, so as to start the terminal equipment through the upgraded main system files or backup system files.
2. The method of claim 1, wherein the verifying the primary file system partition comprises:
acquiring verification information of a main system file in a main file system partition;
comparing the verification information with preset verification information, and determining a comparison result;
when the comparison results are the same, determining that the partition verification of the main file system is successful;
and when the comparison result is different, determining that the partition verification of the main file system fails.
3. The method as recited in claim 2, further comprising:
under the condition that the partition check of the main file system is successful, reading a main kernel of a main system from a main system file stored in the partition of the main file system;
Starting a main system based on the main kernel, the kernel starting parameters and the main system file;
And upgrading the main system files and the backup system files stored in the main file system partition through the main system respectively, so as to start the terminal equipment through the upgraded main system files or backup system files.
4. A method according to claim 1 or 3, wherein upgrading the primary system file and the backup system file stored by the primary file system partition, respectively, comprises:
Acquiring a current size value and an initial size value of the backup file system partition;
Determining an upgrading sequence according to the comparison result of the current size value and the initial size value;
And respectively upgrading the main system files and the backup system files stored in the main file system partition according to the upgrading sequence.
5. The method of claim 4, wherein the starting address of the backup file system partition precedes the starting address of the primary file system partition, wherein determining the upgrade order based on the comparison of the current size value and the initial size value comprises:
when the comparison result is that the current size value is smaller than or equal to the initial size value, determining the upgrading sequence as upgrading the backup system file firstly and then upgrading the main system file;
And when the comparison result is that the current size value is larger than the initial size value, determining the upgrading sequence as that the main system file is upgraded firstly and then the backup system file is upgraded.
6. The method of claim 1, wherein the reading the backup kernel of the backup system from the backup system files stored in the backup file system partition comprises:
decompressing the backup system files stored in the backup file system partition to obtain decompressed backup system files;
and reading the backup kernel of the backup system from the decompressed backup system file.
7. The method of claim 3, wherein the reading the primary kernel of the primary system from the primary system file stored by the primary file system partition comprises:
Decompressing the main system file stored in the main file system partition to obtain a decompressed main system file;
And reading the main kernel of the main system from the decompressed main system file.
8. A linux dual system starting and upgrading device, applied to a terminal device, wherein the terminal device comprises a main file system partition and a backup file system partition, and the device comprises:
The verification module is used for verifying the main file system partition in the starting process of the terminal equipment;
the first reading module is used for acquiring the backup partition number of the backup file system partition under the condition that the verification of the main file system partition fails, and reading the backup kernel of the backup system from the backup system file stored in the backup file system partition;
The partition number modification module is used for modifying the partition number parameter in the kernel starting parameter into the backup partition number, wherein the default value of the partition number parameter is a main partition number corresponding to a main file system partition;
The first starting module is used for starting a backup system based on the backup kernel, the modified kernel starting parameters and the backup system files;
and the first upgrading module is used for upgrading the main system file and the backup system file stored in the main file system partition through the backup system respectively so as to start the terminal equipment through the upgraded main system file or backup system file.
9. An electronic device comprising a processor and a memory, the memory storing computer executable instructions executable by the processor, the processor executing the computer executable instructions to implement the linux dual system startup and upgrade method of any of claims 1-7.
10. A computer readable storage medium storing computer executable instructions which, when invoked and executed by a processor, cause the processor to implement the linux dual system startup and upgrade method of any of claims 1 to 7.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411349747.8A CN119271460A (en) | 2024-09-26 | 2024-09-26 | A Linux dual-system startup and upgrade method, device, equipment and medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411349747.8A CN119271460A (en) | 2024-09-26 | 2024-09-26 | A Linux dual-system startup and upgrade method, device, equipment and medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN119271460A true CN119271460A (en) | 2025-01-07 |
Family
ID=94120502
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202411349747.8A Pending CN119271460A (en) | 2024-09-26 | 2024-09-26 | A Linux dual-system startup and upgrade method, device, equipment and medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN119271460A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN120315781A (en) * | 2025-06-17 | 2025-07-15 | 之江实验室 | A satellite computing device control method, satellite computing device and system |
-
2024
- 2024-09-26 CN CN202411349747.8A patent/CN119271460A/en active Pending
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN120315781A (en) * | 2025-06-17 | 2025-07-15 | 之江实验室 | A satellite computing device control method, satellite computing device and system |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN111880740B (en) | Data processing method, device, computer system and readable storage medium | |
| US7543137B2 (en) | Information processing device and information processing method | |
| CN108563532B (en) | Data processing method and related device | |
| US20070055969A1 (en) | System and method for updating firmware | |
| CN110442473B (en) | Nonvolatile data storage method and device, electronic equipment and medium | |
| CN114116305A (en) | BIOS firmware recovery method, system, terminal and storage medium based on PFR | |
| US11586504B2 (en) | Electronic apparatus and boot method thereof | |
| CN119271460A (en) | A Linux dual-system startup and upgrade method, device, equipment and medium | |
| CN109582332B (en) | System upgrading method and device for Internet camera | |
| CN113110891B (en) | Firmware loading method and device for solid state disk, computer equipment and storage medium | |
| CN110286932A (en) | Program downloading method and device | |
| CN115756984A (en) | Memory test method, device, equipment and storage medium | |
| KR20230091660A (en) | Method and apparatus for verify software integrity | |
| CN120066598B (en) | Classification method of operating system startup items, computer program products and services | |
| US7490321B2 (en) | Method for updating firmware via determining program code | |
| CN113050887B (en) | Flash memory partition data processing method, device, computer equipment and storage medium | |
| CN111857882B (en) | Extensible SSD card opening firmware loading method and device, computer equipment and storage medium | |
| US6539338B1 (en) | Self-diagnostic testing of a network interface adapter | |
| CN114385418A (en) | Protection method, device, equipment and storage medium for communication equipment | |
| CN118503014A (en) | Software upgrading method, device, equipment and computer readable storage medium | |
| CN114115700B (en) | Flash memory data reading and writing method and flash memory data reading and writing device | |
| CN113608922A (en) | Backup system switching method and device | |
| CN113626091A (en) | Starting optimization method and device of solid state disk, computer equipment and storage medium | |
| CN118747095B (en) | Method and device for starting embedded system, electronic equipment and storage medium | |
| CN112905218A (en) | Firmware upgrading method, device and equipment |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |