CN117112304A - Disk cloning method and system - Google Patents

Disk cloning method and system Download PDF

Info

Publication number
CN117112304A
CN117112304A CN202311119150.XA CN202311119150A CN117112304A CN 117112304 A CN117112304 A CN 117112304A CN 202311119150 A CN202311119150 A CN 202311119150A CN 117112304 A CN117112304 A CN 117112304A
Authority
CN
China
Prior art keywords
disk
partition
target
information
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202311119150.XA
Other languages
Chinese (zh)
Other versions
CN117112304B (en
Inventor
梅浩峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Aomei Technology Co ltd
Original Assignee
Chengdu Aomei Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chengdu Aomei Technology Co ltd filed Critical Chengdu Aomei Technology Co ltd
Priority to CN202311119150.XA priority Critical patent/CN117112304B/en
Publication of CN117112304A publication Critical patent/CN117112304A/en
Application granted granted Critical
Publication of CN117112304B publication Critical patent/CN117112304B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1456Hardware arrangements for backup
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention belongs to the technical field of disk cloning, and relates to a disk cloning method and a disk cloning system, wherein the method comprises the following steps: acquiring source disk information; reading partition parameters of a target disk, and adjusting the partition parameters of the target disk; locking the source disk; reading used information of a file system, constructing a starting position of a sector needing cloning and the sector quantity needing continuous copying according to the used information of the file system to obtain target file information; calculating the position of a target partition written into a target disk, and writing target file information into the target partition of the target disk; writing the reconstructed partition table into a target disk; repairing the guiding information and the configuration information of the operating system; the operating system is started. The invention can clone only the used part of the file system, thereby improving the cloning speed; the size of the file system can be adjusted in the cloning process, the file system cloning is realized, and the guiding information and the configuration information of the operating system can be repaired.

Description

Disk cloning method and system
Technical Field
The invention relates to the technical field of disk cloning, in particular to a disk cloning method and system.
Background
The user's computer generally has the requirement of upgrading hardware, if the disk space is insufficient, it is usually necessary to purchase new hardware as new storage space, but the hardware interface on the motherboard is limited, if the hardware interface is insufficient, it is necessary to completely transfer the data of the hard disk with smaller original storage space to the new hard disk, and it is difficult to ensure the consistency of the data by using the new hard disk to replace the old hard disk.
The traditional disk cloning mode is to copy data according to the sector, the copying speed is slow, the time is long, and the efficiency is extremely low; the file system cannot be regulated in a sector copy mode, the system cannot be repaired and guided, the existing file system cannot be changed in the disk cloning process by the existing disk cloning method, the target file system cannot be changed in the cloning process, and the problem that the cloned target file system cannot be operated easily occurs.
Disclosure of Invention
In order to solve the technical problems, the invention provides a disk cloning method and a disk cloning system.
In a first aspect, the present invention provides a disk cloning method, including:
acquiring source disk information and reading partition information of each source disk;
selecting a target disk and acquiring size information of a partition of the target disk;
locking a source disk, creating a snapshot if the source disk cannot be locked, and restarting the system to enter Wi windows PE to clone the disk if the source disk cannot be locked and the snapshot cannot be created;
reading used information of a file system, constructing a starting position of a sector to be cloned and a sector quantity to be continuously copied according to the used information of the file system, and obtaining target file information;
calculating the position of a target partition written into the target disk according to the size of the partition of the source disk and the size of the partition of the target disk, writing target file information of a sector read out from the partition of the source disk into the target partition of the target disk, and reconstructing file record information and bitmap information according to the written position of the target partition until the data of the sectors read out from all the partitions on the source disk are cloned into the target disk;
reconstructing a partition table according to the starting position and the size of a target partition of a target disk and the type of the target disk, and writing the reconstructed partition table into the target disk;
if the source disk has an operating system file, after the data of the sectors read out by all the partitions on the source disk are copied to the target disk, repairing the guiding information and the configuration information of the operating system according to the type of the target disk;
restarting the computer, selecting a target disk from a Boot menu of the BIOS as a starting disk for starting, and starting the cloned operating system.
The invention provides a disk cloning method, which comprises a reading unit, a parameter adjusting unit, an analyzing unit, a constructing unit, a cloning unit, a writing unit, a repairing unit and a starting unit;
the reading unit is used for acquiring the source disk information and reading the partition information of each block of source disk;
the parameter adjusting unit is used for acquiring the size information of the partition of the target disk;
the analysis unit is used for locking the source disk, creating a snapshot if the source disk cannot be locked, and restarting the system to enter Wi windows PE to clone the disk if the source disk cannot be locked and the snapshot cannot be created;
the construction unit is used for reading the used information of the file system, constructing the starting position of the sector needing cloning and the sector quantity needing continuous copying according to the used information of the file system, and obtaining target file information;
the cloning unit is used for calculating the position of a target partition written into the target disk according to the size of the partition of the source disk and the size of the partition of the target disk, writing target file information of a sector read out from the partition of the source disk into the target partition of the target disk, and reconstructing file record information and bitmap information according to the written position of the target partition until the data of the sectors read out from all the partitions on the source disk are cloned into the target disk;
the writing unit is used for rebuilding a partition table according to the starting position and the size of a target partition of the target disk and the type of the target disk and writing the rebuilt partition table into the target disk;
the restoring unit is used for restoring the guide information and the configuration information of the operating system according to the type of the target disk after the data of the sectors read out by all the partitions on the source disk are copied to the target disk when the operating system file exists in the source disk;
the starting unit is used for restarting the computer, selecting a target disk from a Boot menu of the BIOS as a starting disk for starting, and starting the cloned operating system.
On the basis of the technical scheme, the invention can be improved as follows.
Further, reading partition parameters of the target disk, including: the computer system analyzes the partition table of the target disk or obtains partition information on each target disk through an interface provided by an operating system, wherein the partition information comprises a starting sector, a total sector number, a block size, a volume label, a disk symbol and a symbol link of the partition.
Further, adjusting partition parameters of the target disk includes: the system adjusts the size of the partition of the target disk, or the user manually edits and sets the size of each partition of the target disk, if the target disk is smaller than the source disk and the used space of the partition on the source disk is smaller than the total size of the target disk, all the partitions which need to be cloned to the target disk are reduced in an equal proportion in the memory so as to adapt to the capacity of the target disk; if the used space of all the partitions of the source disk is larger than the total size of the target disk, prompting that the space of the target disk is insufficient; if the space of the target disk is larger than that of the source disk, expanding each partition according to the proportion of each partition of the source disk to the total space of the source disk so as to occupy the whole source disk; if the target disk is as large as the source disk, cloning is performed according to the size of the partition of the source disk.
Further, according to the size of the partition of the source disk and the size of the partition of the target disk, calculating the position of the target partition written into the target disk, and writing the target file information of the sector read from the partition of the source disk into the target partition of the target disk, including: if the selected target partition cloned to the target disk is as large as the partition of the source disk or the partition of the target disk is larger than the target partition of the source disk, directly writing the target file information of the sector read from the partition of the source disk into the target partition of the target disk; if the target partition of the target disk is smaller than the size of the partition of the source disk, the write location needs to be recalculated at the time of writing the data according to the size of the target partition.
Further, according to the size of the partition of the source disk and the size of the partition of the target disk, calculating the position of the target partition written into the target disk, and writing the target file information of the sector read from the partition of the source disk into the target partition of the target disk, including:
acquiring information of a source disk file system;
changing a file system according to the size of a partition of a set target disk, copying data of an original file system to a target position of the target disk if the file system is enlarged, and reconstructing information of a new file system according to the size of the file system, wherein the information comprises a bitmap and a DBR; if the file system is reduced, firstly, file record information of a new file system is built in the memory of the computer, and fragments of the original file system are adjusted in the copying process, so that fragments exceeding the new size area can be accommodated by the adjusted fragments.
Further, reconstructing a partition table according to the starting position and the size of a target partition of the target disk and the type of the target disk, and writing the reconstructed partition table into the target disk, including: if the target disk is a GPT disk, generating a new GU ID for each target partition, constructing a new partition table according to the GU ID of the target partition, and writing the new partition table into the target disk; if the target disk is an MBR disk, reconstructing an MBR partition table according to the starting position and the size of the target partition, and writing the reconstructed partition table into the target disk.
Further, repairing the guiding information and the configuration information of the operating system according to the type of the target disk, including: if the target disk is a GPT disk, acquiring GUIDs of a System partition and a Boot partition of the target disk, and updating the GUIDs into a BCD file of the System partition; if the target disk is an MBR disk, updating the disk signature of the target disk, the starting position of the System partition and the starting position of the Boot partition into a BCD file; if the operating System of the target disk is an operating System below Wi windows Vista, modifying path guide data in a guide information file of a System partition according to the path guide data of the System partition and a Boot partition of the target disk, and then repairing the disk symbol information in the Boot partition; if the target disk is a GPT disk, the key value of the registry of the disk symbol of the C disk is found, and then the GU ID of the Boot partition of the target disk is filled into the key value of the registry of the disk symbol of the C disk; and if the target disk is an MBR disk, filling the disk signature of the Boot partition of the target disk and the starting position of the Boot partition into the key value of the registry of the disk symbol of the C disk.
Further, the file system is a FAT32 file system or an NTFS file system; and acquiring a main file table and bitmap information of the NTFS, adjusting data exceeding the bitmap according to the bitmap information, modifying file record information of the data exceeding the bitmap, updating the main file table of the NTFS after completing data cloning, finding the file record information to be adjusted in the memory of the computer, and adjusting to complete the adjustment of the NTFS.
Further, repairing the guiding information and the configuration information of the operating system according to the type of the target disk, including:
judging whether the operating system is in Legacy mode or UEF I mode, and executing a corresponding repairing method according to the mode of the operating system:
if the migrated operating System is in the Legacy mode, modifying the position information of the System partition and the Boot partition in the BCD file, changing the System and the Boot information before migration into the disk signature corresponding to the System and the Boot information after migration and the starting position of the target partition, modifying the registry file in the Boot partition, and changing the information of the disk signature disk of the source disk into the disk signature and the starting position information of the new Boot partition;
if the migrated System is in the UEFI mode, the information of the System partition, the Boot partition and the Recover partition in the BCD file needs to be changed into corresponding disk GUID information and partition GUID information, and similarly, the registry information in the Boot partition also needs to be changed into the GUID information of the new Boot partition.
The beneficial effects of the invention are as follows: according to the invention, only the used part of the file system can be cloned according to the size of the file system, and the partition of the target disk can be selected and adjusted, so that the cloning speed is improved; the size of the file system can be adjusted in the cloning process, the cloning of the file system is realized, and the guiding information and the configuration information of the operating system can be repaired.
Drawings
FIG. 1 is a schematic diagram of a disk cloning method according to embodiment 1 of the present invention;
FIG. 2 is a schematic diagram of a disk cloning system according to embodiment 2 of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. The components of the embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Example 1
As an embodiment, as shown in fig. 1, to solve the above technical problem, the present embodiment provides a disk cloning method, including:
acquiring source disk information and reading partition information of each source disk;
selecting a target disk and acquiring size information of a partition of the target disk;
locking a source disk, creating a snapshot if the source disk cannot be locked, and restarting the system to enter Wi windows PE to clone the disk if the source disk cannot be locked and the snapshot cannot be created;
reading used information of a file system, constructing a starting position of a sector to be cloned and a sector quantity to be continuously copied according to the used information of the file system, and obtaining target file information; file system refers to the file format on disk in the segment area, if on a C disk on Wi windows operating system, the file system is usually NTFS, the file system is many on different operating systems, common file systems such as FAT, FAT32, FAT16, NTFS, EXFAT, HFS, EXT; the size of the target file system is constructed according to the size of the target disk to be cloned, for example: if the total size of the source file system is 100GB, the used space is 50GB, the target file system is only 60GB, and although the target file system 60GB is smaller than the source file system 100GB but larger than the 50GB of the used space of the source file system, the size of the source file system is constructed into a 60GB file system, so that the target file system can be cloned, namely: the source file system is built into the clone process and reconstructed into a smaller or larger file system and written to the target disk.
Calculating the position of a target partition written into the target disk according to the size of the partition of the source disk and the size of the partition of the target disk, writing target file information of a sector read out from the partition of the source disk into the target partition of the target disk, and reconstructing file record information (the file record information refers to index information of data in a file system) and bitmap information according to the written position of the target partition until the data of the sectors read out from all the partitions on the source disk are cloned into the target disk;
reconstructing a partition table according to the starting position and the size of a target partition of a target disk and the type of the target disk, and writing the reconstructed partition table into the target disk;
if the source disk has an operating system file, after the data of the sectors read out by all the partitions on the source disk are copied to the target disk, repairing the guiding information and the configuration information of the operating system according to the type of the target disk;
restarting the computer, selecting a target disk from a Boot (system guide item) menu of the B IOS as a starting disk for starting, and starting the cloned operating system.
Optionally, reading partition parameters of the target disk includes: the computer system analyzes the partition table of the target disk or obtains partition information on each target disk through an interface provided by an operating system, wherein the partition information comprises a starting sector, a total sector number, a block size, a volume label, a disk symbol and a symbol link of the partition.
In the actual application process, the system constructs disk partition information displayed to the user according to the acquired source disk information and partition parameters of the target disk, and the user selects the source disk to be cloned according to the displayed disk partition information. And the user selects the target disk according to the requirements, if the target disk is a non-empty disk, the user is reminded that the partitions of the target disk are all cleared when executing the next step, and if the target disk is an empty disk, reminding is not needed. The user can change the partition size of the target disk and pre-adjust the partition parameters cloned to the target disk.
Optionally, adjusting partition parameters of the target disk includes: the system adjusts the size of the partition of the target disk, or the user manually edits and sets the size of each partition of the target disk, if the target disk is smaller than the source disk and the used space of the partition on the source disk is smaller than the total size of the target disk, all the partitions which need to be cloned to the target disk are reduced in an equal proportion in the memory so as to adapt to the capacity of the target disk; if the used space of all the partitions of the source disk is larger than the total size of the target disk, prompting that the space of the target disk is insufficient; if the space of the target disk is larger than that of the source disk, expanding each partition according to the proportion of each partition of the source disk to the total space of the source disk so as to occupy the whole source disk; if the target disk is as large as the source disk, cloning is performed according to the size of the partition of the source disk.
In the practical application process, the partition parameters of the target disk are adjusted according to the sizes of the target disk and the source disk, and the partition of the target disk is adjusted to be in a state suitable for the size of the target disk, so that the cloning speed can be improved, and the integrity of the target file information to be cloned can be ensured.
The system performs cloning according to partition parameters of the target disk set by a user, wherein the cloning step comprises the steps of locking a volume, analyzing a file system, cloning according to a target position and a sector used by the source file system, and repairing the operating system according to the guiding information and configuration information of the operating system on the target disk after the cloning is completed if the source disk comprises the operating system.
Optionally, calculating the position of the target partition written into the target disk according to the size of the partition of the source disk and the size of the partition of the target disk, and writing the target file information of the sector read out from the partition of the source disk into the target partition of the target disk, including: if the selected target partition cloned to the target disk is as large as the partition of the source disk or the partition of the target disk is larger than the target partition of the source disk, directly writing the target file information of the sector read from the partition of the source disk into the target partition of the target disk; if the target partition of the target disk is smaller than the size of the partition of the source disk, the write location needs to be recalculated at the time of writing the data according to the size of the target partition.
In the practical application process, according to the size of the partition of the source disk and the size of the partition of the target disk, a proper target partition is selected by calculating the writing position, so that the cloning speed is improved, and the integrity of target file information to be cloned is guaranteed.
Optionally, calculating the position of the target partition written into the target disk according to the size of the partition of the source disk and the size of the partition of the target disk, and writing the target file information of the sector read out from the partition of the source disk into the target partition of the target disk, including:
acquiring information of a source disk file system;
changing a file system according to the size of a partition of a set target disk, if the file system is enlarged, copying data of an original file system to a target position of the target disk, and then reconstructing information of a new file system according to the size of the file system, wherein the information comprises a bitmap and a DBR (DOS Boot Record); if the file system is reduced, firstly, file record information of a new file system is built in the memory of the computer, and fragments of the original file system are adjusted in the copying process, so that fragments exceeding the new size area can be accommodated by the adjusted fragments.
In the practical application process, the size of the file system is changed according to the size of the partition of the target disk, so that the aim of improving cloning efficiency is fulfilled.
Optionally, reconstructing the partition table according to the starting position and the size of the target partition of the target disk and the type of the target disk, and writing the reconstructed partition table into the target disk, including: if the target disk is a GPT disk (GUID Partition Table, globally unique identification partition table), generating a new GUID (Globally Unique Identifier ) for each target partition, constructing a new partition table according to the GUID of the target partition, and writing the new partition table into the target disk; if the target disk is an MBR (Master Boot Record, master boot record of hard disk) disk, reconstructing an MBR partition table according to the starting position and size of the target partition, and writing the reconstructed partition table into the target disk.
Optionally, repairing the boot information and the configuration information of the operating system according to the type of the target disk includes: if the target disk is a GPT disk, acquiring GUIDs of a System partition and a Boot partition of the target disk, and updating the GUIDs into a BCD file of the System partition; if the target disk is an MBR disk, updating the disk signature of the target disk, the starting position of the System partition and the starting position of the Boot partition into a BCD file; if the operating System of the target disk is an operating System below Windows Vista, modifying path guiding data in a guiding information file of a System partition according to path guiding data of the System partition and a Boot partition of the target disk, and then repairing disk symbol information in the Boot partition; if the target disk is a GPT disk, the key value of the registry of the disk symbol of the C disk is found, and then the GUID of the Boot partition of the target disk is filled into the key value of the registry of the disk symbol of the C disk; and if the target disk is an MBR disk, filling the disk signature of the Boot partition of the target disk and the starting position of the Boot partition into the key value of the registry of the disk symbol of the C disk.
Optionally, the file system is a FAT32 (File Allocation Table ) file system or an NTFS (New Technology File System ) file system; and acquiring a main file table and bitmap information of the NTFS, adjusting data exceeding the bitmap according to the bitmap information, modifying file record information of the data exceeding the bitmap, updating the main file table of the NTFS after completing data cloning, finding the file record information to be adjusted in the memory of the computer, and adjusting to complete the adjustment of the NTFS.
Optionally, repairing the boot information and the configuration information of the operating system according to the type of the target disk includes:
judging whether the operating system is in Legacy mode (BIOS transmission mode starting sequence) or UEFI (Unified Extensible Firmware Interface ) mode, and executing a corresponding repairing method according to the mode of the operating system:
if the migrated operating System is in the Legacy mode, modifying the position information of the System partition and the Boot partition in the BCD file, changing the System and the Boot information before migration into the disk signature corresponding to the System and the Boot information after migration and the starting position of the target partition, modifying the registry file in the Boot partition, and changing the information of the disk signature disk of the source disk into the disk signature and the starting position information of the new Boot partition;
if the migrated System is in the UEFI mode, the information of the System partition, the Boot partition and the Recover partition in the BCD file needs to be changed into corresponding disk GUID information and partition GUID information, and similarly, the registry information in the Boot partition also needs to be changed into the GUID information of the new Boot partition. The partitions of the target disk are disk clone migration, and only the file system is migrated, and since each partition has a unique identifier and cannot be repeated with a source, the target partition needs to be reassigned with a unique identifier, namely GUID information.
The beneficial effects of the invention are as follows: according to the invention, only the used part of the file system can be cloned according to the size of the file system, and the partition of the target disk can be selected and adjusted, so that the cloning speed is improved; the size of the file system can be adjusted at will in the cloning process, the cloning of the file system is realized, and the guiding information and the configuration information of the operating system can be repaired.
Example 2
Based on the same principle as the method shown in embodiment 1 of the present invention, there is also provided a disk cloning method in an embodiment of the present invention, including a reading unit, a parameter adjusting unit, an analyzing unit, a constructing unit, a cloning unit, a writing unit, a repairing unit, and a starting unit;
the reading unit is used for acquiring the source disk information and reading the partition information of each block of source disk;
the parameter adjusting unit is used for acquiring the size information of the partition of the target disk;
the analysis unit is used for locking the source disk, creating a snapshot if the source disk cannot be locked, and restarting the system to enter Wi windows PE to clone the disk if the source disk cannot be locked and the snapshot cannot be created;
the construction unit is used for reading the used information of the file system, constructing the starting position of the sector needing cloning and the sector quantity needing continuous copying according to the used information of the file system, and obtaining target file information;
the cloning unit is used for calculating the position of a target partition written into the target disk according to the size of the partition of the source disk and the size of the partition of the target disk, writing target file information of a sector read out from the partition of the source disk into the target partition of the target disk, and reconstructing file record information and bitmap information according to the written position of the target partition until the data of the sectors read out from all the partitions on the source disk are cloned into the target disk;
the writing unit is used for rebuilding a partition table according to the starting position and the size of a target partition of the target disk and the type of the target disk and writing the rebuilt partition table into the target disk;
the restoring unit is used for restoring the guide information and the configuration information of the operating system according to the type of the target disk after the data of the sectors read out by all the partitions on the source disk are copied to the target disk when the operating system file exists in the source disk;
the starting unit is used for restarting the computer, selecting a target disk from a Boot menu of the B IOS as a starting disk for starting, and starting the cloned operating system.
Optionally, reading partition parameters of the target disk includes: the computer system analyzes the partition table of the target disk or obtains partition information on each target disk through an interface provided by an operating system, wherein the partition information comprises a starting sector, a total sector number, a block size, a volume label, a disk symbol and a symbol link of the partition.
Optionally, adjusting partition parameters of the target disk includes: the system adjusts the size of the partition of the target disk, or the user manually edits and sets the size of each partition of the target disk, if the target disk is smaller than the source disk and the used space of the partition on the source disk is smaller than the total size of the target disk, all the partitions which need to be cloned to the target disk are reduced in an equal proportion in the memory so as to adapt to the capacity of the target disk; if the used space of all the partitions of the source disk is larger than the total size of the target disk, prompting that the space of the target disk is insufficient; if the space of the target disk is larger than that of the source disk, expanding each partition according to the proportion of each partition of the source disk to the total space of the source disk so as to occupy the whole source disk; if the target disk is as large as the source disk, cloning is performed according to the size of the partition of the source disk.
Optionally, calculating the position of the target partition written into the target disk according to the size of the partition of the source disk and the size of the partition of the target disk, and writing the target file information of the sector read out from the partition of the source disk into the target partition of the target disk, including: if the selected target partition cloned to the target disk is as large as the partition of the source disk or the partition of the target disk is larger than the target partition of the source disk, directly writing the target file information of the sector read from the partition of the source disk into the target partition of the target disk; if the target partition of the target disk is smaller than the size of the partition of the source disk, the write location needs to be recalculated at the time of writing the data according to the size of the target partition.
Optionally, calculating the position of the target partition written into the target disk according to the size of the partition of the source disk and the size of the partition of the target disk, and writing the target file information of the sector read out from the partition of the source disk into the target partition of the target disk, including:
acquiring information of a source disk file system;
changing a file system according to the size of a partition of a set target disk, copying data of an original file system to a target position of the target disk if the file system is enlarged, and reconstructing information of a new file system according to the size of the file system, wherein the information comprises a bitmap and a DBR; if the file system is reduced, firstly, file record information of a new file system is built in the memory of the computer, and fragments of the original file system are adjusted in the copying process, so that fragments exceeding the new size area can be accommodated by the adjusted fragments.
Optionally, reconstructing the partition table according to the starting position and the size of the target partition of the target disk and the type of the target disk, and writing the reconstructed partition table into the target disk, including: if the target disk is a GPT disk, generating a new GU ID for each target partition, constructing a new partition table according to the GU ID of the target partition, and writing the new partition table into the target disk; if the target disk is an MBR disk, reconstructing an MBR partition table according to the starting position and the size of the target partition, and writing the reconstructed partition table into the target disk.
Optionally, repairing the boot information and the configuration information of the operating system according to the type of the target disk includes: if the target disk is a GPT disk, acquiring GUIDs of a System partition and a Boot partition of the target disk, and updating the GUIDs into a BCD file of the System partition; if the target disk is an MBR disk, updating the disk signature of the target disk, the starting position of the System partition and the starting position of the Boot partition into a BCD file; if the operating System of the target disk is an operating System below Wi-windows Vista (such as Wi-windows Vista operating System, wi-windows XP operating System and the like), modifying path guiding data in a guiding information file of a System partition according to the path guiding data of the System partition and a Boot partition of the target disk, and then repairing the disk symbol information in the Boot partition; if the target disk is a GPT disk, the key value of the registry of the disk symbol of the C disk is found, and then the GU ID of the Boot partition of the target disk is filled into the key value of the registry of the disk symbol of the C disk; and if the target disk is an MBR disk, filling the disk signature of the Boot partition of the target disk and the starting position of the Boot partition into the key value of the registry of the disk symbol of the C disk.
Optionally, the file system is a FAT32 file system or an NTFS file system; and acquiring a main file table and bitmap information of the NTFS, adjusting data exceeding the bitmap according to the bitmap information, modifying file record information of the data exceeding the bitmap, updating the main file table of the NTFS after completing data cloning, finding the file record information to be adjusted in the memory of the computer, and adjusting to complete the adjustment of the NTFS.
Optionally, repairing the boot information and the configuration information of the operating system according to the type of the target disk includes:
judging whether the operating system is in Legacy mode or UEF I mode, and executing a corresponding repairing method according to the mode of the operating system:
if the migrated operating System is in the Legacy mode, modifying the position information of the System partition and the Boot partition in the BCD file, changing the System and the Boot information before migration into the disk signature corresponding to the System and the Boot information after migration and the starting position of the target partition, modifying the registry file in the Boot partition, and changing the information of the disk signature disk of the source disk into the disk signature and the starting position information of the new Boot partition;
if the migrated System is in the UEFI mode, the information of the System partition, the Boot partition and the Recover partition in the BCD file needs to be changed into corresponding disk GUID information and partition GUID information, and similarly, the registry information in the Boot partition also needs to be changed into the GUID information of the new Boot partition.
The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method of disk cloning comprising:
acquiring source disk information and reading partition information of each source disk;
selecting a target disk and acquiring size information of a partition of the target disk;
locking a source disk, creating a snapshot if the source disk cannot be locked, and restarting the system to enter Wi windows PE to clone the disk if the source disk cannot be locked and the snapshot cannot be created;
reading used information of a file system, constructing a starting position of a sector to be cloned and a sector quantity to be continuously copied according to the used information of the file system, and obtaining target file information;
calculating the position of a target partition written into the target disk according to the size of the partition of the source disk and the size of the partition of the target disk, writing target file information read out from the partition of the source disk into the target partition of the target disk, and reconstructing file record information and bitmap information according to the written position of the target partition until the data of the sectors read out from all the partitions on the source disk are cloned into the target disk;
reconstructing a partition table according to the starting position and the size of a target partition of a target disk and the type of the target disk, and writing the reconstructed partition table into the target disk;
if the source disk has an operating system file, after the data of the sectors read out by all the partitions on the source disk are copied to the target disk, repairing the guiding information and the configuration information of the operating system according to the type of the target disk;
restarting the computer, selecting a target disk from a Boot menu of the B IOS as a starting disk for starting, and starting the cloned operating system.
2. The disk cloning method as set forth in claim 1, wherein reading partition parameters of the target disk includes: the computer system analyzes the partition table of the target disk or obtains partition information on each target disk through an interface provided by an operating system, wherein the partition information comprises a starting sector, a total sector number, a block size, a volume label, a disk symbol and a symbol link of the partition.
3. The disk cloning method according to claim 1, wherein adjusting partition parameters of the target disk comprises: the system adjusts the size of the partition of the target disk, or the user manually edits and sets the size of each partition of the target disk, if the target disk is smaller than the source disk and the used space of the partition on the source disk is smaller than the total size of the target disk, all the partitions which need to be cloned to the target disk are reduced in an equal proportion in the memory so as to adapt to the capacity of the target disk; if the used space of all the partitions of the source disk is larger than the total size of the target disk, prompting that the space of the target disk is insufficient; if the space of the target disk is larger than that of the source disk, expanding each partition according to the proportion of each partition of the source disk to the total space of the source disk so as to occupy the whole source disk; if the target disk is as large as the source disk, cloning is performed according to the size of the partition of the source disk.
4. The disk cloning method according to claim 1, wherein calculating a position of a target partition written to the target disk based on a size of the partition of the source disk and a size of the partition of the target disk, writing target file information of a sector read from the partition of the source disk to the target partition of the target disk, comprises: if the selected target partition cloned to the target disk is as large as the partition of the source disk or the partition of the target disk is larger than the target partition of the source disk, directly writing the target file information of the sector read from the partition of the source disk into the target partition of the target disk; if the target partition of the target disk is smaller than the size of the partition of the source disk, the write location needs to be recalculated at the time of writing the data according to the size of the target partition.
5. The disk cloning method according to any one of claims 1 or 4, wherein calculating a position of a target partition written to the target disk based on a size of the partition of the source disk and a size of the partition of the target disk, writing target file information of a sector read from the partition of the source disk to the target partition of the target disk, comprises:
acquiring information of a source disk file system;
changing a file system according to the size of a partition of a set target disk, copying data of an original file system to a target position of the target disk if the file system is enlarged, and reconstructing information of a new file system according to the size of the file system, wherein the information comprises a bitmap and a DBR; if the file system is reduced, a file record of the new file system is firstly built in the memory of the computer, and fragments of the original file system are adjusted in the copying process, so that fragments exceeding the new-size area can be accommodated by the adjusted fragments.
6. The disk cloning method according to claim 1, wherein reconstructing the partition table according to the start position, the size and the type of the target partition of the target disk and writing the reconstructed partition table to the target disk comprises: if the target disk is a GPT disk, generating a new GUID for each target partition, constructing a new partition table according to the GUID of the target partition, and writing the new partition table into the target disk; if the target disk is an MBR disk, reconstructing an MBR partition table according to the starting position and the size of the target partition, and writing the reconstructed partition table into the target disk.
7. The disk cloning method according to claim 1, wherein repairing the boot information and the configuration information of the operating system according to the type of the target disk comprises: if the target disk is a GPT disk, acquiring GUIDs of a System partition and a Boot partition of the target disk, and updating the GUIDs into a BCD file of the System partition; if the target disk is an MBR disk, updating the disk signature of the target disk, the starting position of the System partition and the starting position of the Boot partition into a BCD file; if the operating System of the target disk is an operating System below Windows Vista, modifying path guiding data in a guiding information file of a System partition according to path guiding data of the System partition and a Boot partition of the target disk, and then repairing disk symbol information in the Boot partition; if the target disk is a GPT disk, the key value of the registry of the disk symbol of the C disk is found, and then the GUID of the Boot partition of the target disk is filled into the key value of the registry of the disk symbol of the C disk; and if the target disk is an MBR disk, filling the disk signature of the Boot partition of the target disk and the starting position of the Boot partition into the key value of the registry of the disk symbol of the C disk.
8. The disc cloning method according to claim 7, wherein the file system is a FAT32 file system or an NTFS file system; and acquiring a main file table and bitmap information of the NTFS, adjusting data exceeding the bitmap according to the bitmap information, modifying file record information of the data exceeding the bitmap, finding the file record information to be adjusted in a memory of a computer, and adjusting to finish the adjustment of the NTFS.
9. The disk cloning method according to claim 1, wherein repairing the boot information and the configuration information of the operating system according to the type of the target disk comprises:
judging whether the operating system is in a Legacy mode or a UEFI mode, and executing a corresponding repairing method according to the mode of the operating system:
if the migrated operating System is in the Legacy mode, modifying the position information of the System partition and the Boot partition in the BCD file, changing the System and the Boot information before migration into the disk signature corresponding to the System and the Boot information after migration and the starting position of the target partition, modifying the registry file in the Boot partition, and changing the information of the disk signature disk of the source disk into the disk signature and the starting position information of the new Boot partition;
if the migrated System is in the UEF I mode, the information of the System partition, the Boot partition and the Recover partition in the BCD file needs to be changed into corresponding disk GUID information and partition GUID information, and similarly, the registry information in the Boot partition also needs to be changed into the GUID information of the new Boot partition.
10. The disk cloning system is characterized by comprising a reading unit, a parameter adjusting unit, an analyzing unit, a constructing unit, a cloning unit, a writing unit, a repairing unit and a starting unit;
the reading unit is used for acquiring the source disk information and reading the partition information of each block of source disk;
the parameter adjusting unit is used for acquiring the size information of the partition of the target disk;
the analysis unit is used for locking the source disk, creating a snapshot if the source disk cannot be locked, and restarting the system to enter Windows PE for disk cloning if the source disk cannot be locked and the snapshot cannot be created;
the construction unit is used for reading the used information of the file system, constructing the starting position of the sector needing cloning and the sector quantity needing continuous copying according to the used information of the file system, and obtaining target file information;
the cloning unit is used for calculating the position of a target partition written into the target disk according to the size of the partition of the source disk and the size of the partition of the target disk, writing target file information of a sector read out from the partition of the source disk into the target partition of the target disk, and reconstructing file record information and bitmap information according to the written position of the target partition until the data of the sectors read out from all the partitions on the source disk are cloned into the target disk;
the writing unit is used for rebuilding a partition table according to the starting position and the size of a target partition of the target disk and the type of the target disk and writing the rebuilt partition table into the target disk;
the restoring unit is used for restoring the guide information and the configuration information of the operating system according to the type of the target disk after the data of the sectors read out by all the partitions on the source disk are copied to the target disk when the operating system file exists in the source disk;
the starting unit is used for restarting the computer, selecting a target disk from a Boot menu of the BIOS as a starting disk for starting, and starting the cloned operating system.
CN202311119150.XA 2023-08-31 2023-08-31 Disk cloning method and system Active CN117112304B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311119150.XA CN117112304B (en) 2023-08-31 2023-08-31 Disk cloning method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311119150.XA CN117112304B (en) 2023-08-31 2023-08-31 Disk cloning method and system

Publications (2)

Publication Number Publication Date
CN117112304A true CN117112304A (en) 2023-11-24
CN117112304B CN117112304B (en) 2024-02-20

Family

ID=88812523

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311119150.XA Active CN117112304B (en) 2023-08-31 2023-08-31 Disk cloning method and system

Country Status (1)

Country Link
CN (1) CN117112304B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117707438A (en) * 2024-02-06 2024-03-15 成都艾勃科技有限公司 Partition incremental cloning method

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1622018A1 (en) * 2003-05-06 2006-02-01 Lenovo (Beijing) Limited A method for renovating the computer operating system
CN102253985A (en) * 2011-06-30 2011-11-23 深圳市江波龙电子有限公司 File system data management method and system
CN105095017A (en) * 2014-05-23 2015-11-25 中兴通讯股份有限公司 Partition table based hard disk repair method and apparatus
CN112380071A (en) * 2020-12-09 2021-02-19 成都傲梅科技有限公司 Method for quickly backing up NTFS file system
CN112416657A (en) * 2020-12-09 2021-02-26 成都傲梅科技有限公司 System cloning method
CN114138563A (en) * 2021-12-06 2022-03-04 成都傲梅科技有限公司 Method for backing up and restoring Hyper-V virtual machine
CN115509824A (en) * 2022-11-23 2022-12-23 深圳市科力锐科技有限公司 Data backup method, device, equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1622018A1 (en) * 2003-05-06 2006-02-01 Lenovo (Beijing) Limited A method for renovating the computer operating system
CN102253985A (en) * 2011-06-30 2011-11-23 深圳市江波龙电子有限公司 File system data management method and system
CN105095017A (en) * 2014-05-23 2015-11-25 中兴通讯股份有限公司 Partition table based hard disk repair method and apparatus
CN112380071A (en) * 2020-12-09 2021-02-19 成都傲梅科技有限公司 Method for quickly backing up NTFS file system
CN112416657A (en) * 2020-12-09 2021-02-26 成都傲梅科技有限公司 System cloning method
CN114138563A (en) * 2021-12-06 2022-03-04 成都傲梅科技有限公司 Method for backing up and restoring Hyper-V virtual machine
CN115509824A (en) * 2022-11-23 2022-12-23 深圳市科力锐科技有限公司 Data backup method, device, equipment and storage medium

Non-Patent Citations (7)

* Cited by examiner, † Cited by third party
Title
XIN ZHAO等: "Prism: Providing Flexible and Fast Filesystem Cloning Service for Virtual Servers", 《ACM/IFIP/USENIX INTERNATIONAL CONFERENCE ON DISTRIBUTED SYSTEMS PLATFORMS AND OPEN DISTRIBUTED PROCESSING》, vol. 5346, 31 December 2008 (2008-12-31), pages 388, XP019112941 *
张沪滨: "面向QEMU的分布式块存储系统的设计与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》, no. 3, 15 March 2020 (2020-03-15), pages 137 - 158 *
樱子: "硬盘数据整体高效迁移", 《电脑爱好者》, no. 5, 1 March 2014 (2014-03-01), pages 9 - 10 *
王德军;王丽娜;郝永芳;: "裸机备份与恢复技术研究", 计算机应用研究, no. 12, 15 December 2008 (2008-12-15), pages 3735 - 3738 *
蒋金艳;: "硬盘数据的备份与恢复", 安康师专学报, no. 04, 30 August 2006 (2006-08-30), pages 77 - 80 *
郭溪川;: "硬盘分区数据的备份与恢复", 农业网络信息, no. 02, 26 February 2007 (2007-02-26), pages 125 - 127 *
陈培德;吴建平;王丽清;: "重建NTFS的DBR及分区表的研究与实现", 实验科学与技术, no. 06, 28 December 2016 (2016-12-28), pages 56 - 59 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117707438A (en) * 2024-02-06 2024-03-15 成都艾勃科技有限公司 Partition incremental cloning method
CN117707438B (en) * 2024-02-06 2024-05-14 成都艾勃科技有限公司 Partition incremental cloning method

Also Published As

Publication number Publication date
CN117112304B (en) 2024-02-20

Similar Documents

Publication Publication Date Title
EP1739535B1 (en) File system storing transaction records in flash-like media
EP1744246B1 (en) File system having deferred verification of data integrity
CA2818472C (en) Optimized startup verification of file system integrity
US8001165B2 (en) Storage system format for transaction safe file system
US20070136387A1 (en) Transaction-Safe FAT Files System
CN117112304B (en) Disk cloning method and system
EP1739575A2 (en) File system having inverted hierarchical structure
JPH1069408A (en) Data storage method and device at file system level utilizing hole
CN107239526A (en) File system implementation method, scrap cleaning method, operating position localization method
US10423580B2 (en) Storage and compression of an aggregation file
CN106709014B (en) File system conversion method and device
CN109062516B (en) Method for eliminating invalid data in backup process of windows virtual machine
CN107436761B (en) UEFI (unified extensible firmware interface) system and traditional system coexistence management method based on UEFI mainboard
CN112416657A (en) System cloning method
CN109164988A (en) Processor-based virtual machine snapshot method and system
CN111399774B (en) Data processing method and device based on snapshot under distributed storage system
CN109739437B (en) Method for expanding root partition based on cloud platform Linux virtual machine
CN108776596B (en) Enhancement method and system based on Windows To Go
CN114158258B (en) Method for dynamically generating file system compatibility in real time
CN109062510A (en) A kind of data migration method and system
CN114356797A (en) Solid-state storage method, system and equipment based on file system optimization
CN107608636A (en) A kind of data acquisition device of design method and its application based on FAT file system
CN106557275A (en) A kind of method and device of data processing
KR20030090423A (en) Apparatus For Storage Floppy Data Through Flash Memory Card

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant