CN109298873B - System upgrading method and device - Google Patents
System upgrading method and device Download PDFInfo
- Publication number
- CN109298873B CN109298873B CN201710584511.6A CN201710584511A CN109298873B CN 109298873 B CN109298873 B CN 109298873B CN 201710584511 A CN201710584511 A CN 201710584511A CN 109298873 B CN109298873 B CN 109298873B
- Authority
- CN
- China
- Prior art keywords
- partition
- data
- partition table
- new
- upgrading
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR 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/44505—Configuring for program initiating, e.g. using registry, configuration files
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Stored Programmes (AREA)
Abstract
The embodiment of the invention provides a system upgrading method and device, which are characterized in that an upgrading packet is obtained; analyzing an upgrading sequence when the data of each partition are upgraded from the upgrading packet, wherein the upgrading sequence is determined according to the type of the partition table change, and comprises a positive sequence and a reverse sequence; according to the upgrading sequence, the data in the source partition table are processed according to a preset rule and then are transferred to a new partition table; by adopting the scheme, the conversion of the source partition table and the new partition table data is realized by using a reverse order or positive order moving mode, the full backup of the data is not needed, the requirement on the buffer space in the moving process is reduced, the data which is not upgraded or not moved is not destroyed, the processed data is occupied in time, the limited space is fully utilized, the backup recovery efficiency is also improved, the time required by the upgrading process is reduced, and the upgrading success rate is improved.
Description
Technical Field
The present invention relates to the field of communications, and in particular, to a method and apparatus for upgrading a system.
Background
Currently, in the project development process, the system residual space is smaller and smaller due to the increase of local application or google patch, and the partition table needs to be modified, for example, the system partition is increased, or a new partition is added.
Partition change necessarily involves the problem of how user data is retained, and existing variable partition schemes mention that all data backed up is rewritten after the new partition table is divided, and when user data is large, external storage devices are required to be used, the upgrading process is long, and the failure probability is high.
Disclosure of Invention
The technical problem mainly solved by the embodiment of the invention is to provide a system upgrading method and device, and solve the problems of long upgrading process and high failure probability caused by partition modification in the prior art.
In order to solve the above technical problems, an embodiment of the present invention provides a system upgrade method, including:
acquiring an upgrade package;
analyzing an upgrading sequence when the data of each partition are upgraded from the upgrading packet, wherein the upgrading sequence is determined according to the type of the partition table change, and comprises a positive sequence and a reverse sequence;
and according to the upgrading sequence, the data in the source partition table are processed according to a preset rule and then are migrated to the new partition table.
In order to solve the above technical problems, an embodiment of the present invention provides a system upgrade apparatus, including:
the acquisition module is used for acquiring the upgrade package;
the analysis module is used for analyzing the upgrading sequence of the data of each partition when the data of each partition is upgraded from the upgrading packet, the upgrading sequence is determined according to the type of the partition table change, and the upgrading sequence comprises a positive sequence and a reverse sequence;
and the upgrading module is used for processing the data in the source partition table according to a preset rule and then migrating the processed data into the new partition table according to the upgrading sequence.
In order to solve the above technical problems, an embodiment of the present invention further provides a computer storage medium, in which computer executable instructions are stored, where the computer executable instructions are configured to execute the foregoing system upgrade method.
The beneficial effects of the invention are as follows:
according to the system upgrading method and device provided by the embodiment of the invention, the upgrading package is obtained; analyzing an upgrading sequence when the data of each partition are upgraded from the upgrading packet, wherein the upgrading sequence is determined according to the type of the partition table change, and comprises a positive sequence and a reverse sequence; according to the upgrading sequence, the data in the source partition table are processed according to a preset rule and then are transferred to a new partition table; by adopting the scheme, the upgrading sequence of the data of each partition determined according to the type of the partition table change comprises a positive sequence and a reverse sequence, the data in the source partition table is upgraded according to the upgrading sequence, the conversion of the data of the source partition table and the new partition table is realized by using a reverse sequence or a positive sequence moving mode, the whole disk backup of the data is not needed, the requirement on the buffer space in the moving process is reduced, the data which are not upgraded or not moved is not damaged, the processed data are occupied in time, the limited space is fully utilized, the backup recovery efficiency is also improved, the time required by the upgrading process is reduced, and the upgrading success rate is improved.
Drawings
FIG. 1 is a flowchart of a system upgrade method according to a first embodiment of the present invention;
FIG. 2 is a schematic diagram of absolute address variation of data in various partitions according to various embodiments of the present invention;
FIG. 3 is a schematic diagram illustrating a relative address change of data in a userdata partition according to various embodiments of the present invention;
FIG. 4 is a diagram illustrating relative address changes of data in a system partition according to various embodiments of the present invention;
fig. 5 is a schematic diagram of a system upgrade apparatus according to a second embodiment of the present invention.
Detailed Description
The embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
Example 1
Referring to fig. 1, fig. 1 is a flowchart of a system upgrade method provided in the present embodiment, and the method includes the following steps:
s101: acquiring an upgrade package;
s102: analyzing an upgrading sequence when the data of each partition are upgraded from the upgrading packet, wherein the upgrading sequence is determined according to the type of the partition table change, and comprises a positive sequence and a reverse sequence;
the number of different project partitions is different, but the main partitions and their arrangement order are consistent, for example, the system includes sbl partition, rpm partition, modem partition, boot partition, recovery partition, tz partition, system partition, userdata partition and is arranged in this order. At this time, the positive sequence upgrade is to upgrade the following partitions in sequence: sbl1 partition, rpm partition, modem partition, boot partition, recovery partition, tz partition, system partition, userdata partition. The reverse upgrade is to upgrade the following partitions in sequence: userdata partition, system partition, tz partition, recovery partition, boot partition, modem partition, rpm partition, sbl partition.
The types to which the partition table changes belong include newly added partition, system partition expansion and system partition contraction;
for the case of a newly added partition, in addition to the user data partition size change, a change in the system partition head address is involved;
for the conditions of system partition expansion and system partition shrinkage, only the problem of user data preservation after the user data partition size is changed needs to be considered;
s103: and according to the upgrading sequence, the data in the source partition table are processed according to a preset rule and then are migrated to the new partition table.
In one embodiment, when the partition table change belongs to a new partition type, the new partition is inserted before the system partition, the head address of the system partition is changed, the whole system partition is shifted backwards, the userdata partition is contracted, and the upgrading sequence is in a reverse order;
s103, according to the upgrading sequence, the step of migrating the data in the source partition table to the new partition table after processing the data according to a preset rule comprises the following steps:
migrating data in a userdata partition in the source partition table to a userdata partition in the new partition table according to a first preset sub-rule;
updating the data in the system partition according to a second preset sub-rule, and writing the data into the system partition of the new partition table;
writing the corresponding data in the source partition table into a new partition of the new partition table;
updating the data in other partitions in reverse order, and correspondingly writing the data into the corresponding partitions of the new partition table;
other partitions are upgraded, and the head addresses of the partitions are unchanged, so that the upgrading process is similar to the original process, and other partition upgrades are consistent with the existing mode.
For example, the source partition table contains sbl partitions, rpm partitions, modem partitions, boot partitions, recovery partitions, tz partitions, system partitions, and userdata partitions, and is arranged in this order, and when a new partition table is inserted before a system partition, data in the userdata partitions, the system partitions, tz partitions, recovery partitions, boot partitions, modem partitions, rpm partitions, and sbl1 partitions in the source partition table are sequentially processed during reverse upgrade.
In one embodiment, when the type of the partition table change is System partition expansion, the userdata partition is reduced, the userdata partition address is offset backwards, and the upgrading sequence is reverse;
for System partition expansion, the userdata partition is reduced, the head address of the userdata partition is increased, the whole data area moves backwards, and the core writes by using the reverse order of the data partition, so that the un-moved data is not damaged;
s103, according to the upgrading sequence, the step of migrating the data in the source partition table to the new partition table after processing the data according to a preset rule comprises the following steps:
migrating data in a userdata partition in the source partition table to a userdata partition in the new partition table according to a first preset sub-rule;
updating the data in other partitions in reverse order, and correspondingly writing the data into the corresponding partitions of the new partition table;
after data in the userdata partition is migrated, the system partition and the partition before the system partition are upgraded, and the upgrading process is similar to the original process as the head addresses of the partitions are unchanged, so that the system partition and the previous partition are upgraded in a consistent manner.
The migration of the data in the userdata partition in the source partition table to the userdata partition in the new partition table according to the first preset sub-rule includes:
acquiring each data block of a userdata partition in an upgrade package; dividing the data blocks according to the residual space of the userdata partition, numbering each data block from 0 to M in sequence, wherein the difference value between the head address of the userdata partition in the new partition table and the head address of the userdata partition in the source partition table is a, each data block is 0+a to Mxc+a based on the offset of the head address of the userdata partition in the new partition table, wherein c is the size of each data block, and M is greater than 0;
migrating the data of each data block to a userdata partition of a new partition table in reverse order, wherein the method specifically comprises the following steps of: the method comprises the steps of obtaining data of a data partition with the number M, backing up the data to an idle space of a userdata partition, wherein the backup process is to prevent the data from being unable to be recovered after upgrading interruption; since the current projects all support encryption of userdata, the last 16K of the stored secret key is ensured not to move and not to be covered; writing the data of the data block into a storage area with the head address of M+c+a and the tail address of (M+1) c+a of a userdata partition in a new partition table; and acquiring the data of the data block with the number M-1, and repeating the steps until the data of the data block with the number 0 is migrated to the userdata partition of the new partition table.
The data partitioning is mainly to acquire the space occupation condition of the userdata partition, determine the size of the data partitioning according to the space occupation condition, for example, the residual space is larger than 1.5G, partition the data with the size of 1G, if the residual space is smaller than 1.5G, partition the data with the size of 50% of the residual space, and write the data into a data partitioning table, wherein the table can be accessed by an upgrade program in the upgrade process.
For example, referring to fig. 2, fig. 2 is a schematic diagram of absolute address variation of data in each partition according to the present embodiment; in fig. 2, the first address of the sbl partition in the source partition table is 0, and the last address is 100; the head address of other partitions in the source partition table is 100, and the tail address is 200; the first address of the tz partition in the source partition table is 200, and the last address is 300; the head address of the system partition in the source partition table is 300, and the tail address is 500; the head address of the userdata partition in the source partition table is 500;
a partition newpartition is added before the system partition, the head address of the sbl partition in the new partition table is 0, and the tail address is 100; the head address of other partitions in the new partition table is 100, and the tail address is 200; the first address of the tz partition in the new partition table is 200, and the last address is 300; the head address of the newpartition partition in the new partition table is 300, and the tail address is 400; the head address of the system partition in the new partition table is 400, and the tail address is 600; the head address of the userdata partition in the new partition table is 600.
Referring to fig. 3, fig. 3 is a schematic diagram illustrating a relative address change of data in a userdata partition according to the present embodiment; in FIG. 3, the userdata partition in the source partition table contains data chunks numbered 0, with a head address of 0 and a tail address of c; the data block with the number of 1 is also contained, the head address of the data block is c, and the tail address of the data block is 2c; the method also comprises a data block with the number of 2, wherein the head address of the data block is 2c, and the tail address of the data block is 3c; also contains free space, whose head address is 3c;
the difference value between the head address of the userdata partition in the new partition table and the head address of the userdata partition in the source partition table is a, wherein a=100; the new partition table contains data blocks with the number of 0, the head address of the data blocks is a, and the tail address of the data blocks is c+a; the data block with the number of 1 is also contained, the head address of the data block is c+a, and the tail address of the data block is 2c+a; the data block with the number of 2 is also contained, the head address of the data block is 2c+a, and the tail address of the data block is 3c+a; also included is free space, whose head address is 3c+a.
Wherein updating the data in the system partition according to the second preset sub-rule and writing the data into the system partition of the new partition table comprises:
acquiring each data block of a system partition in an upgrade package; numbering each data block from 1 to P in sequence, wherein the difference value between the head address of the system partition in the new partition table and the head address of the system partition in the source partition table is e, and P is greater than 1;
acquiring a head address A and a tail address B of a last data block number P of a system partition, merging patches into the data block, and writing the merged data of the data block into positions A+e to B+e of the system partition in a new partition table; and acquiring the head address and the tail address of the last data partition of the system partition number P, and repeating the steps until the data of the data partition number 1 is written into the system partition of the new partition table.
Referring to FIG. 4, FIG. 4 is a schematic diagram showing the relative address change of data in a system partition according to the present embodiment; in FIG. 4, the system partition in the source partition table contains data blocks numbered 1, 2, and 3 and a free space data block, with the head address of the data block numbered 1 being 0; the tail address of the data block with the number of 2 is A; the head address of the data block with the number of 3 is A, and the tail address is B; the head address of the free space data block is B;
the difference between the first address of the system partition in the new partition table and the first address of the system partition in the source partition table is e, wherein e=100; the new partition table contains a data partition with the number of 1, and the head address of the data partition is e; the data block with the number of 2 is also contained, and the tail address of the data block is A+e; the data block with the number of 3 is also contained, the head address of the data block is A+e, and the tail address of the data block is B+e; also included is free space, whose head address is b+e.
In the same item, a=e.
Aiming at the situation of a newly added partition, the existing block upgrading technology is needed to be utilized, the block technology is not based on files in a file system any more, differential upgrading is carried out by utilizing the space occupied by the files, for example, the space occupied by one file is from an address A to an address B, data between the address A and the address B are directly read during upgrading, and the data are written back to the address A to the address B after patching. The difference process is to compare the address spaces and generate patch data, and generate an address space list system.transfer.list corresponding to the patch, and support the system upgrade project to carry system map files in the compiled version, and record the address spaces corresponding to all files in the system partition.
In this scheme, the contents of the system map and the system transfer list are ordered when making the upgrade package, and are arranged in a manner of from big to small in the first address, that is, the upgrade is performed sequentially from the partition last, so that the data which is not upgraded and not offset is kept. Setting the difference value between the first address of the new partition table system partition and the first address of the source partition table system partition as e, firstly acquiring data from the tail address A of the second file to the tail address B of the first file according to the system map file (the address space of the two files is not necessarily continuous), merging the patch into the data block if the address of the system transfer list is between A and B, writing the data block into the space between A+e and B+e, skipping the patching step if the address of the first patch is smaller than A, copying into the space between A+e and B+e, sequentially executing the steps, and finally moving the data block containing partition head information backward by e.
In one embodiment, when the type of the partition table change is that the System partition is reduced, the userdata partition is increased, the userdata partition address is shifted forward, and the upgrading sequence is positive;
s103, according to the upgrading sequence, the step of migrating the data in the source partition table to the new partition table after processing the data according to a preset rule comprises the following steps:
the data in other partitions are upgraded in the positive sequence, and the data are written into the corresponding partitions of the new partition table correspondingly;
and migrating the data in the userdata partition in the source partition table to the userdata partition in the new partition table according to a third preset sub-rule.
The step of migrating the data in the userdata partition in the source partition table to the userdata partition in the new partition table according to the third preset sub-rule includes:
acquiring each data block of a userdata partition in an upgrade package; dividing the data blocks according to the residual space of the userdata partition, numbering each data block from 0 to N in sequence, wherein the difference value between the head address of the userdata partition in the new partition table and the head address of the userdata partition in the source partition table is-d, and each data block is based on the offset of the head address of the userdata partition in the new partition table from 0-d to N, wherein b is the size of each data block, and N is greater than 0;
the positive sequence migrates the data of each data block to the userdata partition of the new partition table, and specifically comprises the following steps: obtaining data of a data partition with the number of 0, backing up the data into an idle space of a userdata partition, and writing the data of the data partition into a storage area with the head address of 0-d and the tail address of 1*b-d of the userdata partition in a new partition table; and acquiring the data of the data block with the number of 1, and repeating the steps until the migration of the data block with the number of N to the userdata partition of the new partition table is completed.
Taking a newly added partition as an example, inserting the newly added partition before a system partition, shifting the system partition backwards, and shrinking a userdata partition;
the preparation work before upgrading comprises two parts of making a packet and partitioning data of a userdata partition:
the method comprises the steps of adjusting the upgrading sequence of an upgrading script when making a package, wherein the upgrading sequence specifically comprises the steps of firstly migrating userdata partition data, secondly upgrading a system partition in reverse order, writing in newly added partition content, upgrading other partitions according to the original mode, and putting partition tables before and after upgrading into an upgrading package;
the data partitioning is mainly to acquire the space occupation condition of the userdata partition, determine the size of the data partitioning according to the space occupation condition, for example, the residual space is larger than 1.5G, partition the data with the size of 1G, if the residual space is smaller than 1.5G, partition the data with the size of 50% of the residual space, and write the data into a data partitioning table, wherein the table can be accessed by an upgrade program in the upgrade process.
The specific upgrading process is as follows:
the first step: judging whether the userdata partition has a residual space or not, if yes, recording the residual space, and if full, prompting a user to release the space, otherwise, updating the space;
and a second step of: under the condition that the userdata partition has a residual space, data in the userdata partition is subjected to data blocking;
and a third step of: restarting to enter recovery to start upgrading, and firstly migrating data in a userdata partition;
fourth step: upgrading the system data according to the system map, the system transfer list and the first address offset, and writing the upgraded data into a new address in a new partition table;
fifth step: writing the content of the newly added partition;
sixth step: other partitions are upgraded.
Through implementation of the embodiment, the upgrading sequence of upgrading the data of each partition determined according to the type of the partition table change comprises a positive sequence and a reverse sequence, the data in the source partition table is upgraded according to the upgrading sequence, conversion of the data of the source partition table and the new partition table is realized by using a reverse sequence or a positive sequence moving mode, full-disk backup of the data is not needed, the requirement on the cache space in the moving process is reduced, the data which are not upgraded or not moved is not damaged, the processed data are occupied in time, the limited space is fully utilized, the backup recovery efficiency is also improved, the time required by the upgrading process is reduced, and the upgrading success rate is improved.
Example two
Referring to fig. 5, fig. 5 is a schematic diagram of a system upgrade apparatus provided in the present embodiment, where the system upgrade apparatus includes: an acquisition module 501, a parsing module 502, and an upgrade module 503, wherein,
an obtaining module 501, configured to obtain an upgrade package;
the analysis module 502 is configured to analyze an upgrade order when the data of each partition is upgraded from the upgrade package, where the upgrade order is determined according to a type to which the partition table change belongs, and the upgrade order includes a positive order and a reverse order;
the number of different project partitions is different, but the main partitions and their arrangement order are consistent, for example, the system includes sbl partition, rpm partition, modem partition, boot partition, recovery partition, tz partition, system partition, userdata partition and is arranged in this order. At this time, the positive sequence upgrade is to upgrade the following partitions in sequence: sbl1 partition, rpm partition, modem partition, boot partition, recovery partition, tz partition, system partition, userdata partition. The reverse upgrade is to upgrade the following partitions in sequence: userdata partition, system partition, tz partition, recovery partition, boot partition, modem partition, rpm partition, sbl partition.
The types to which the partition table changes belong include newly added partition, system partition expansion and system partition contraction;
for the case of a newly added partition, in addition to the user data partition size change, a change in the system partition head address is involved;
for the conditions of system partition expansion and system partition shrinkage, only the problem of user data preservation after the user data partition size is changed needs to be considered;
and the upgrading module 503 is configured to process the data in the source partition table according to a preset rule and migrate the processed data to the new partition table according to the upgrading sequence.
In one embodiment, when the partition table change belongs to a new partition type, the new partition is inserted before the system partition, the head address of the system partition is changed, the whole system partition is shifted backwards, the userdata partition is contracted, and the upgrading sequence is in a reverse order;
the upgrade module 503 is configured to migrate data in the userdata partition in the source partition table to a userdata partition in the new partition table according to a first preset sub-rule;
updating the data in the system partition according to a second preset sub-rule, and writing the data into the system partition of the new partition table;
writing the corresponding data in the source partition table into a new partition of the new partition table;
updating the data in other partitions in reverse order, and correspondingly writing the data into the corresponding partitions of the new partition table;
other partitions are upgraded, and the head addresses of the partitions are unchanged, so that the upgrading process is similar to the original process, and other partition upgrades are consistent with the existing mode.
For example, the source partition table contains sbl partitions, rpm partitions, modem partitions, boot partitions, recovery partitions, tz partitions, system partitions, and userdata partitions, and is arranged in this order, and when a new partition table is inserted before a system partition, data in the userdata partitions, the system partitions, tz partitions, recovery partitions, boot partitions, modem partitions, rpm partitions, and sbl1 partitions in the source partition table are sequentially processed during reverse upgrade.
In one embodiment, when the type of the partition table change is System partition expansion, the userdata partition is reduced, the userdata partition address is offset backwards, and the upgrading sequence is reverse;
for System partition expansion, the userdata partition is reduced, the head address of the userdata partition is increased, the whole data area moves backwards, and the core writes by using the reverse order of the data partition, so that the un-moved data is not damaged;
the upgrade module 503 is configured to migrate data in the userdata partition in the source partition table to a userdata partition in the new partition table according to a first preset sub-rule;
updating the data in other partitions in reverse order, and correspondingly writing the data into the corresponding partitions of the new partition table;
after data in the userdata partition is migrated, the system partition and the partition before the system partition are upgraded, and the upgrading process is similar to the original process as the head addresses of the partitions are unchanged, so that the system partition and the previous partition are upgraded in a consistent manner.
Wherein, the migration of the data in the user data partition in the source partition table to the user data partition in the new partition table by the upgrade module 503 according to the first preset sub-rule includes:
acquiring each data block of a userdata partition in an upgrade package; dividing the data blocks according to the residual space of the userdata partition, numbering each data block from 0 to M in sequence, wherein the difference value between the head address of the userdata partition in the new partition table and the head address of the userdata partition in the source partition table is a, each data block is 0+a to Mxc+a based on the offset of the head address of the userdata partition in the new partition table, wherein c is the size of each data block, and M is greater than 0;
migrating the data of each data block to a userdata partition of a new partition table in reverse order, wherein the method specifically comprises the following steps of: the method comprises the steps of obtaining data of a data partition with the number M, backing up the data to an idle space of a userdata partition, wherein the backup process is to prevent the data from being unable to be recovered after upgrading interruption; since the current projects all support encryption of userdata, the last 16K of the stored secret key is ensured not to move and not to be covered; writing the data of the data block into a storage area with the head address of M+c+a and the tail address of (M+1) c+a of a userdata partition in a new partition table; and acquiring the data of the data block with the number M-1, and repeating the steps until the data of the data block with the number 0 is migrated to the userdata partition of the new partition table.
The data partitioning is mainly to acquire the space occupation condition of the userdata partition, determine the size of the data partitioning according to the space occupation condition, for example, the residual space is larger than 1.5G, partition the data with the size of 1G, if the residual space is smaller than 1.5G, partition the data with the size of 50% of the residual space, and write the data into a data partitioning table, wherein the table can be accessed by an upgrade program in the upgrade process.
For example, referring to fig. 2, fig. 2 is a schematic diagram of absolute address variation of data in each partition according to the present embodiment; in fig. 2, the first address of the sbl partition in the source partition table is 0, and the last address is 100; the head address of other partitions in the source partition table is 100, and the tail address is 200; the first address of the tz partition in the source partition table is 200, and the last address is 300; the head address of the system partition in the source partition table is 300, and the tail address is 500; the head address of the userdata partition in the source partition table is 500;
a partition newpartition is added before the system partition, the head address of the sbl partition in the new partition table is 0, and the tail address is 100; the head address of other partitions in the new partition table is 100, and the tail address is 200; the first address of the tz partition in the new partition table is 200, and the last address is 300; the head address of the newpartition partition in the new partition table is 300, and the tail address is 400; the head address of the system partition in the new partition table is 400, and the tail address is 600; the head address of the userdata partition in the new partition table is 600.
Referring to fig. 3, fig. 3 is a schematic diagram illustrating a relative address change of data in a userdata partition according to the present embodiment; in FIG. 3, the userdata partition in the source partition table contains data chunks numbered 0, with a head address of 0 and a tail address of c; the data block with the number of 1 is also contained, the head address of the data block is c, and the tail address of the data block is 2c; the method also comprises a data block with the number of 2, wherein the head address of the data block is 2c, and the tail address of the data block is 3c; also contains free space, whose head address is 3c;
the difference value between the head address of the userdata partition in the new partition table and the head address of the userdata partition in the source partition table is a, wherein a=100; the new partition table contains data blocks with the number of 0, the head address of the data blocks is a, and the tail address of the data blocks is c+a; the data block with the number of 1 is also contained, the head address of the data block is c+a, and the tail address of the data block is 2c+a; the data block with the number of 2 is also contained, the head address of the data block is 2c+a, and the tail address of the data block is 3c+a; also included is free space, whose head address is 3c+a.
Wherein, the updating module 503 updates the data in the system partition according to the second preset sub-rule, and writes the data into the system partition of the new partition table, which includes:
acquiring each data block of a system partition in an upgrade package; numbering each data block from 1 to P in sequence, wherein the difference value between the head address of the system partition in the new partition table and the head address of the system partition in the source partition table is e, and P is greater than 1;
acquiring a head address A and a tail address B of a last data block number P of a system partition, merging patches into the data block, and writing the merged data of the data block into positions A+e to B+e of the system partition in a new partition table; and acquiring the head address and the tail address of the last data partition of the system partition number P, and repeating the steps until the data of the data partition number 1 is written into the system partition of the new partition table.
Referring to FIG. 4, FIG. 4 is a schematic diagram showing the relative address change of data in a system partition according to the present embodiment; in FIG. 4, the system partition in the source partition table contains data blocks numbered 1, 2, and 3 and a free space data block, with the head address of the data block numbered 1 being 0; the tail address of the data block with the number of 2 is A; the head address of the data block with the number of 3 is A, and the tail address is B; the head address of the free space data block is B;
the difference between the first address of the system partition in the new partition table and the first address of the system partition in the source partition table is e, wherein e=100; the new partition table contains a data partition with the number of 1, and the head address of the data partition is e; the data block with the number of 2 is also contained, and the tail address of the data block is A+e; the data block with the number of 3 is also contained, the head address of the data block is A+e, and the tail address of the data block is B+e; also included is free space, whose head address is b+e.
In the same item, a=e.
Aiming at the situation of a newly added partition, the existing block upgrading technology is needed to be utilized, the block technology is not based on files in a file system any more, differential upgrading is carried out by utilizing the space occupied by the files, for example, the space occupied by one file is from an address A to an address B, data between the address A and the address B are directly read during upgrading, and the data are written back to the address A to the address B after patching. The difference process is to compare the address spaces and generate patch data, and generate an address space list system.transfer.list corresponding to the patch, and support the system upgrade project to carry system map files in the compiled version, and record the address spaces corresponding to all files in the system partition.
In this scheme, the contents of the system map and the system transfer list are ordered when making the upgrade package, and are arranged in a manner of from big to small in the first address, that is, the upgrade is performed sequentially from the partition last, so that the data which is not upgraded and not offset is kept. Setting the difference value between the first address of the new partition table system partition and the first address of the source partition table system partition as e, firstly acquiring data from the tail address A of the second file to the tail address B of the first file according to the system map file (the address space of the two files is not necessarily continuous), merging the patch into the data block if the address of the system transfer list is between A and B, writing the data block into the space between A+e and B+e, skipping the patching step if the address of the first patch is smaller than A, copying into the space between A+e and B+e, sequentially executing the steps, and finally moving the data block containing partition head information backward by e.
In one embodiment, when the type of the partition table change is that the System partition is reduced, the userdata partition is increased, the userdata partition address is shifted forward, and the upgrading sequence is positive;
the upgrade module 503 is used for forward upgrading the data in other partitions and writing the data into the corresponding partitions of the new partition table correspondingly;
and migrating the data in the userdata partition in the source partition table to the userdata partition in the new partition table according to a third preset sub-rule.
The step of migrating the data in the userdata partition in the source partition table to the userdata partition in the new partition table according to the third preset sub-rule includes:
acquiring each data block of a userdata partition in an upgrade package; dividing the data blocks according to the residual space of the userdata partition, numbering each data block from 0 to N in sequence, wherein the difference value between the head address of the userdata partition in the new partition table and the head address of the userdata partition in the source partition table is-d, and each data block is based on the offset of the head address of the userdata partition in the new partition table from 0-d to N, wherein b is the size of each data block, and N is greater than 0;
the positive sequence migrates the data of each data block to the userdata partition of the new partition table, and specifically comprises the following steps: obtaining data of a data partition with the number of 0, backing up the data into an idle space of a userdata partition, and writing the data of the data partition into a storage area with the head address of 0-d and the tail address of 1*b-d of the userdata partition in a new partition table; and acquiring the data of the data block with the number of 1, and repeating the steps until the migration of the data block with the number of N to the userdata partition of the new partition table is completed.
Taking a newly added partition as an example, inserting the newly added partition before a system partition, shifting the system partition backwards, and shrinking a userdata partition;
the preparation work before upgrading comprises two parts of making a packet and partitioning data of a userdata partition:
the method comprises the steps of adjusting the upgrading sequence of an upgrading script when making a package, wherein the upgrading sequence specifically comprises the steps of firstly migrating userdata partition data, secondly upgrading a system partition in reverse order, writing in newly added partition content, upgrading other partitions according to the original mode, and putting partition tables before and after upgrading into an upgrading package;
the data partitioning is mainly to acquire the space occupation condition of the userdata partition, determine the size of the data partitioning according to the space occupation condition, for example, the residual space is larger than 1.5G, partition the data with the size of 1G, if the residual space is smaller than 1.5G, partition the data with the size of 50% of the residual space, and write the data into a data partitioning table, wherein the table can be accessed by an upgrade program in the upgrade process.
The specific upgrading process is as follows:
the first step: judging whether the userdata partition has a residual space or not, if yes, recording the residual space, and if full, prompting a user to release the space, otherwise, updating the space;
and a second step of: under the condition that the userdata partition has a residual space, data in the userdata partition is subjected to data blocking;
and a third step of: restarting to enter recovery to start upgrading, and firstly migrating data in a userdata partition;
fourth step: upgrading the system data according to the system map, the system transfer list and the first address offset, and writing the upgraded data into a new address in a new partition table;
fifth step: writing the content of the newly added partition;
sixth step: other partitions are upgraded.
Through implementation of the embodiment, the upgrading sequence of upgrading the data of each partition determined according to the type of the partition table change comprises a positive sequence and a reverse sequence, the data in the source partition table is upgraded according to the upgrading sequence, conversion of the data of the source partition table and the new partition table is realized by using a reverse sequence or a positive sequence moving mode, full-disk backup of the data is not needed, the requirement on the cache space in the moving process is reduced, the data which are not upgraded or not moved is not damaged, the processed data are occupied in time, the limited space is fully utilized, the backup recovery efficiency is also improved, the time required by the upgrading process is reduced, and the upgrading success rate is improved.
It will be appreciated by those skilled in the art that the modules or steps of the embodiments of the invention described above may be implemented in a general purpose computing device, they may be centralized on a single computing device, or distributed over a network of computing devices, or they may alternatively be implemented in program code executable by computing devices, such that they may be stored in a storage medium (ROM/RAM, magnetic or optical disk) for execution by computing devices and, in some cases, the steps shown or described may be performed in a different order than what is shown or described herein, or they may be separately manufactured as individual integrated circuit modules, or a plurality of modules or steps in them may be manufactured as a single integrated circuit module. Therefore, the present invention is not limited to any specific combination of hardware and software.
The foregoing is a further detailed description of embodiments of the invention in connection with the specific embodiments, and it is not intended that the invention be limited to the specific embodiments described. It will be apparent to those skilled in the art that several simple deductions or substitutions may be made without departing from the spirit of the invention, and these should be considered to be within the scope of the invention.
Claims (8)
1. A system upgrade method, comprising:
acquiring an upgrade package;
analyzing an upgrading sequence when the data of each partition are upgraded from the upgrading packet, wherein the upgrading sequence is determined according to the type of the partition table change, and comprises a positive sequence and a reverse sequence;
according to the upgrading sequence, the data in the source partition table are processed according to a preset rule and then are transferred to a new partition table;
when the type of the partition table change is a newly added partition, the newly added partition is inserted before the system partition, the system partition shifts backwards, the user data partition is reduced, and the upgrading sequence is in a reverse order;
according to the upgrading sequence, the step of migrating the data in the source partition table to the new partition table after processing the data according to a preset rule comprises the following steps:
migrating data in the user data partition in the source partition table to the user data partition in the new partition table according to a first preset sub-rule;
updating data in the system partition according to a second preset sub-rule, and writing the data into the system partition of the new partition table;
writing the corresponding data in the source partition table into a new partition of the new partition table;
and then updating the data in other partitions in reverse order, and correspondingly writing the data into the corresponding partitions of the new partition table.
2. The system upgrade method of claim 1, wherein when the partition table change belongs to a type of system partition expansion, the user data partition is reduced, the user data partition addresses are shifted backward, and the upgrade order is a reverse order;
according to the upgrading sequence, the step of migrating the data in the source partition table to the new partition table after processing the data according to a preset rule comprises the following steps:
migrating data in the user data partition in the source partition table to the user data partition in the new partition table according to a first preset sub-rule;
and then updating the data in other partitions in reverse order, and correspondingly writing the data into the corresponding partitions of the new partition table.
3. The system upgrade method of claim 1, wherein when the partition table change belongs to a type of system partition shrink, the user data partition is increased, the user data partition addresses are shifted forward, and the upgrade order is positive;
according to the upgrading sequence, the step of migrating the data in the source partition table to the new partition table after processing the data according to a preset rule comprises the following steps:
the data in other partitions are upgraded in the positive sequence, and the data are written into the corresponding partitions of the new partition table correspondingly;
and migrating the data in the user data partition in the source partition table to the user data partition in the new partition table according to a third preset sub-rule.
4. The system upgrade method of claim 1 or 2, wherein said migrating data in user data partitions in the source partition table to user data partitions in the new partition table according to the first preset sub-rule comprises:
acquiring each data partition of the user data partition in the upgrade package; dividing the data blocks according to the residual space of the user data partition, numbering each data block from 0 to M in sequence, wherein the difference value between the head address of the user data partition in the new partition table and the head address of the user data partition in the source partition table is a, and each data block is based on the offset of the head address of the user data partition in the new partition table and is 0+a to Mxc+a, wherein c is the size of each data block, and M is greater than 0;
and (3) transferring the data of each data block to a user data partition of a new partition table in reverse order, wherein the method specifically comprises the following steps of: obtaining data of a data partition with the number of M, backing up the data to an idle space of a user data partition, and writing the data of the data partition into a storage area with the head address of M+c and the tail address of (M+1) c+a of the user data partition in a new partition table; and acquiring the data of the data block with the number M-1, and repeating the steps until the data of the data block with the number 0 is migrated to the user data partition of the new partition table.
5. The system upgrade method of claim 1, wherein upgrading the data in the system partition according to the second preset sub-rule and writing into the system partition of the new partition table comprises:
acquiring each data block of the system partition in the upgrade package; numbering each data block from 1 to P in sequence, wherein the difference value between the head address of the system partition in the new partition table and the head address of the system partition in the source partition table is e, and P is more than 1;
acquiring a head address A and a tail address B of a last data block number P of a system partition, merging patches into the data blocks, and writing the merged data of the data blocks into positions A+e to B+e of the system partition in a new partition table; and then acquiring the head address and the tail address of the last data block of the system partition number P, and repeating the steps until the data of the data block with the number 1 is written into the system partition of the new partition table.
6. A system upgrade apparatus, comprising:
the acquisition module is used for acquiring the upgrade package;
the analysis module is used for analyzing the upgrading sequence of the data of each partition when the data of each partition is upgraded from the upgrading packet, the upgrading sequence is determined according to the type of the partition table change, and the upgrading sequence comprises a positive sequence and a reverse sequence;
the upgrading module is used for processing the data in the source partition table according to a preset rule and then migrating the processed data into a new partition table according to the upgrading sequence;
when the type of the partition table change is a newly added partition, the newly added partition is inserted before the system partition, the system partition shifts backwards, the user data partition is reduced, and the upgrading sequence is in a reverse order;
the upgrading module is used for migrating the data in the user data partition in the source partition table to the user data partition in the new partition table according to a first preset sub-rule;
updating data in the system partition according to a second preset sub-rule, and writing the data into the system partition of the new partition table;
writing the corresponding data in the source partition table into a new partition of the new partition table;
and then updating the data in other partitions in reverse order, and correspondingly writing the data into the corresponding partitions of the new partition table.
7. The system upgrade apparatus of claim 6, wherein when the partition table change belongs to a type of system partition expansion, the user data partition is contracted, the user data partition addresses are shifted backward, and the upgrade order is a reverse order;
the upgrading module is used for migrating the data in the user data partition in the source partition table to the user data partition in the new partition table according to a first preset sub-rule;
and then updating the data in other partitions in reverse order, and correspondingly writing the data into the corresponding partitions of the new partition table.
8. The system upgrade apparatus of claim 6, wherein when the partition table change belongs to a type of system partition shrink, the user data partition is increased, the user data partition addresses are shifted forward, and the upgrade order is positive;
the upgrading module is used for forward upgrading the data in other partitions and correspondingly writing the data into the corresponding partitions of the new partition table;
and migrating the data in the user data partition in the source partition table to the user data partition in the new partition table according to a third preset sub-rule.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710584511.6A CN109298873B (en) | 2017-07-18 | 2017-07-18 | System upgrading method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710584511.6A CN109298873B (en) | 2017-07-18 | 2017-07-18 | System upgrading method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109298873A CN109298873A (en) | 2019-02-01 |
CN109298873B true CN109298873B (en) | 2023-05-09 |
Family
ID=65167348
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710584511.6A Active CN109298873B (en) | 2017-07-18 | 2017-07-18 | System upgrading method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109298873B (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110569058B (en) * | 2019-09-09 | 2023-06-30 | Oppo(重庆)智能科技有限公司 | System upgrading method, device, terminal and computer readable storage medium |
CN110781030A (en) * | 2019-09-09 | 2020-02-11 | 晶晨半导体(深圳)有限公司 | Backup method for user data in android system upgrading process |
CN111124451A (en) * | 2019-12-24 | 2020-05-08 | 山东有人信息技术有限公司 | Distributed backup upgrading method |
CN112162773B (en) * | 2020-10-10 | 2022-09-02 | 北京紫光展锐通信技术有限公司 | Differential upgrading method and device, storage medium and terminal |
CN114356386A (en) * | 2021-12-28 | 2022-04-15 | 杭州涂鸦信息技术有限公司 | Block differential upgrading method, terminal equipment and computer readable storage medium |
CN114637523B (en) * | 2022-02-14 | 2024-10-18 | 北京鸿合爱学教育科技有限公司 | Firmware upgrade file processing method, device, server and storage medium |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5555371A (en) * | 1992-12-17 | 1996-09-10 | International Business Machines Corporation | Data backup copying with delayed directory updating and reduced numbers of DASD accesses at a back up site using a log structured array data storage |
CN103473099A (en) * | 2013-09-13 | 2013-12-25 | 惠州Tcl移动通信有限公司 | Software upgrading method and system for mobile terminal |
CN104932909A (en) * | 2014-03-17 | 2015-09-23 | 中兴通讯股份有限公司 | Terminal software upgrading method and device |
CN106445616A (en) * | 2016-10-12 | 2017-02-22 | 北京元心科技有限公司 | Method and device for upgrading terminal equipment from multiple systems to single system |
CN106484448A (en) * | 2015-08-28 | 2017-03-08 | 青岛海信移动通信技术股份有限公司 | A kind of method for upgrading software and device |
-
2017
- 2017-07-18 CN CN201710584511.6A patent/CN109298873B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5555371A (en) * | 1992-12-17 | 1996-09-10 | International Business Machines Corporation | Data backup copying with delayed directory updating and reduced numbers of DASD accesses at a back up site using a log structured array data storage |
CN103473099A (en) * | 2013-09-13 | 2013-12-25 | 惠州Tcl移动通信有限公司 | Software upgrading method and system for mobile terminal |
CN104932909A (en) * | 2014-03-17 | 2015-09-23 | 中兴通讯股份有限公司 | Terminal software upgrading method and device |
CN106484448A (en) * | 2015-08-28 | 2017-03-08 | 青岛海信移动通信技术股份有限公司 | A kind of method for upgrading software and device |
CN106445616A (en) * | 2016-10-12 | 2017-02-22 | 北京元心科技有限公司 | Method and device for upgrading terminal equipment from multiple systems to single system |
Non-Patent Citations (1)
Title |
---|
《Android Recovery系统分析2----升级包目录结构分析》;lifuxianoa;《https://blog.csdn.net/lifuxianoa/article/details/8729929》;第1-5页 * |
Also Published As
Publication number | Publication date |
---|---|
CN109298873A (en) | 2019-02-01 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109298873B (en) | System upgrading method and device | |
US9778926B2 (en) | Minimizing image copying during partition updates | |
CN103970585B (en) | Create the method and device of virtual machine | |
US8060703B1 (en) | Techniques for allocating/reducing storage required for one or more virtual machines | |
US8140537B2 (en) | Block level tagging with file level information | |
US20080172426A1 (en) | Storage system format for transaction safe file system | |
US10120595B2 (en) | Optimizing backup of whitelisted files | |
US11289115B1 (en) | Copying a storage tape | |
CN107665219B (en) | Log management method and device | |
CN105677736A (en) | Method and apparatus for increasing and deleting server nodes | |
CN107798063B (en) | Snapshot processing method and snapshot processing device | |
US20150286653A1 (en) | Data Synchronization Method and Data Synchronization System for Multi-Level Associative Storage Architecture, and Storage Medium | |
CN112000426B (en) | Data processing method and device | |
CN105867903A (en) | Method and device or splitting code library | |
WO2019041891A1 (en) | Method and device for generating upgrade package | |
CN110209420A (en) | A kind of method and device updating bootstrap loader | |
EP2669806B1 (en) | Storage system | |
US11726743B2 (en) | Merging multiple sorted lists in a distributed computing system | |
CN110597568B (en) | Plug-in deployment method, system and terminal | |
US20120254138A1 (en) | Database management method | |
US9588884B2 (en) | Systems and methods for in-place reorganization of device storage | |
CN111158858A (en) | Cloning method and device of virtual machine and computer readable storage medium | |
CN111090701B (en) | Service request processing method, device, readable storage medium and computer equipment | |
US11163642B2 (en) | Methods, devices and computer readable medium for managing a redundant array of independent disks | |
CN106649669A (en) | Data storage method and system based on remote dictionary server |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |