Operating system replacement method and device, equipment, storage medium and product

By obtaining the hash list and obtaining the backup files and core files from the virtual hash storage device, efficient replacement of the operating system is achieved, which solves the problems of insufficient efficiency of operating system replacement and difficulty in rollback in the existing technology.

CN118796256APending Publication Date: 2024-10-18CHINA MOBILE GROUP ZHEJIANG +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410244425.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-04
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

The existing technology lacks an efficient operating system replacement method, which makes system rollback difficult, especially when the new operating system is incompatible with the existing environment.

Method used

By obtaining the path hash list, file hash list and basic file hash list, the operating system backup files and core files are obtained from the virtual hash storage device, and replacement processing is performed to realize the rollback of the operating system.

Benefits of technology

It improves the efficiency and capacity utilization of operating system replacement, reduces backup time and storage requirements, and solves the problem of difficulty in system rollback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796256A_ABST
    Figure CN118796256A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and provides a replacement method and device of an operating system, equipment, a storage medium and a product. The method comprises the steps of obtaining a path hash list, a file hash list and a basic file hash list of a to-be-replaced operating system in response to a system rollback instruction; based on the path hash list and the file hash list, obtaining an operating system backup file of the operating system to be replaced from the virtual hash storage device; based on the basic file hash list, obtaining an operating system core file of the operating system to be replaced from the virtual hash storage device; and replacing the to-be-replaced operating system based on the operating system backup file and the operating system core file. Through the mode, the operating system backup file and the operating system core file of the to-be-replaced operating system are obtained based on the path hash list, the file hash list and the basic file hash list, and the to-be-replaced operating system is replaced, so that rollback replacement of the operating system is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment, storage medium and product for replacing an operating system. Background Art

[0002] The server operating system is the system software responsible for coordinating, managing and controlling computer hardware resources and software resources. It is one of the core basic products of the IT system. The security and stability of the server operating system are of great significance to the normal operation of the IT system and to ensuring the security of network information.

[0003] The security of the operating system is of vital importance to both individual and corporate users. Some operating systems may have security vulnerabilities and are vulnerable to malicious attacks. By replacing the operating system with a new version or another more secure operating system, the overall security of the system can be improved. Since the new operating system may be incompatible with the existing operating environment, making it difficult for the operating system to run normally, a system rollback is required. System rollback refers to restoring the operating system from the current version to the previous version, that is, replacing the new operating system with the previously backed-up operating system.

[0004] However, there is currently no efficient method for replacing operating systems. Summary of the invention

[0005] The embodiments of the present application provide a method, apparatus, device, storage medium and product for replacing an operating system, so as to solve the technical problem that there is no efficient operating system replacement method in the prior art.

[0006] In a first aspect, an embodiment of the present application provides a method for replacing an operating system, comprising: in response to a system rollback instruction, obtaining a path hash list, a file hash list, and a basic file hash list of the operating system to be replaced; the path hash list is used to identify the file storage path of the operating system backup file, the file hash list is used to identify the operating system backup file, and the basic file hash list is used to identify the operating system core file, which is a file for controlling and managing the operation of the operating system; based on the path hash list and the file hash list, obtaining the operating system backup file of the operating system to be replaced from a virtual hash storage device; based on the basic file hash list, obtaining the operating system core file of the operating system to be replaced from the virtual hash storage device; based on the operating system backup file and the operating system core file, replacing the operating system to be replaced.

[0007] In one embodiment, the number of files of the operating system core file is at least one; in response to the system rollback instruction, before obtaining the path hash list and file hash list of the operating system to be replaced, it also includes: recursively traversing the operating system core files; determining the file hash value corresponding to each operating system core file; generating a basic file hash list based on the file hash value corresponding to each operating system core file; the basic file hash list includes the file hash value corresponding to each operating system core file; and storing the basic file hash list and each operating system core file in a virtual hash storage device.

[0008] In one embodiment, the operating system backup file includes multiple operating system non-core files; in response to the system rollback instruction, before obtaining the path hash list, file hash list and basic file hash list of the operating system to be replaced, it also includes: traversing the operating system non-core files; determining the file hash value corresponding to each operating system non-core file; based on the file storage path of each operating system non-core file and the file hash value corresponding to each operating system non-core file, determining the path hash value corresponding to each operating system non-core file; based on the file hash value corresponding to each operating system non-core file, generating a file hash list; the file hash list includes the file hash value corresponding to each operating system non-core file; based on the path hash value corresponding to each operating system non-core file, generating a path hash list; the path hash list includes the path hash value corresponding to each operating system non-core file; storing the path hash list and the file hash list to a virtual hash storage device.

[0009] In one embodiment, the operating system to be replaced is a virtual operating system; based on the operating system backup file and the operating system core file, the operating system to be replaced is replaced, including: mounting a virtual disk; storing the operating system backup file and the operating system core file to the virtual disk; mounting the virtual disk storing the operating system backup file and the operating system core file to the operating system to be replaced; replacing the operating system files of the operating system to be replaced with the operating system backup file and the operating system core file stored in the virtual disk, and completing the replacement process of the operating system to be replaced.

[0010] In one embodiment, the operating system to be replaced is a bare metal operating system; based on the operating system backup file and the operating system core file, the operating system to be replaced is replaced, including: preparing an ISO image file based on the operating system backup file and the operating system core file; the ISO image file contains the operating system backup file and the operating system core file; mounting the ISO image file to the operating system to be replaced; replacing the operating system files of the operating system to be replaced with the operating system backup files and the operating system core files stored in the ISO image file, and completing the replacement process of the operating system to be replaced.

[0011] In one embodiment, before performing replacement processing on the operating system to be replaced based on the operating system backup file and the operating system core file, the method further includes: compressing the operating system backup file and the operating system core file.

[0012] In a second aspect, an embodiment of the present application provides an operating system replacement device, including: a hash list acquisition module, used to respond to a system rollback instruction to obtain a path hash list, a file hash list and a basic file hash list of the operating system to be replaced; the path hash list is used to identify the file storage path of the operating system backup file, the file hash list is used to identify the operating system backup file, and the basic file hash list is used to identify the operating system core file, which is a file for controlling and managing the operation of the operating system; a backup file acquisition module, used to obtain the operating system backup file of the operating system to be replaced from a virtual hash storage device based on the path hash list and the file hash list; a core file acquisition module, used to obtain the operating system core file of the operating system to be replaced from the virtual hash storage device based on the basic file hash list; a replacement module, used to replace the operating system to be replaced based on the operating system backup file and the operating system core file.

[0013] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a method for replacing an operating system as described above is implemented.

[0014] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for replacing an operating system as described in any one of the above.

[0015] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements a method for replacing an operating system as described in any one of the above.

[0016] The replacement method, device, equipment, storage medium and product of the operating system provided in the embodiments of the present application, in response to the system rollback instruction, obtain the path hash list, file hash list and basic file hash list of the operating system to be replaced; the path hash list is used to identify the file storage path of the operating system backup file, the file hash list is used to identify the operating system backup file, and the basic file hash list is used to identify the operating system core file, which is a file for controlling and managing the operation of the operating system; based on the path hash list and the file hash list, the operating system backup file of the operating system to be replaced is obtained from the virtual hash storage device; based on the basic file hash list, the operating system core file of the operating system to be replaced is obtained from the virtual hash storage device; based on the operating system backup file and the operating system core file, the operating system to be replaced is replaced. In the above manner, the operating system backup file and the operating system core file of the operating system to be replaced are obtained based on the path hash list, the file hash list and the basic file hash list, and the operating system to be replaced is replaced based on the operating system backup file and the operating system core file, thereby realizing the rollback replacement of the operating system. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0018] Figure 1 It is a flowchart of a method for replacing an operating system provided in an embodiment of the present application;

[0019] Figure 2 It is a schematic diagram of large-scale operating system file backup provided by an embodiment of the present application;

[0020] Figure 3 It is a schematic diagram of a single operating system file backup process provided by an embodiment of the present application;

[0021] Figure 4 is a schematic diagram of a process of replacing a virtual operating system provided in an embodiment of the present application;

[0022] Figure 5 It is a schematic diagram of a process of replacing a bare metal operating system provided in an embodiment of the present application;

[0023] Figure 6 It is a structural schematic diagram of a replacement device for an operating system provided in an embodiment of the present application;

[0024] Figure 7It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0026] See also Figure 1 , Figure 1 1 is a flowchart of a method for replacing an operating system provided in an embodiment of the present application. In this embodiment, the method for replacing an operating system is applied to a hash file control component, which can be run on a device where an operating system is installed, or can be used as an external component connecting a virtual hash storage device to a device where an operating system is located. The method for replacing an operating system includes steps S110 to S140, and each step is as follows:

[0027] S110: In response to the system rollback instruction, a path hash list, a file hash list, and a basic file hash list of the operating system to be replaced are obtained.

[0028] The path hash list is used to identify the file storage path of the operating system backup file, the file hash list is used to identify the operating system backup file, and the basic file hash list is used to identify the operating system core file, which is a file that controls and manages the operation of the operating system.

[0029] Generally, the operating system is stored in the form of files and saved as operating system files. The operating system files include operating system core files and operating system non-core files.

[0030] Among them, the operating system core files are files that control and manage the operation of the operating system.

[0031] For example, the operating system core files of the Linux operating system are saved in the core root directory of the operating system files. The core root directory includes but is not limited to / etc, / usr, / var, / run, / boot, etc. The files saved in the core root directory are the operating system core files.

[0032] For multiple operating systems of the same version, the operating system core files of each operating system are the same, but each operating system may have different personalized configurations for the operating system non-core files. Therefore, the operating system non-core files of each operating system are usually different. During the operating system replacement process, it is necessary to completely replace the operating system based on both the operating system backup files and the operating system core files.

[0033] Therefore, before performing a system rollback, you need to back up the operating system core files and operating system non-core files in advance.

[0034] It can be understood that the operating system core files and the operating system non-core files can be backed up in the virtual hash storage device in advance.

[0035] Optionally, the virtual hash storage device may be an external storage device independent of the device where the operating system is located.

[0036] Optionally, the virtual hash storage device may be a storage device on a device where the operating system is located.

[0037] In this embodiment, there are multiple operating systems to be replaced. When performing large-scale operating system replacement (i.e., rolling back multiple operating systems to be replaced to the operating system before the pre-backup), since the operating system core files of multiple operating systems of the same version are the same, in order to save the storage capacity of the virtual hash storage device and improve the backup efficiency, only one operating system core file can be saved on the virtual hash storage device, and the operating system non-core files of each operating system can be stored separately.

[0038] After saving a copy of the operating system core file on the virtual hash storage device, each operating system only needs to back up the operating system non-core files on the virtual hash storage device to complete the pre-backup of the entire operating system. That is, after saving a copy of the operating system core file on the virtual hash storage device, each operating system actually needs to back up only its own operating system non-core files. Therefore, the operating system non-core files of each operating system can be considered as the operating system backup files of the operating system.

[0039] It should be noted that after a copy of the operating system core file is saved on the virtual hash storage device, each operating system can only back up the parts that are different from other operating systems (ie, operating system non-core files), so this backup method is essentially an incremental backup method.

[0040] When performing large-scale operating system replacement, the incremental backup method can effectively reduce the time required for backup operations, reduce the storage capacity of storage devices, and improve backup efficiency.

[0041] Generally, the backup operation time of the operating system includes file preparation time and backup time. File preparation time is relatively fixed and short, but backup time is greatly affected by the throughput rate of the operating system, so the backup time varies greatly. The calculation formula for backup time is as follows:

[0042] Backup time = backup capacity ÷ throughput rate;

[0043] The throughput rate is restricted by two aspects: one is the maximum storage throughput rate, and the other is the maximum throughput rate of a single disk (the throughput rate of a single disk is limited by the fiber card, network card, local disk properties, etc.).

[0044] In a virtualized environment, the maximum throughput rate of a single disk is lower than the maximum throughput rate of storage.

[0045] When performing large-scale operating system replacement, if the sum of the single-disk throughput rates is greater than the maximum storage throughput rate, the total backup time is calculated as follows:

[0046] Total backup time = total backup capacity ÷ storage throughput rate;

[0047] When replacing a single operating system, if the total throughput of a single disk is less than the maximum storage throughput, the total backup time is calculated as follows:

[0048] Total backup time = total backup capacity ÷ single disk throughput rate.

[0049] Here are some examples:

[0050] Example 1: Assuming that the maximum throughput rate of the operating system distributed storage in a virtualized environment is 1GB / s, the maximum throughput rate of a single disk is 200MB / s, and the capacity of an operating system is about 5G, if 100 operating systems are fully backed up at the same time, then without other production business read and write operations, the total throughput rate of the single disk is less than the maximum storage throughput rate, that is,

[0051] 200MB / s×100 (units)=20GB / s;

[0052] 20GB / s>1GB / s;

[0053] Therefore, the total backup time is 5G×100 (units) ÷ 1GB / s = 500 seconds.

[0054] When replacing a single operating system, the backup time of a single operating system is 5G÷200MB / s=25 seconds.

[0055] From Example 1, we can see that when a large-scale operating system replacement is performed, the backup time is 500÷25=20 times the original time.

[0056] Example 2: Assume that the hard disk attribute of the local operating system is SSD, the throughput rate of a single disk is 500MB / s, and the capacity of an operating system is approximately 5G. In the absence of other production business read and write operations, the backup time of a single operating system is 5G ÷ 500MB / s = 10 seconds.

[0057] Assume that the hard disk attribute of the local operating system is SATA, the throughput rate of a single disk is 100M / s, and the capacity of an operating system is approximately 5G. In the absence of other production business read and write operations, the backup time of a single operating system is 5G÷100M / s=50 seconds.

[0058] As can be seen from Example 2, when a single operating system is replaced, the backup time is affected by the hardware of the single disk.

[0059] From the above examples, it can be seen that when performing a large-scale operating system replacement, if a full backup of all operating systems is required (Example 1), the total backup time will be longer than the backup time of a single operating system, and the backup capacity of the storage device will be large. Therefore, when performing a large-scale operating system replacement, in order to reduce backup time and backup capacity, you can use virtual hash storage devices and hash file control components to perform incremental file backups.

[0060] It can be understood that the hash file control component can save the path hash list, file hash list and basic file hash list of the operating system to be replaced; the virtual hash storage device can save the path hash list, file hash list, basic file hash list, as well as the operating system core files and operating system non-core files of the operating system to be replaced.

[0061] Among them, the path hash list is used to identify the file storage path of the operating system backup file, and the file hash list is used to identify the operating system backup file. Based on the path hash list and the file hash list, the corresponding operating system backup file can be searched on the virtual hash storage device.

[0062] The basic file hash list is used to identify the operating system core files. The operating system core files are files that control and manage the operation of the operating system. Based on the basic file hash list, the corresponding operating system core files can be searched on the virtual hash storage device.

[0063] Specifically, there are multiple operating systems to be replaced; for each operating system to be replaced, in response to a system rollback instruction, the hash file control component can obtain a path hash list, a file hash list and a basic file hash list of the operating system to be replaced for the operating system to be replaced.

[0064] S120: Based on the path hash list and the file hash list, obtain the operating system backup file of the operating system to be replaced from the virtual hash storage device.

[0065] Specifically, for each operating system to be replaced, in response to the system rollback instruction, after the hash file control component can obtain the path hash list, file hash list and basic file hash list of the operating system to be replaced, the path hash list and file hash list can be used to search the virtual hash storage device for the operating system backup file corresponding to the operating system to be replaced.

[0066] S130: Based on the basic file hash list, obtain the operating system core file of the operating system to be replaced from the virtual hash storage device.

[0067] Specifically, for each operating system to be replaced, in response to the system rollback instruction, after the hash file control component can obtain the path hash list, file hash list and basic file hash list of the operating system to be replaced, the basic file hash list can be used to search the virtual hash storage device for the operating system core file corresponding to the operating system to be replaced.

[0068] S140: Based on the operating system backup file and the operating system core file, the operating system to be replaced is replaced.

[0069] The operating system replacement method provided in the embodiment of the present application obtains the path hash list, file hash list and basic file hash list of the operating system to be replaced in response to the system rollback instruction; the path hash list is used to identify the file storage path of the operating system backup file, the file hash list is used to identify the operating system backup file, and the basic file hash list is used to identify the operating system core file, which is a file for controlling and managing the operation of the operating system; based on the path hash list and the file hash list, the operating system backup file of the operating system to be replaced is obtained from the virtual hash storage device; based on the basic file hash list, the operating system core file of the operating system to be replaced is obtained from the virtual hash storage device; based on the operating system backup file and the operating system core file, the operating system to be replaced is replaced. In the above manner, the operating system backup file and the operating system core file of the operating system to be replaced are obtained based on the path hash list, the file hash list and the basic file hash list, and the operating system to be replaced is replaced based on the operating system backup file and the operating system core file, thereby realizing the rollback replacement of the operating system.

[0070] In some embodiments, the number of files of the operating system core file is at least one.

[0071] In response to a system rollback instruction, before obtaining the path hash list and file hash list of the operating system to be replaced, it also includes: recursively traversing the operating system core files; determining the file hash value corresponding to each operating system core file; generating a basic file hash list based on the file hash value corresponding to each operating system core file; the basic file hash list includes the file hash value corresponding to each operating system core file; and storing the basic file hash list and each operating system core file in a virtual hash storage device.

[0072] Before rolling back the system, you need to back up the operating system core files and operating system non-core files.

[0073] See also Figure 2 , Figure 2 It is a schematic diagram of large-scale operating system file backup provided in an embodiment of the present application.

[0074] As shown in Figure 2, the virtual hash storage device can store operating system files of multiple versions of operating systems (for example, including operating system files of operating system version X and operating system files of operating system version Y). For each version of the operating system, the basic file hash list of the operating system version and the corresponding operating system core file (i.e., operating system basic file) are retained.

[0075] It can be understood that the virtual hash storage device stores the operating system hash list.

[0076] For each version of the operating system, a corresponding operating system hash value may be generated for the version of the operating system, an operating system hash list may be generated based on the operating system hash value corresponding to each version of the operating system, and the operating system hash values ​​may be used to distinguish operating system files of different versions.

[0077] The operating system basic files can be obtained through the first newly installed corresponding version of the operating system, and the corresponding basic file hash list is generated.

[0078] Specifically, there are multiple operating system core files. Before the system rollback, for the operating system that needs to be backed up in advance, all operating system core files of the operating system are recursively traversed to determine the file directory of each operating system core file.

[0079] Furthermore, a file hash value corresponding to each operating system core file is determined.

[0080] Specifically, for each operating system core file, the operating system core file or the file directory of the operating system core file is written into a new file, and a hash value is generated for the new file through hash calculation as the file hash value corresponding to the operating system core file.

[0081] Furthermore, based on the file hash value corresponding to each operating system core file, a basic file hash list is generated.

[0082] The base file hash list contains the file hash value corresponding to each operating system core file.

[0083] Furthermore, the basic file hash list and each operating system core file are sent to the virtual hash storage device for storage.

[0084] Similarly, for each operating system core file, a corresponding path hash value is generated for the operating system core file; and a basic path hash list is generated based on the path hash value corresponding to each operating system core file.

[0085] The base path hash list contains the path hash value corresponding to each operating system core file.

[0086] Optionally, the basic path hash list includes one or more of a path hash value, a file hash value, a full file path, an operating system attribute, a configuration attribute, a persistent attribute, and a custom attribute corresponding to each operating system non-core file.

[0087] Furthermore, the base path hash list is sent to the virtual hash storage device for storage.

[0088] As shown in 2, operating system A, operating system B and operating system C are the same version of operating system, the operating system version is X, and the operating system core files of operating system A, operating system B and operating system C are the same, so only one operating system core file and the basic file hash list corresponding to the operating system core file need to be stored on the virtual hash storage device.

[0089] Optionally, the basic file hash list includes one or more of a file hash value, a full file path, an operating system attribute, a configuration attribute, a persistent attribute, and a custom attribute corresponding to each operating system core file.

[0090] Optionally,

[0091] Optionally, the calculation method of the file hash value includes but is not limited to: MD5 algorithm, SHA-1 algorithm, SHA-256 algorithm, etc.

[0092] The difference between the file hash values ​​generated by different hash value calculation methods is that the length of the check value is different (that is, the collision probability is different), and the calculation speed of different hash value calculation methods is different.

[0093] Optionally, the full file path is the path of the file in the operating system.

[0094] Optionally, the operating system attributes include but are not limited to the operating system version and the like.

[0095] Optionally, the configuration attributes include but are not limited to IP information and the like.

[0096] Optionally, the custom attributes include but are not limited to whether to persist the data, the storage duration, etc.

[0097] In some embodiments, the operating system backup file includes a plurality of operating system non-core files.

[0098] In response to the system rollback instruction, before obtaining the path hash list, file hash list and basic file hash list of the operating system to be replaced, it also includes: traversing the non-core files of the operating system; determining the file hash value corresponding to each non-core file of the operating system; determining the path hash value corresponding to each non-core file of the operating system based on the file storage path of each non-core file of the operating system and the file hash value corresponding to each non-core file of the operating system; generating a file hash list based on the file hash value corresponding to each non-core file of the operating system; the file hash list includes the file hash value corresponding to each non-core file of the operating system; generating a path hash list based on the path hash value corresponding to each non-core file of the operating system; the path hash list includes the path hash value corresponding to each non-core file of the operating system; storing the path hash list and the file hash list to the virtual hash storage device.

[0099] In response to the system rollback instruction, before obtaining the path hash list, the file hash list and the basic file hash list of the operating system to be replaced, the operating system non-core files are traversed.

[0100] Specifically, for each operating system to be replaced, a file list of all RPM software packages installed on the operating system to be replaced is listed, and the full paths of all files of the software packages are obtained one by one, and each operating system non-core file is traversed and searched.

[0101] Furthermore, a file hash value corresponding to each operating system non-core file is determined.

[0102] If it is detected that the path of the RPM software package is a non-core directory, it means that the file saved in the non-core directory is an operating system non-core file, and a corresponding file hash value is generated for the operating system non-core file through hash calculation.

[0103] Traverse and search for each operating system non-core file, and generate a corresponding file hash value for each operating system non-core file through hash calculation.

[0104] Further, based on the file storage path of each operating system non-core file and the file hash value corresponding to each operating system non-core file, a path hash value corresponding to each operating system non-core file is determined.

[0105] Specifically, for each operating system non-core file, a secondary hash calculation is performed on the file storage path of the operating system non-core file and the file hash value corresponding to the operating system non-core file to generate a path hash value corresponding to the operating system non-core file.

[0106] Furthermore, a file hash list is generated based on the file hash value corresponding to each operating system non-core file.

[0107] The file hash list contains the file hash value corresponding to each operating system non-core file.

[0108] Furthermore, a path hash list is generated based on the path hash value corresponding to each operating system non-core file.

[0109] Furthermore, the path hash list includes a path hash value corresponding to each non-core file of the operating system; and the path hash list and the file hash list are stored in a virtual hash storage device.

[0110] Optionally, the file hash list includes one or more of a file hash value, a full file path, an operating system attribute, a configuration attribute, a persistent attribute, and a custom attribute corresponding to each operating system non-core file.

[0111] Optionally, the path hash list includes one or more of a path hash value, a file hash value, a full file path, an operating system attribute, a configuration attribute, a persistent attribute, and a custom attribute corresponding to each operating system non-core file.

[0112] Optionally, the calculation method of the file hash value includes but is not limited to: MD5 algorithm, SHA-1 algorithm, SHA-256 algorithm, etc.

[0113] The difference between the file hash values ​​generated by different hash value calculation methods is that the length of the check value is different (that is, the collision probability is different), and the calculation speed of different hash value calculation methods is different.

[0114] Optionally, the full file path is the path of the file in the operating system.

[0115] Optionally, the operating system attributes include but are not limited to the operating system version and the like.

[0116] Optionally, the configuration attributes include but are not limited to IP information and the like.

[0117] Optionally, the custom attributes include but are not limited to whether to persist the data, the storage duration, etc.

[0118] To more clearly illustrate the process of backing up the operating system based on the hash file control component, operating system A is used as an example for explanation below.

[0119] In the case of large-scale operating system replacement, when operating system A needs to be backed up, a path hash list and a file hash list corresponding to operating system A are first generated.

[0120] See also Figure 3 , Figure 3 It is a flowchart of a single operating system file backup provided in an embodiment of the present application.

[0121] The file control rules of the hash file control component are as follows:

[0122] (1) The path hash list and file hash list corresponding to operating system A are sent to the hash file control component, and the hash file control component performs file comparison based on the path hash list and file hash list.

[0123] It can be understood that, assuming that at least one backup operation has been performed before operating system A performs this backup operation, there may be backed-up files in the hash file control component and the virtual hash storage device, that is, some identical path hash values ​​may already exist in the path hash lists on the hash file control component and the virtual hash storage device, and some identical file hash values ​​may already exist in the file hash lists.

[0124] In order to reduce duplicate backups, it is necessary to perform file comparison based on the path hash list and file hash list to achieve deduplication.

[0125] Specifically, operating system A sends the corresponding path hash list and file hash list generated by this backup operation to the hash file control component, and compares them with the corresponding path hash list and file hash list generated by the hash file control component during the last backup operation.

[0126] If the path hash lists corresponding to the two backup operations contain the same path hash value, it means that the operating system non-core file corresponding to the path hash value has been uploaded. At this time, there is no need to upload the operating system non-core file corresponding to the path hash value to the virtual hash storage device.

[0127] If the corresponding path hash list generated by this backup operation contains a path hash value different from that in the corresponding path hash list generated during the last backup operation, the file hash value and the full file path (ie, the file storage path) are decomposed based on the path hash value.

[0128] The hash file control component further compares the hash file list with the decomposed file hash values; if the same file hash value exists, it means that the file corresponding to the file hash value is the same file stored in a different directory, and it is necessary to add the different path hash value to the corresponding path hash list generated during the last backup operation, but there is no need to upload the file again, because the same file hash value already exists in the corresponding file hash list generated during the last backup operation, indicating that the same file has been stored.

[0129] (2) If the same file hash value does not exist, a file upload message is sent to operating system A.

[0130] (3) After receiving the file upload message, the operational system A uploads the operating system non-core file corresponding to the different file hash values ​​to the virtual hash storage device.

[0131] (4) After the operational system A uploads the operating system non-core file corresponding to the different file hash value to the virtual hash storage device, it uploads a completion message to the hash file control component; after receiving the upload completion message, the hash file control component adds the path hash value corresponding to the operating system non-core file to the corresponding path hash list generated during the last backup operation.

[0132] Optionally, after the backup operation is completed, a use mark is added to the custom attribute of the path hash list, indicating that the path hash list is being used normally and does not need to be cleaned up, thereby completing the backup operation of operating system A.

[0133] It can be understood that after completing the backup operation of operating system A, operating system A can be upgraded and updated; if the updated operating system A is incompatible with the existing operating environment and a system rollback is required, then in response to the system rollback instruction, the replacement of operating system A is completed and operating system A is rolled back to the version backed up this time.

[0134] Optionally, after completing the replacement of operating system A, operating system A sends a replacement completion message to the hash file control component, and the hash file control component can cancel the usage mark added to the custom attribute of the path hash list based on the replacement completion message.

[0135] (5) The hash file control component can further compare the file hash value, operating system attributes, configuration attributes, other custom attributes, etc., and determine whether it is necessary to retain the path hash list and file hash list of operating system A based on the above information (the path hash list and file hash list newly added after the default replacement fallback need to be cleaned up), that is, whether to clean up the file hash value, operating system attributes, configuration attributes, other custom attributes and other related information.

[0136] Optionally, determine whether there are other operating systems using the newly added files of operating system A in this backup operation based on the use mark in the custom attribute. If no other operating system is using the newly added files of operating system A in this backup operation, it is determined that the newly added files of operating system A in this backup operation can be cleaned up.

[0137] (6) When it is determined based on the usage mark that no other operating system is using the newly added files of the backup operation of operating system A, the hash file control component can first clean up the corresponding path hash list and file hash list, etc., and synchronize the cleaning message to the virtual hash storage device to clean up the relevant files in the virtual hash storage device.

[0138] Optionally, when it is determined based on the usage mark that no other operating system is using the newly added files of operating system A in this backup operation, the relevant files will not be cleaned up temporarily. When the persistent time attribute defined in the custom attribute expires, the hash file control will also clean up the corresponding path hash list and file hash list, and synchronize the cleanup message to the virtual hash storage device to clean up the relevant files in the virtual hash storage device.

[0139] Backing up non-core files of the operating system through the incremental backup method can reduce backup time and backup capacity.

[0140] Here are some examples:

[0141] Example 3: Assume that the maximum throughput rate of the distributed storage of the operating system in the virtualized environment is 1GB / s, the maximum throughput rate of a single disk is 200MB / s, and the capacity of an operating system is approximately 5G. If 100 operating systems are backed up at the same time, excluding other production business read and write operations, assuming that the operating system core files account for 95% and are the same data in the 100 operating systems, the total backup time is 5G×100 (units)×(1-95%)÷1GB / s=25 seconds.

[0142] The backup capacity including the basic capacity (i.e. the capacity of the same data) is 5G+5G×100 (units)×(1-95%)=30GB. Compared with 500GB, the total backup capacity is reduced by (500GB-30GB)÷500GB=94%.

[0143] Example 4: Assuming that the hard disk attribute of the local operating system is SSD, the throughput rate of a single disk is 500MB / s, and the capacity of an operating system is approximately 5G, then excluding other production business read and write operations, the backup time of a single operating system is 5G×(1-95%)÷500MB / s=0.5 seconds.

[0144] Assuming that the hard disk attribute of the local operating system is SATA, the throughput rate of a single disk is 100M / s, and the capacity of an operating system is about 5G, then excluding other production business read and write operations, the backup time of a single operating system is 5G×(1-95%)÷100MB / s=2.5 seconds.

[0145] From examples 1, 2, 3, and 4, we can see that, assuming that 95% of the data is the same, the overall backup capacity is reduced by about 94%, and the backup speed is increased by 20 times.

[0146] In some embodiments, the operating system to be replaced is a virtual operating system.

[0147] Based on the operating system backup files and the operating system core files, the operating system to be replaced is replaced, including: mounting a virtual disk; storing the operating system backup files and the operating system core files in the virtual disk; mounting the virtual disk storing the operating system backup files and the operating system core files to the operating system to be replaced; replacing the operating system files of the operating system to be replaced with the operating system backup files and the operating system core files stored in the virtual disk, and completing the replacement process of the operating system to be replaced.

[0148] In the case of large-scale operating system replacement, the main purpose of backup is to trigger automatic / manual system rollback in the event of failure or application incompatibility.

[0149] Generally speaking, there are two types of operating systems: one is the operating system in a virtualized environment, namely the virtual operating system, and the other is the system under bare metal, namely the bare metal operating system; there are two reasons for system rollback: one is a sudden rollback due to system failure, and the other is a human determination that a rollback is required due to reasons such as application compatibility (manual execution of the rollback command).

[0150] If a rollback is manually determined to be necessary (manual execution of the rollback command) due to application compatibility or other reasons, then if the default redundant space is sufficient, in order to increase the rollback speed, the compressed file function can be disabled and the operating system backup files and operating system core files can be directly obtained from the virtual hash storage device based on the path hash list, file hash list and basic file hash list, and the existing operating system files of the operating system to be replaced are replaced and saved with the obtained operating system backup files and operating system core files.

[0151] If the system space of the operating system is to be replaced, a file compression function (for example, compression by gzip) may be enabled to compress the operating system backup file and the operating system core file before performing subsequent replacement operations.

[0152] Preferably, the compression rate is 70%.

[0153] It should be noted that the order of system rollback is basically the same as that of system startup, and usually follows the following system rollback steps:

[0154] S1: When performing system rollback, the operating system is restarted, and a hardware self-test (POST) is performed and a boot loader is loaded through the computer firmware BIOS (Basic Input Output System) or the Unified Firmware Interface (UEFI).

[0155] S2: The boot loader (such as GRUB, LILO, etc.) is responsible for loading the fallback boot instructions when the computer starts and loading the fallback kernel image from the boot device.

[0156] S3: Kernel initialization: After the fallback kernel image is loaded into the memory, it starts initialization, including initializing hardware, creating processes, loading driver modules, and other operations.

[0157] S4: Roll back the system: Initialize and mount the sysroot directory according to the content of the rolled back kernel image, and perform a second restart after synchronously obtaining the backup file.

[0158] Since this restart uses the original operating system files and boot, the restart operation is consistent with the original operating system. If the backup file is compressed, use the decompression and overwriting synchronization method when synchronously obtaining the backup file.

[0159] It can be understood that the backup files here include operating system backup files and operating system core files.

[0160] See also Figure 4 , Figure 4 It is a flowchart of replacing a virtual operating system provided in an embodiment of the present application.

[0161] like Figure 4 As shown, if the operating system to be replaced is a virtual operating system, the steps for performing the replacement process are as follows:

[0162] If the hash file control component confirms that the virtual operating system is abnormal through system crash detection, the virtual disk is mounted on the hash file control component.

[0163] Furthermore, the virtual hash storage device is controlled to store the operating system backup file and the operating system core file in the virtual disk.

[0164] Furthermore, after executing the system rollback steps S1-S3, when performing the system rollback step S4, the virtual disk storing the operating system backup files and the operating system core files is uninstalled from the hash file control component and mounted to the operating system to be replaced; according to the content of the rollback kernel image, the sysroot directory is initialized and mounted, and the operating system files of the operating system to be replaced are replaced with the operating system backup files and the operating system core files stored in the virtual disk, the replacement process of the operating system to be replaced is completed, and a second restart is performed.

[0165] In some embodiments, the operating system to be replaced is a bare metal operating system.

[0166] The operating system to be replaced is replaced based on the operating system backup file and the operating system core file, including: preparing an ISO image file based on the operating system backup file and the operating system core file; the ISO image file contains the operating system backup file and the operating system core file; mounting the ISO image file to the operating system to be replaced; replacing the operating system files of the operating system to be replaced with the operating system backup files and the operating system core files stored in the ISO image file, and completing the replacement process of the operating system to be replaced.

[0167] See also Figure 5 , Figure 5 It is a flowchart of replacing a bare metal operating system provided in an embodiment of the present application.

[0168] like Figure 5 As shown, if the operating system to be replaced is a virtual operating system, the steps for performing the replacement process are as follows:

[0169] If the hash file control component confirms that the virtual operating system is abnormal through system crash detection, an ISO image file is prepared using an ISO image tool based on the operating system backup file and the operating system core file, and the ISO image file is mounted through IPMI as a virtual optical drive and sent to the operating system.

[0170] The ISO image file contains the operating system backup file and the operating system core file.

[0171] Furthermore, after executing the system rollback steps S1-S3, when performing the system rollback step S4, the ISO image file is mounted to the operating system to be replaced; according to the content of the rollback kernel image, the sysroot directory is initialized and mounted, and the operating system files of the operating system to be replaced are replaced with the operating system backup files and operating system core files stored in the ISO image file, the replacement process of the operating system to be replaced is completed, and a second restart is performed.

[0172] In some embodiments, based on the operating system backup file and the operating system core file, before the operating system to be replaced is replaced, the process further includes: compressing the operating system backup file and the operating system core file.

[0173] In the case of large-scale operating system replacement, the main purpose of backup is to trigger automatic / manual system rollback in the event of failure or application incompatibility.

[0174] Generally speaking, there are two types of operating systems: one is the operating system in a virtualized environment, namely the virtual operating system, and the other is the system under bare metal, namely the bare metal operating system; there are two reasons for system rollback: one is a sudden rollback due to system failure, and the other is a human determination that a rollback is required due to reasons such as application compatibility (manual execution of the rollback command).

[0175] If a rollback is manually determined to be necessary (manual execution of the rollback command) due to application compatibility or other reasons, then if the default redundant space is sufficient, in order to increase the rollback speed, the compressed file function can be disabled and the operating system backup files and operating system core files can be directly obtained from the virtual hash storage device based on the path hash list, file hash list and basic file hash list, and the existing operating system files of the operating system to be replaced are replaced and saved with the obtained operating system backup files and operating system core files.

[0176] If the system space of the operating system is to be replaced, a file compression function (for example, compression by gzip) may be enabled to compress the operating system backup file and the operating system core file before performing subsequent replacement operations.

[0177] The operating system replacement method provided in the embodiment of the present application solves the problems of insufficient replacement efficiency and insufficient replacement capacity during large-scale operating system replacement by setting up a virtual hash storage device and a hash file control component, and solves the problem of difficulty in system rollback in the prior art by real-time rollback. At the same time, the problem of limited space in some operating systems is solved by compressing space during system rollback.

[0178] The present application also provides a device for replacing an operating system. Figure 6 , Figure 6 It is a structural diagram of the replacement device of the operating system provided in an embodiment of the present application. In this embodiment, the passenger identification device includes a hash list acquisition module 610, a backup file acquisition module 620, a core file acquisition module 630 and a replacement module 640.

[0179] The hash list acquisition module 610 is used to obtain the path hash list, file hash list and basic file hash list of the operating system to be replaced in response to the system rollback instruction.

[0180] The path hash list is used to identify the file storage path of the operating system backup file, the file hash list is used to identify the operating system backup file, and the basic file hash list is used to identify the operating system core file, which is a file that controls and manages the operation of the operating system.

[0181] The backup file acquisition module 620 is used to acquire the operating system backup file of the operating system to be replaced from the virtual hash storage device based on the path hash list and the file hash list.

[0182] The core file acquisition module 630 is used to acquire the operating system core file of the operating system to be replaced from the virtual hash storage device based on the basic file hash list.

[0183] The replacement module 640 is used to replace the operating system to be replaced based on the operating system backup file and the operating system core file.

[0184] In some embodiments, the number of files of the operating system core file is at least one.

[0185] The replacement device for the operating system also includes a storage module, which is used to recursively traverse the operating system core files; determine the file hash value corresponding to each operating system core file; generate a basic file hash list based on the file hash value corresponding to each operating system core file; the basic file hash list includes the file hash value corresponding to each operating system core file; and store the basic file hash list and each operating system core file in a virtual hash storage device.

[0186] In some embodiments, the operating system backup file includes a plurality of operating system non-core files.

[0187] The storage module is also used to traverse the non-core files of the operating system; determine the file hash value corresponding to each non-core file of the operating system; determine the path hash value corresponding to each non-core file of the operating system based on the file storage path of each non-core file of the operating system and the file hash value corresponding to each non-core file of the operating system; generate a file hash list based on the file hash value corresponding to each non-core file of the operating system; the file hash list includes the file hash value corresponding to each non-core file of the operating system; generate a path hash list based on the path hash value corresponding to each non-core file of the operating system; the path hash list includes the path hash value corresponding to each non-core file of the operating system; and store the path hash list and the file hash list in a virtual hash storage device.

[0188] In some embodiments, the operating system to be replaced is a virtual operating system.

[0189] The replacement module 640 is also used to mount a virtual disk; store the operating system backup files and the operating system core files in the virtual disk; mount the virtual disk storing the operating system backup files and the operating system core files to the operating system to be replaced; replace the operating system files of the operating system to be replaced with the operating system backup files and the operating system core files stored in the virtual disk, and complete the replacement process of the operating system to be replaced.

[0190] In some embodiments, the operating system to be replaced is a bare metal operating system.

[0191] The replacement module 640 is also used to prepare an ISO image file based on the operating system backup file and the operating system core file; the ISO image file contains the operating system backup file and the operating system core file; the ISO image file is mounted to the operating system to be replaced; the operating system files of the operating system to be replaced are replaced with the operating system backup files and the operating system core files stored in the ISO image file, and the replacement process of the operating system to be replaced is completed.

[0192] In some embodiments, the replacement module 640 is also used to compress the operating system backup files and the operating system core files.

[0193] The embodiment of the present application also provides an electronic device, Figure 7 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the replacement method of the operating system.

[0194] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0195] An embodiment of the present application also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method for replacing the operating system provided by the above methods is implemented.

[0196] An embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned methods for replacing an operating system.

[0197] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0198] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0199] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for replacing an operating system, characterized in that: include: In response to the system rollback instruction, a path hash list, a file hash list and a basic file hash list of the operating system to be replaced are obtained; the path hash list is used to identify the file storage path of the operating system backup file, the file hash list is used to identify the operating system backup file, and the basic file hash list is used to identify the operating system core file, and the operating system core file is a file that controls and manages the operation of the operating system; Based on the path hash list and the file hash list, acquiring the operating system backup file of the to-be-replaced operating system from a virtual hash storage device; Based on the basic file hash list, obtaining the operating system core file of the to-be-replaced operating system from the virtual hash storage device; The operating system to be replaced is replaced based on the operating system backup file and the operating system core file.

2. The method for replacing an operating system according to claim 1, characterized in that: The number of the operating system core file is at least one; Before the step of obtaining the path hash list and the file hash list of the operating system to be replaced in response to the system rollback instruction, the method further includes: Recursively traverse the operating system core files; Determine the file hash value corresponding to each operating system core file; Generate a basic file hash list based on the file hash value corresponding to each operating system core file; the basic file hash list includes the file hash value corresponding to each operating system core file; The basic file hash list and each operating system core file are stored in the virtual hash storage device.

3. The method for replacing an operating system according to claim 1, characterized in that: The operating system backup file includes a plurality of operating system non-core files; Before obtaining the path hash list, file hash list and basic file hash list of the operating system to be replaced in response to the system rollback instruction, the method further includes: Traversing the non-core files of the operating system; Determine the file hash value corresponding to each operating system non-core file; Determine a path hash value corresponding to each operating system non-core file based on a file storage path of each operating system non-core file and a file hash value corresponding to each operating system non-core file; Generate a file hash list based on the file hash value corresponding to each operating system non-core file; the file hash list includes the file hash value corresponding to each operating system non-core file; Generate a path hash list based on the path hash value corresponding to each operating system non-core file; the path hash list includes the path hash value corresponding to each operating system non-core file; The path hash list and the file hash list are stored in the virtual hash storage device.

4. The method for replacing an operating system according to claim 1, characterized in that: The operating system to be replaced is a virtual operating system; The replacing process of the operating system to be replaced based on the operating system backup file and the operating system core file includes: Mount the virtual disk; Storing the operating system backup file and the operating system core file in the virtual disk; Mounting the virtual disk storing the operating system backup file and the operating system core file to the operating system to be replaced; The operating system files of the operating system to be replaced are replaced with the operating system backup files and the operating system core files stored in the virtual disk, thereby completing the replacement process of the operating system to be replaced.

5. The method for replacing an operating system according to claim 1, characterized in that: The operating system to be replaced is a bare metal operating system; The replacing process of the operating system to be replaced based on the operating system backup file and the operating system core file includes: Based on the operating system backup file and the operating system core file, preparing an ISO image file; the ISO image file includes the operating system backup file and the operating system core file; Mounting the ISO image file to the operating system to be replaced; The operating system files of the operating system to be replaced are replaced with the operating system backup files and the operating system core files stored in the ISO image file, thereby completing the replacement process of the operating system to be replaced.

6. The method for replacing an operating system according to claim 1, characterized in that: Before performing replacement processing on the operating system to be replaced based on the operating system backup file and the operating system core file, the method further includes: The operating system backup file and the operating system core file are compressed.

7. A device for replacing an operating system, characterized in that: include: A hash list acquisition module is used to obtain a path hash list, a file hash list and a basic file hash list of the operating system to be replaced in response to a system rollback instruction; the path hash list is used to identify a file storage path of an operating system backup file, the file hash list is used to identify an operating system backup file, and the basic file hash list is used to identify an operating system core file, which is a file for controlling and managing the operation of the operating system; A backup file acquisition module, used for acquiring the operating system backup file of the operating system to be replaced from the virtual hash storage device based on the path hash list and the file hash list; A core file acquisition module, used for acquiring the operating system core file of the operating system to be replaced from the virtual hash storage device based on the basic file hash list; The replacement module is used to replace the operating system to be replaced based on the operating system backup file and the operating system core file.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for replacing the operating system according to any one of claims 1 to 6 is implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for replacing the operating system according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method for replacing the operating system according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method for backing up and restoring terminal system based on cloud architecture

    CN102508735A

  • User-defined metadata-oriented indexing and querying method and system

    CN111427847A

  • Backup method and system of NAS file system and storage medium

    CN114546980A

  • Method, device and computer program product for backuping virtual machine

    US20200117545A1

  • Updating a file using differences and file format therefor

    WO2009132261A1