Mirror image data processing method of operating system

By adapting snapshot tools and configuring read-only snapshot files, the problem of balancing read-only and modifiable ISO images is solved, automated image deployment and multi-system compatibility are achieved, and the efficiency and reliability of image processing are improved.

CN120723260APending Publication Date: 2025-09-30BEIJING DONGFANG YIMENG TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510890044.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-30
Publication Date
2025-09-30

AI Technical Summary

Technical Problem

In the existing technology, it is difficult to balance the read-only and modifiable properties of ISO images. Manually copying image files leads to irregular snapshot management and low deployment efficiency. In addition, snapshot tools for different operating systems have poor compatibility. Additional dependencies need to be installed when deploying images, which increases the usage threshold.

Method used

By adapting the snapshot tool, generating and configuring read-only snapshot files, automatically loading the snapshot tool, and integrating the snapshot tool and configuration files into the image, the automated deployment and compatibility of the image can be achieved. Snapshot files are stored in isolation to avoid confusion and reduce manual intervention.

Benefits of technology

It achieves a balance between read-only and modifiable ISO images, improves image deployment efficiency and reliability, reduces usage complexity, and supports compatible deployment of multiple operating systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723260A_ABST
    Figure CN120723260A_ABST
Patent Text Reader

Abstract

The mirror image data processing method of the operating system comprises the following steps: acquiring an original ISO mirror image file of the operating system, and mounting the original ISO mirror image file to a specified directory; copying a file system of the original ISO mirror image file to a working directory and forming a system file copy; adapting a snapshot tool according to the type of the operating system, obtaining a dependency item of the snapshot tool and installing the snapshot tool; configuring the snapshot file in the current state into a read-only attribute through an authority management function of the system file copy, and generating a read-only snapshot file; modifying a system startup script to automatically load a snapshot tool and identify a read-only snapshot file of a specified subdirectory when an operating system is started; and unloading the initially mounted original ISO mirror image file, and packaging the complete system file copy in the working directory into a new ISO mirror image file by using a mirror image packaging tool. According to the scheme, the system starting reliability is improved, multi-architecture adaptation is supported, the development and maintenance cost is reduced, and efficient and stable deployment is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a mirror data processing method for an operating system, belonging to the technical field of mirror data processing of computer operating systems. Background Art

[0002] In operating system development, ISO images, as a standard distribution format for operating systems, typically need to meet the dual requirements of read-only and modifiable. In existing technologies, directly modifying the original ISO image destroys the image's read-only attribute, making it impossible to retain the historical state before the modification. Manually copying image files for backup leads to problems such as irregular snapshot management and low deployment efficiency.

[0003] For example, when manually copying image files, due to the lack of a systematic snapshot tool adaptation mechanism, different operating systems such as Linux and Windows require manual configuration of snapshot tools, which has poor compatibility. Historical snapshots cannot be automatically loaded when the modified image is started, and manual pre-recovery of the system status is required, affecting deployment efficiency. In addition, traditional packaging methods only include system file copies and do not integrate snapshot tools and configuration files, resulting in the need to install additional dependencies when deploying the image, greatly increasing the usage threshold of image installation. Summary of the Invention

[0004] In view of the above-mentioned deficiencies in the prior art, an object of the present invention is to provide a method for processing mirror data of an operating system.

[0005] According to an embodiment of the present invention, a first solution is provided: a method for processing image data of an operating system, comprising the following steps:

[0006] Get the original ISO image file of the operating system and mount it to the specified directory;

[0007] Copies the file system of the original ISO image file in the specified directory to the working directory and forms a modifiable system file copy;

[0008] Adapting a snapshot tool according to the type of the operating system, obtaining dependencies of the snapshot tool and installing the snapshot tool, editing a snapshot configuration file of the snapshot tool and setting a storage location and triggering rules for the snapshot tool;

[0009] Use the snapshot tool to generate a copy of the modifiable system files in the working directory as a snapshot file of the current state. Use the permission management function of the system file copy to configure the snapshot file of the current state as read-only and generate a read-only snapshot file.

[0010] Copy the read-only snapshot file to a specified subdirectory of the working directory, and modify the system startup script to automatically load the snapshot tool when the operating system starts and identify the read-only snapshot file in the specified subdirectory;

[0011] Unmount the original ISO image file that was initially mounted, and use an image packaging tool to package the complete system file copy in the working directory into a new ISO image file. The complete system file includes the system file copy, system configuration file, read-only snapshot file of the specified subdirectory, snapshot tool, and snapshot configuration file.

[0012] Furthermore, the step of adapting the snapshot tool according to the type of the operating system includes:

[0013] Select a snapshot tool version that is compatible with the operating system. If the operating system uses the Linux kernel, adjust the snapshot tool's kernel interface to adapt to the system driver. If the operating system uses the Windows kernel, replace the snapshot tool's underlying dependencies to be compatible with the system operating environment.

[0014] Furthermore, the step of configuring the snapshot file in the current state as a read-only attribute and generating a read-only snapshot file through the authority management function of the system file copy includes:

[0015] If the operating system is Linux, use the file permission management function of the Linux system to call the chmod444 command to set the read and write permissions of the snapshot file to "read only";

[0016] If the operating system is Windows, set the file read-only attribute flag and set the read and write permissions of the snapshot file to "read only".

[0017] Furthermore, the step of copying the read-only snapshot file to a designated subdirectory of the working directory includes:

[0018] Isolate system snapshot files from system file copies to avoid accidental deletion or overwriting of read-only snapshot files when system files are modified. The path of the designated subdirectory is: / workdir / snapshots / .

[0019] Furthermore, the step of modifying the system startup script so that the snapshot tool is automatically loaded when the operating system starts and the read-only snapshot file in the specified subdirectory is identified includes:

[0020] If the operating system is Linux, the system startup script is / etc / rc.local. Modify the system startup script to add the snapshot tool loading command: service snapshot-tool start. Set the environment variable: SNAPSHOT_PATH = / workdir / snapshots / to identify the storage path of read-only snapshot files.

[0021] If the operating system is Windows, the system startup script is the Windows startup task schedule. Modify the system startup script to add the snapshot tool loading command: service snapshot-tool start. Set the environment variable to: SNAPSHOT_PATH = / workdir / snapshots / to identify the storage path of the read-only snapshot files.

[0022] Furthermore, the step of using an image packaging tool to package the complete system file copy in the working directory into a new ISO image file includes:

[0023] The image packaging tool is mkisofs for Linux systems or WinISO for Windows systems. The packaging includes system file copies, system configuration files, read-only snapshot files in designated subdirectories, snapshot tools, and the complete path structure of snapshot configuration files.

[0024] Furthermore, the step of generating a copy of the modifiable system file in the working directory into a snapshot file of the current state by using a snapshot tool further includes:

[0025] Compare the differences between the current system file copy and the previous snapshot file and generate an incremental file in .diff format. Store the incremental file and record the association between the incremental file and the previous snapshot file.

[0026] When using an image packaging tool to package a new ISO image file, store the initial full snapshot file and subsequently added incremental files in the snapshots directory of the image. Set the incremental link base_snapshot:v1.iso; incremental:[v1-v2.diff,v2-v3.diff] in the snapshot configuration file.

[0027] When the operating system starts, the snapshot tool merges the current incremental file with the initial full snapshot file based on the incremental link to restore the latest system status.

[0028] Furthermore, the step of modifying the system startup script so that the snapshot tool is automatically loaded when the operating system starts and the read-only snapshot file in the designated subdirectory is identified further includes:

[0029] When the operating system starts, the snapshot tool calculates the SHA-256 hash value and compares it with the hash value stored in the system configuration file to verify the integrity of the read-only snapshot file in the specified subdirectory;

[0030] If the hash does not match, the verification fails. The snapshot tool automatically checks the latest undamaged snapshot sorted by timestamp to see if there is a previous valid snapshot. If so, it loads the snapshot to restore the system state.

[0031] If the hashes do not match continuously and all snapshots fail verification, the operating system automatically enters safe mode, loading only the basic kernel and necessary drivers. A message stating "snapshot file corruption requires manual recovery" is displayed in the / var / log / snapshot_error.log log.

[0032] Synchronous, the snapshot tool automatically regenerates snapshots and updates hash values ​​periodically while the operating system is running.

[0033] Furthermore, the step of using an image packaging tool to package the complete system file copy in the working directory into a new ISO image file includes:

[0034] Generate a multi-architecture system file copy in the working directory through the multi-architecture virtual machine, wherein the multi-architecture system file copy includes an x86_64 system file copy, an ARM64 system file copy, and a RISC-V system file copy;

[0035] During packaging, the image packaging tool stores copies of multi-architecture system files, system configuration files, read-only snapshot files in specified subdirectories, snapshot tools, and snapshot configuration files in the architecture-specified partitions of the image, including / arch / x86_64 / and / arch / arm64 / .

[0036] Embed an architecture detection module in the boot partition of the image, wherein the architecture detection module identifies the current hardware architecture by reading the CPU ID information of the hardware when the operating system starts;

[0037] Based on the identification results of the current hardware architecture, / arch / arm64 / rootfs is used as the root file system, / arch / arm64 / snapshot-tool is called, and the boot program loads the system file copy and snapshot tool of the corresponding architecture-specific partition to make the current image compatible with the deployment requirements of multiple hardware platforms.

[0038] Furthermore, the method further includes: starting a new ISO image file in a test environment to verify whether the recognition and instant restore functions of the snapshot tool are normal.

[0039] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following steps:

[0040] Get the original ISO image file of the operating system and mount it to the specified directory;

[0041] Copies the file system of the original ISO image file in the specified directory to the working directory and forms a modifiable system file copy;

[0042] Adapting a snapshot tool according to the type of the operating system, obtaining dependencies of the snapshot tool and installing the snapshot tool, editing a snapshot configuration file of the snapshot tool and setting a storage location and triggering rules for the snapshot tool;

[0043] Use the snapshot tool to generate a copy of the modifiable system files in the working directory as a snapshot file of the current state. Use the permission management function of the system file copy to configure the snapshot file of the current state as read-only and generate a read-only snapshot file.

[0044] Copy the read-only snapshot file to a specified subdirectory of the working directory, and modify the system startup script to automatically load the snapshot tool when the operating system starts and identify the read-only snapshot file in the specified subdirectory;

[0045] Unmount the original ISO image file that was initially mounted, and use an image packaging tool to package the complete system file copy in the working directory into a new ISO image file. The complete system file includes the system file copy, system configuration file, read-only snapshot file of the specified subdirectory, snapshot tool, and snapshot configuration file.

[0046] A computer-readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the following steps:

[0047] Get the original ISO image file of the operating system and mount it to the specified directory;

[0048] Copies the file system of the original ISO image file in the specified directory to the working directory and forms a modifiable system file copy;

[0049] Adapting a snapshot tool according to the type of the operating system, obtaining dependencies of the snapshot tool and installing the snapshot tool, editing a snapshot configuration file of the snapshot tool and setting a storage location and triggering rules for the snapshot tool;

[0050] Use the snapshot tool to generate a copy of the modifiable system files in the working directory as a snapshot file of the current state. Use the permission management function of the system file copy to configure the snapshot file of the current state as read-only and generate a read-only snapshot file.

[0051] Copy the read-only snapshot file to a specified subdirectory of the working directory, and modify the system startup script to automatically load the snapshot tool when the operating system starts and identify the read-only snapshot file in the specified subdirectory;

[0052] Unmount the original ISO image file that was initially mounted, and use an image packaging tool to package the complete system file copy in the working directory into a new ISO image file. The complete system file includes the system file copy, system configuration file, read-only snapshot file of the specified subdirectory, snapshot tool, and snapshot configuration file.

[0053] Compared with the existing technology, the technical solution provided by this application has the following unique beneficial effects: in the image processing of the operating system of this solution, the original ISO image file is mounted in the specified directory, and the system files are copied to the working directory, which retains the read-only nature of the original image to avoid accidental modification, accidental deletion or accidental overwriting, and provides a modifiable copy of the system files for function debugging, solving the contradiction between image modification and original state preservation; the process of adapting snapshot tools, installing dependencies, configuring storage locations and triggering rules is solidified into a standard image processing method, which realizes the compatible deployment of snapshot tools under different operating systems and reduces the technical threshold for using snapshot tools across systems; the generated snapshot file of the current state is configured as only The read attribute ensures that snapshot files cannot be modified. By copying them to a designated subdirectory for isolated storage, confusion between snapshot files and system files is avoided, improving the traceability of historical status. By modifying the system startup script, the snapshot tool is automatically loaded and read-only snapshot files are identified, realizing the function of automatically restoring the historical status when the system starts, without the need for manual intervention, significantly improving the efficiency and reliability of image deployment. The final packaged new ISO image file integrates system file copies, system configuration files, read-only snapshot files in designated subdirectories, snapshot tools, and snapshot configuration files to form a one-stop image. No additional dependencies need to be installed during deployment, reducing the complexity of user use. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0055] in:

[0056] Figure 1 is a flowchart of a method for processing image data of an operating system in one embodiment;

[0057] Figure 2 FIG. 1 is a structural block diagram of a computer device in one embodiment. DETAILED DESCRIPTION

[0058] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of 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 only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of this application.

[0059] Example 1

[0060] The technical problem solved by this embodiment is that when manually copying image files, due to the lack of a systematic snapshot tool adaptation mechanism, different operating systems such as Linux and Windows need to manually configure snapshot tools, resulting in poor compatibility. Historical snapshots cannot be automatically loaded when the modified image is started, and manual pre-recovery of the system status is required, affecting deployment efficiency. In addition, the traditional packaging method only includes a copy of the system files and does not integrate snapshot tools and configuration files. As a result, additional dependencies need to be installed when deploying the image, which greatly increases the usage threshold of image installation.

[0061] In order to solve the above technical problems, this embodiment provides a method for processing image data of an operating system, such as Figure 1 As shown, the following steps are included:

[0062] S101: Obtain the original ISO image file of the operating system and mount the original ISO image file to a specified directory;

[0063] S102: Copy the file system of the original ISO image file in the designated directory to the working directory and form a modifiable system file copy;

[0064] S103: adapting a snapshot tool according to the type of the operating system, obtaining dependencies of the snapshot tool and installing the snapshot tool, editing a snapshot configuration file of the snapshot tool and setting a storage location and triggering rules for the snapshot tool;

[0065] S104: using a snapshot tool to generate a copy of the modifiable system file in the working directory as a snapshot file of the current state, and using the permission management function of the system file copy to configure the snapshot file of the current state as a read-only attribute and generate a read-only snapshot file;

[0066] S105: copying the read-only snapshot file to a specified subdirectory of the working directory, and modifying the system startup script so that the snapshot tool is automatically loaded when the operating system starts and the read-only snapshot file in the specified subdirectory is recognized;

[0067] S106: Unmount the original ISO image file that was initially mounted, and use an image packaging tool to package the complete system file copy in the working directory into a new ISO image file, where the complete system file includes the system file copy, the system configuration file, the read-only snapshot file of the specified subdirectory, the snapshot tool, and the snapshot configuration file.

[0068] In the image processing of the operating system in this solution, the original ISO image file is mounted in the specified directory, and the system files are copied to the working directory, which retains the read-only nature of the original image to avoid accidental modification, accidental deletion or accidental overwriting, and provides a modifiable copy of the system files for function debugging, solving the contradiction between image modification and original state preservation; the process of adapting snapshot tools, installing dependencies, configuring storage locations and triggering rules is solidified into a standard image processing method, which realizes the compatible deployment of snapshot tools under different operating systems and reduces the technical threshold for using snapshot tools across systems; the generated snapshot file of the current state is configured as read-only to ensure that the snapshot file cannot be modified. Modifiability: By copying to a designated subdirectory for isolated storage, the confusion between snapshot files and system files is avoided, and the traceability of historical status is improved. By modifying the system startup script, the snapshot tool is automatically loaded and the read-only snapshot file is identified, which realizes the function of automatically restoring the historical status when the system starts, without the need for manual intervention, significantly improving the efficiency and reliability of image deployment. The final packaged new ISO image file integrates system file copies, system configuration files, read-only snapshot files in designated subdirectories, snapshot tools and snapshot configuration files to form a one-stop image. No additional dependencies need to be installed during deployment, reducing the complexity of user use.

[0069] Example 2

[0070] This embodiment specifically discloses a preferred operating system image data processing method, including the following steps:

[0071] S201: Obtain the original ISO image file of the operating system and mount the original ISO image file to a specified directory;

[0072] Specifically, the original ISO image file is an ISO image file of a domestic operating system. The original ISO image file is mounted to a specified directory, such as / mnt / iso, so as to access files in the image.

[0073] S202: Copy the file system of the original ISO image file in the specified directory to the working directory and form a modifiable system file copy;

[0074] Specifically, this step is the process of customizing the system image, and the working directory is / mnt / workdir.

[0075] S203: adapting a snapshot tool according to the type of the operating system, obtaining dependencies of the snapshot tool and installing the snapshot tool, editing a snapshot configuration file of the snapshot tool and setting a storage location and triggering rules for the snapshot tool;

[0076] The step of adapting the snapshot tool according to the type of operating system includes: selecting a snapshot tool version compatible with the operating system version; if the operating system is a Linux kernel, adjusting the kernel interface of the snapshot tool to adapt to the system driver; if the operating system is a Windows kernel, replacing the underlying dependencies of the snapshot tool to be compatible with the system operating environment.

[0077] Specifically, the specific distribution and kernel compatibility can be determined by reading the ID field (such as ubuntu or centos) and the VERSION_ID field (such as 20.04) in the system file / etc / os-release and combining it with the kernel version (obtained using the uname -r command). The system version can be obtained by reading the ProductName (such as "Windows 10Pro") and ReleaseId (such as "2004") in the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion, or by calling the PowerShell command Get-ComputerInfo|Select-Object OSName.

[0078] Dependencies are program files required for the snapshot tool to run. In Linux, the snapper tool relies on the Btrfs file system driver, configuration management tools, and service management tools. In Windows, the VSS service relies on functional components, COM+ services, and Windows Management Instrumentation.

[0079] After installation, you need to customize the snapshot tool's behavior by editing the configuration file. Core parameters include storage location, triggering rules, and retention policy. The storage location is used to avoid confusion with system files. Triggering rules include timed triggering and event triggering. Retention policy includes the maximum number of snapshots and automatic deletion of old snapshots.

[0080] For example, in Linux:

[0081] Configuration file path: The default location is / etc / snapper / configs / root.

[0082] Key parameter settings:

[0083] SUBVOLUME: Specifies the Btrfs subvolume to be monitored (e.g. / @, which corresponds to the working directory of the system file copy);

[0084] TIMELINE_CREATE: Set the timing trigger rule (for example, yes means enabling the timing snapshot, and TIMELINE_MIN_AGE=1h means generating once every hour);

[0085] NUMBER_CLEANUP: Sets the retention policy (e.g., NUMBER_MAX=10 means a maximum of 10 snapshots are retained, and older snapshots are automatically deleted);

[0086] BACKGROUND_COMPARISON: Set the storage location (such as BACKUP_LOCATION = / workdir / snapshots / , pointing to the isolated read-only snapshot storage directory).

[0087] This standardized process systematically addresses the poor cross-system compatibility of snapshot tools in traditional solutions. Supporting mainstream operating systems such as Linux (Ubuntu / CentOS) and Windows (10 / 11), snapshot tool deployment can be completed without manual intervention, improving adaptation efficiency by over 80%. Automatically identifying and installing dependencies through system commands eliminates the tedious manual search and installation required by users in traditional solutions. By uniformly setting storage locations and triggering rules through configuration files, the traceability and reliability of snapshot files are significantly improved.

[0088] S204: Generate a snapshot file of the current state from a copy of the modifiable system file in the working directory using a snapshot tool, configure the snapshot file of the current state as read-only using the permission management function of the system file copy, and generate a read-only snapshot file;

[0089] The steps of configuring the snapshot file in the current state as a read-only attribute and generating a read-only snapshot file through the permission management function of the system file copy include: if the operating system is a Linux system, calling the chmod444 command through the file permission management function of the Linux system to set the read and write permissions of the snapshot file to "read only"; if the operating system is a Windows system, setting the file read-only attribute mark and setting the read and write permissions of the snapshot file to "read only".

[0090] Taking the Linux system as an example, Btrfs supports the "subvolume" and "snapshot" features. The subvolume is an independent file system branch, and the snapshot is generated through the "copy-on-write" mechanism - it only records the metadata of the current status of the subvolume, and does not copy the actual file content.

[0091] A copy of the system files in the working directory is stored in the Btrfs subvolume; calling the snapper tool to execute the command automatically generates a snapshot file, which is stored in / workdir / rootfs / .snapshots / snapshot by default. It is essentially a "read-only mirror" of the Btrfs subvolume, containing the inode information and metadata of all current files.

[0092] Linux controls file access through file system permissions. Snapshot files, as mirrors of Btrfs subvolumes, inherit permissions from the parent volume, but must be explicitly set to "read-only." To do this, call the chmod command to set the snapshot file's user / group / other permissions to "read-only." Using the Btrfs feature, directly set the subvolume to read-only. Any attempt to modify the snapshot file will result in a "permission denied" error, ensuring that the snapshot contents cannot be altered.

[0093] The above steps systematically solve the technical problems of "the contradiction between image modification and state preservation" and "snapshots are easy to tamper with".

[0094] S205: copying the read-only snapshot file to a designated subdirectory of the working directory, and modifying the system startup script so that the snapshot tool is automatically loaded when the operating system starts and the read-only snapshot file in the designated subdirectory is identified;

[0095] Specifically, the step of copying the read-only snapshot file to the designated subdirectory of the working directory includes: isolating the system snapshot file and the system file copy to avoid accidental deletion or overwriting of the read-only snapshot file when the system file is modified. The path of the designated subdirectory is: / workdir / snapshots / .

[0096] The step of modifying the system startup script so that the snapshot tool is automatically loaded when the operating system starts and the read-only snapshot file in the specified subdirectory is identified includes:

[0097] If the operating system is Linux, the system startup script is / etc / rc.local. Modify the system startup script to add the snapshot tool loading command: service snapshot-tool start. Set the environment variable: SNAPSHOT_PATH = / workdir / snapshots / to identify the storage path of read-only snapshot files.

[0098] If the operating system is Windows, the system startup script is the Windows startup task schedule. Modify the system startup script to add the snapshot tool loading command: service snapshot-tool start. Set the environment variable to: SNAPSHOT_PATH = / workdir / snapshots / to identify the storage path of the read-only snapshot files.

[0099] This standardized script modification process achieves the following technical benefits: The snapshot tool automatically loads at system startup, eliminating the need for manual intervention. Environment variables are used to uniformly pass paths, preventing input errors. Support for mainstream Linux distributions and Windows versions is achieved, and configuration is deeply integrated with the system's native startup mechanism, significantly improving tool stability.

[0100] S206: Unmounting the initially mounted original ISO image file and using an image packaging tool to package the complete system file copies in the working directory into a new ISO image file, wherein the complete system files include the system file copies, the system configuration file, the read-only snapshot files in the designated subdirectories, the snapshot tool, and the snapshot configuration files. The image packaging tool is mkisofs for Linux systems or WinISO for Windows systems. The packaging includes the complete path structure of the system file copies, the system configuration file, the read-only snapshot files in the designated subdirectories, the snapshot tool, and the snapshot configuration files.

[0101] Specifically, the core objectives of this step are: converting the "modifiable working directory content" into an "immutable ISO image" to ensure environmental consistency during deployment; embedding snapshot tools and configuration files into the new ISO so that the deployed system automatically has snapshot management capabilities; and unmounting the original ISO image to prevent it from occupying mount points or system resources.

[0102] Specifically, the steps to package a new ISO include:

[0103] You need to select an image packaging tool based on the operating system type and configure key parameters, such as the file system type and boot flag, to ensure the deployability of the new ISO.

[0104] Take the Linux system as an example:

[0105] Step 1: Confirm the packaging parameters. Key parameters include:

[0106] -r (or -R): preserve the Unix permissions of the file;

[0107] -J: Generate Joliet extension;

[0108] -b boot / grub / stage2_eltorito: specifies the boot file;

[0109] -o new_image.iso: Output ISO file path.

[0110] Step 2: Execute the packaging command:

[0111] Assuming the working directory is / workdir / rootfs, execute: The tool will recursively package all files in the / workdir / rootfs directory and generate new_image.iso.

[0112] The new ISO image contains the modified system files, a snapshot tool, and read-only snapshots. After deployment, you can directly restore to the modified state and manage historical versions using the snapshot tool. The new ISO image is a standalone image file that can be deployed directly from a CD, USB flash drive, or virtual drive, eliminating the need to reconfigure the environment or install tools. Unmounting the original ISO releases the mount point and system resources, preventing system freezes or errors caused by resource usage. The packaging tool retains the read-only attribute of the file, ensuring that the snapshot file remains tamper-proof after deployment, ensuring the authenticity of the historical state.

[0113] S207: Start the new ISO image file in the test environment to verify whether the snapshot tool's recognition and instant restore functions are normal.

[0114] Example 3

[0115] The technical problem solved by this embodiment is that repeated storage of system files in a full snapshot will cause the image volume to expand. For example, when snapshots are generated multiple times, a complete copy of the system files is stored each time, which increases storage costs and image transmission time.

[0116] To solve the above technical problems, this embodiment further provides a method for processing image data of an operating system, wherein the step of generating a copy of a modifiable system file in a working directory as a snapshot file of the current state by using a snapshot tool further includes:

[0117] Compare the differences between the current system file copy and the previous snapshot file and generate an incremental file in .diff format. Store the incremental file and record the association between the incremental file and the previous snapshot file.

[0118] When using an image packaging tool to package a new ISO image file, store the initial full snapshot file and subsequently added incremental files in the snapshots directory of the image. Set the incremental link base_snapshot:v1.iso; incremental:[v1-v2.diff,v2-v3.diff] in the snapshot configuration file.

[0119] When the operating system starts, the snapshot tool merges the current incremental file with the initial full snapshot file based on the incremental link to restore the latest system status.

[0120] The above steps effectively reduce redundant storage.

[0121] Example 4

[0122] The technical problem solved by this embodiment is that after the system startup script is modified, the snapshot file may be damaged due to, for example, storage medium errors, human deletion, and incompatible snapshot tool versions, resulting in the inability to recognize the snapshot file during system startup, thereby affecting the reliability of the system recovery function.

[0123] To solve the above technical problems, this embodiment further provides a method for processing operating system image data. The steps of modifying the system startup script so that the operating system automatically loads the snapshot tool and identifies the read-only snapshot file in the specified subdirectory when the operating system starts up also include:

[0124] When the operating system starts, the snapshot tool calculates the SHA-256 hash value and compares it with the hash value stored in the system configuration file to verify the integrity of the read-only snapshot file in the specified subdirectory;

[0125] If the hash does not match, the verification fails. The snapshot tool automatically checks the latest undamaged snapshot sorted by timestamp to see if there is a previous valid snapshot. If so, it loads the snapshot to restore the system state.

[0126] If the hashes do not match continuously and all snapshots fail verification, the operating system automatically enters safe mode, loading only the basic kernel and necessary drivers. A message stating "snapshot file corruption requires manual recovery" is displayed in the / var / log / snapshot_error.log log.

[0127] Synchronous, the snapshot tool automatically regenerates snapshots and updates hash values ​​periodically while the operating system is running.

[0128] At startup, the SHA-256 hash value of the snapshot file / workdir / snapshots / snapshot_v1.iso is calculated and compared with the hash values ​​of a1b2c3... stored in the system configuration file / etc / snapshot.conf. This can 100% identify incomplete snapshots caused by storage media errors or accidental deletion, avoiding system crashes caused by loading damaged snapshots.

[0129] If the snapshot tool version is incompatible with the old snapshot file format after upgrading, the hash check will trigger a repair process due to the mismatch between the pre-stored hash and the actual calculated value, avoiding startup blocking caused by tool and snapshot format incompatibility. If the check fails, the tool traverses the snapshot directory by timestamp, automatically locates the most recent undamaged snapshot, and loads its file system to restore the system state. Through the dual-condition screening of "timestamp sorting + hash check", it ensures that the loaded snapshot is the most recent, complete and valid snapshot, avoiding recovery failures caused by selecting an outdated or damaged snapshot.

[0130] Example 5

[0131] The technical problem solved by this embodiment is that the image generated by the basic solution is usually only adapted to a single hardware architecture. When it needs to be deployed to devices with different architectures, a separate image must be produced for each architecture, increasing development and maintenance costs.

[0132] To solve the above technical problems, this embodiment provides an operating system image data processing method, which uses an image packaging tool to package a complete system file copy in a working directory into a new ISO image file, including the following steps:

[0133] Generate a multi-architecture system file copy in the working directory through the multi-architecture virtual machine, wherein the multi-architecture system file copy includes an x86_64 system file copy, an ARM64 system file copy, and a RISC-V system file copy;

[0134] During packaging, the image packaging tool stores copies of multi-architecture system files, system configuration files, read-only snapshot files in specified subdirectories, snapshot tools, and snapshot configuration files in the architecture-specified partitions of the image, including / arch / x86_64 / and / arch / arm64 / .

[0135] Embed an architecture detection module in the boot partition of the image, wherein the architecture detection module identifies the current hardware architecture by reading the CPU ID information of the hardware when the operating system starts;

[0136] Based on the identification results of the current hardware architecture, / arch / arm64 / rootfs is used as the root file system, / arch / arm64 / snapshot-tool is called, and the boot program loads the system file copy and snapshot tool of the corresponding architecture-specific partition to make the current image compatible with the deployment requirements of multiple hardware platforms.

[0137] The traditional solution requires a separate image to be created for each hardware architecture, and the cross-compilation environment must be configured and compatibility tested separately. This solution pre-stores copies of multi-architecture system files in a single image, which can cover all target architectures with just one package, significantly reducing the development cycle. The traditional solution requires a separate image version to be maintained for each architecture. This solution centrally manages multi-architecture files, so vulnerability fixes only need to be updated once in the corresponding architecture partition. A single image can be directly deployed to different architecture hardware such as x86 servers, ARM embedded devices, RISC-V development boards, etc., without the need to manually select images for device models. By pre-saving copies of system files for mainstream architectures, images can be adapted to more than 95% of common hardware.

[0138] Automatic architecture identification at boot: The boot partition's "Architecture Detection Module" reads the hardware's CPU ID or device tree information to complete architecture identification within 1 second, eliminating the need for manual user selection or configuration. Traditional solutions require users to manually select the architecture through the GRUB menu at boot, an operation that takes ≥30 seconds.

[0139] Accurately load corresponding partition resources: The boot program loads the system files and snapshot tools of the corresponding architecture partition based on the recognition results to ensure the architectural consistency of the tools and system files.

[0140] Multi-architecture files are stored in the image's "architecture-specific partition," with a total image size of approximately 12GB. Compared to traditional solutions that create separate images for each architecture, this solution uses the same storage space but offers more centralized management. Multi-architecture system file replicas share some common components, enabling "storage once, reuse across multiple architectures" through partition isolation, reducing redundant data.

[0141] Example 6

[0142] Figure 2 FIG1 shows an internal structure diagram of a computer device in an embodiment. The computer device can be a terminal or a server. Figure 2 As shown, the computer device includes a processor, a memory, and a network interface connected via a system bus. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, the processor can implement the mirror data processing method. The memory may also store a computer program. When the computer program is executed by the processor, the processor can implement the mirror data processing method. It will be understood by those skilled in the art that Figure 2 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.

[0143] In one embodiment, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the following steps:

[0144] Get the original ISO image file of the operating system and mount it to the specified directory;

[0145] Copies the file system of the original ISO image file in the specified directory to the working directory and forms a modifiable system file copy;

[0146] Adapting a snapshot tool according to the type of the operating system, obtaining dependencies of the snapshot tool and installing the snapshot tool, editing a snapshot configuration file of the snapshot tool and setting a storage location and triggering rules for the snapshot tool;

[0147] Use the snapshot tool to generate a copy of the modifiable system files in the working directory as a snapshot file of the current state. Use the permission management function of the system file copy to configure the snapshot file of the current state as read-only and generate a read-only snapshot file.

[0148] Copy the read-only snapshot file to a specified subdirectory of the working directory, and modify the system startup script to automatically load the snapshot tool when the operating system starts and identify the read-only snapshot file in the specified subdirectory;

[0149] Unmount the original ISO image file that was initially mounted, and use an image packaging tool to package the complete system file copy in the working directory into a new ISO image file. The complete system file includes the system file copy, system configuration file, read-only snapshot file of the specified subdirectory, snapshot tool, and snapshot configuration file.

[0150] In one embodiment, a computer-readable storage medium is provided, storing a computer program. When the computer program is executed by a processor, the processor performs the following steps:

[0151] Get the original ISO image file of the operating system and mount it to the specified directory;

[0152] Copies the file system of the original ISO image file in the specified directory to the working directory and forms a modifiable system file copy;

[0153] Adapting a snapshot tool according to the type of the operating system, obtaining dependencies of the snapshot tool and installing the snapshot tool, editing a snapshot configuration file of the snapshot tool and setting a storage location and triggering rules for the snapshot tool;

[0154] Use the snapshot tool to generate a copy of the modifiable system files in the working directory as a snapshot file of the current state. Use the permission management function of the system file copy to configure the snapshot file of the current state as read-only and generate a read-only snapshot file.

[0155] Copy the read-only snapshot file to a specified subdirectory of the working directory, and modify the system startup script to automatically load the snapshot tool when the operating system starts and identify the read-only snapshot file in the specified subdirectory;

[0156] Unmount the original ISO image file that was initially mounted, and use an image packaging tool to package the complete system file copy in the working directory into a new ISO image file. The complete system file includes the system file copy, system configuration file, read-only snapshot file of the specified subdirectory, snapshot tool, and snapshot configuration file.

[0157] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0158] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0159] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be determined by the appended claims.

Claims

1. A method for processing image data of an operating system, characterized in that: The steps include: Get the original ISO image file of the operating system and mount it to the specified directory; Copies the file system of the original ISO image file in the specified directory to the working directory and forms a system file copy; Adapting a snapshot tool according to the type of the operating system, obtaining dependencies of the snapshot tool and installing the snapshot tool, editing a snapshot configuration file of the snapshot tool and setting a storage location and triggering rules for the snapshot tool; Use the snapshot tool to generate a copy of the system files in the working directory as a snapshot file of the current state. Use the permission management function of the system file copy to configure the snapshot file of the current state as read-only and generate a read-only snapshot file. Copy the read-only snapshot file to a specified subdirectory of the working directory, and modify the system startup script to automatically load the snapshot tool when the operating system starts and identify the read-only snapshot file in the specified subdirectory; Unmount the original ISO image file that was initially mounted, and use an image packaging tool to package the complete system file copy in the working directory into a new ISO image file. The complete system file includes the system file copy, system configuration file, read-only snapshot file of the specified subdirectory, snapshot tool, and snapshot configuration file.

2. The method for processing image data of an operating system according to claim 1, wherein: The step of adapting the snapshot tool according to the type of the operating system includes: Select a snapshot tool version that is compatible with the operating system. If the operating system is a Linux kernel, adjust the snapshot tool's kernel interface to adapt to the system driver. If the operating system is a Windows kernel, replace the snapshot tool's underlying dependencies to be compatible with the system operating environment.

3. The method for processing mirror data of an operating system according to claim 1, wherein: The steps of configuring the snapshot file in the current state as read-only by using the authority management function of the system file copy and generating a read-only snapshot file include: If the operating system is Linux, use the file permission management function of the Linux system to call the chmod444 command to set the read and write permissions of the snapshot file to "read only"; When the operating system is Windows, set the file read-only attribute flag and set the read and write permissions of the snapshot file to "read only".

4. The method for processing mirror data of an operating system according to claim 1, wherein: The step of copying the read-only snapshot file to a designated subdirectory of the working directory includes: Isolate system snapshot files from system file copies to avoid accidental deletion or overwriting of read-only snapshot files when system files are modified. The path of the designated subdirectory is: / workdir / snapshots / .

5. The method for processing mirror data of an operating system according to claim 1, wherein: The step of modifying the system startup script so that the snapshot tool is automatically loaded when the operating system starts and the read-only snapshot file in the specified subdirectory is identified includes: If the operating system is Linux, the system startup script is / etc / rc.local. Modify the system startup script to add the snapshot tool loading command: service snapshot-tool start. Set the environment variable: SNAPSHOT_PATH = / workdir / snapshots / to identify the storage path of read-only snapshot files. When the operating system is Windows, the system startup script is the Windows startup task schedule. Modify the system startup script to add the snapshot tool loading command: service snapshot-tool start. Set the environment variable to: SNAPSHOT_PATH = / workdir / snapshots / to identify the storage path of the read-only snapshot files.

6. The method for processing mirror data of an operating system according to claim 1, wherein: The step of using the image packaging tool to package the complete system file copy in the working directory into a new ISO image file includes: The image packaging tool is mkisofs for Linux systems or WinISO for Windows systems. The packaging includes system file copies, system configuration files, read-only snapshot files in designated subdirectories, snapshot tools, and the complete path structure of snapshot configuration files.

7. The method for processing operating system image data according to claim 1, wherein: The step of generating a copy of the modifiable system file in the working directory into a snapshot file of the current state by using the snapshot tool also includes: Compare the differences between the current system file copy and the previous snapshot file and generate an incremental file in .diff format. Store the incremental file and record the association between the incremental file and the previous snapshot file. When using an image packaging tool to package a new ISO image file, store the initial full snapshot file and subsequently added incremental files in the snapshots directory of the image. Set the incremental link base_snapshot:v1.iso; incremental:[v1-v2.diff,v2-v3.diff] in the snapshot configuration file. When the operating system starts, the snapshot tool merges the current incremental file with the initial full snapshot file based on the incremental link to restore the latest system status.

8. The method for processing mirror data of an operating system according to claim 1, wherein: The step of modifying the system startup script so that the snapshot tool is automatically loaded when the operating system starts and the read-only snapshot file in the specified subdirectory is identified also includes: When the operating system starts, the snapshot tool calculates the SHA-256 hash value and compares it with the hash value stored in the system configuration file to verify the integrity of the read-only snapshot file in the specified subdirectory; If the hash does not match, the verification fails. The snapshot tool automatically checks the latest undamaged snapshot sorted by timestamp to see if there is a previous valid snapshot. If so, it loads the snapshot to restore the system state. If the hashes continuously mismatch and all snapshots fail verification, the operating system automatically enters safe mode, loading only the basic kernel and necessary drivers. A message stating "snapshot file corruption requires manual recovery" is displayed in the / var / log / snapshot_error.log log. Synchronous, the snapshot tool automatically regenerates snapshots and updates hash values ​​periodically while the operating system is running.

9. The method for processing mirror data of an operating system according to claim 1, wherein: The step of using the image packaging tool to package the complete system file copy in the working directory into a new ISO image file includes: Generate a multi-architecture system file copy in the working directory through the multi-architecture virtual machine, wherein the multi-architecture system file copy includes an x86_64 system file copy, an ARM64 system file copy, and a RISC-V system file copy; During packaging, the image packaging tool stores copies of multi-architecture system files, system configuration files, read-only snapshot files in specified subdirectories, snapshot tools, and snapshot configuration files in the architecture-specified partitions of the image, including / arch / x86_64 / and / arch / arm64 / . Embed an architecture detection module in the boot partition of the image, wherein the architecture detection module identifies the current hardware architecture by reading the CPU ID information of the hardware when the operating system starts; Based on the identification results of the current hardware architecture, / arch / arm64 / rootfs is used as the root file system, / arch / arm64 / snapshot-tool is called, and the boot program loads the system file copy and snapshot tool of the corresponding architecture-specific partition to make the current image compatible with the deployment requirements of multiple hardware platforms.

10. The method for processing mirror data of an operating system according to claim 1, wherein: Also includes: Start the new ISO image file in the test environment to verify whether the snapshot tool's recognition and instant restore functions are normal.

Citation Information

Patent Citations

  • Method for obtaining mirror image of damaged system disk of virtual machine

    CN104407931A

  • Visual PXE system manufacturing method and system

    CN113590140A

  • ISO mirror image file generation method, system and device and storage medium

    CN114138287A

  • Systems and methods for state consistent replication

    US20140181027A1

  • Automated filer technique for use in virtualized appliances and applications

    WO2009149416A1