[go: up one dir, main page]

CN119884031A - Method for migrating Windows system by file copy mode - Google Patents

Method for migrating Windows system by file copy mode Download PDF

Info

Publication number
CN119884031A
CN119884031A CN202411992032.4A CN202411992032A CN119884031A CN 119884031 A CN119884031 A CN 119884031A CN 202411992032 A CN202411992032 A CN 202411992032A CN 119884031 A CN119884031 A CN 119884031A
Authority
CN
China
Prior art keywords
folder
file
data
source
redirected
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411992032.4A
Other languages
Chinese (zh)
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 CN202411992032.4A priority Critical patent/CN119884031A/en
Publication of CN119884031A publication Critical patent/CN119884031A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/119Details of migration of file systems
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices

Landscapes

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

Abstract

本发明公开了一种通过文件拷贝的方式迁移Wi ndows系统的方法,包括判断备份系统环境是否为PE系统;遍历源系统分区中的所有文件或文件夹;判断遍历返回值中的文件名、文件属性以及类型;继续查找剩余的文件或文件夹,直到拷贝完所有文件或文件夹;修复MountedDevi ces以及修复系统引导,完成迁移。本发明中的方案,通过逐个文件和文件夹的遍历与拷贝,确保源系统中的所有数据。在复制文件夹时,会将源文件夹的属性(如权限、所有权、访问控制列表ACL等)复制到目标文件夹,确保用户权限和文件安全性保持一致。对于重定向文件夹进行特殊处理,能够保持这些文件夹的原有指向,确保用户的设置和习惯在迁移后仍能保持不变。

The present invention discloses a method for migrating a Windows system by means of file copying, comprising determining whether a backup system environment is a PE system; traversing all files or folders in a source system partition; determining the file name, file attribute and type in the traversal return value; continuing to search for the remaining files or folders until all files or folders are copied; repairing MountedDevices and repairing the system boot to complete the migration. The scheme of the present invention ensures all data in the source system by traversing and copying files and folders one by one. When copying a folder, the attributes of the source folder (such as permissions, ownership, access control list ACL, etc.) are copied to the target folder to ensure that user permissions and file security remain consistent. Special processing is performed on redirected folders to maintain the original directions of these folders, ensuring that the user's settings and habits remain unchanged after migration.

Description

Method for migrating Windows system by file copy mode
Technical Field
The invention belongs to the technical field of computer data backup, and particularly relates to a method for migrating a Windows system in a file copy mode.
Background
As the Windows system is used, with the installation and updating of various application programs and the generation of temporary files, the disk space occupied by the system itself is gradually increased, so that the storage space of the C disk becomes more and more tense. This not only affects the speed of operation of the system, but may also cause some applications to fail to start or operate properly. In addition, in view of the user's demands for system performance, many people want to migrate an operating system originally installed on a mechanical hard disk to a Solid State Disk (SSD) for faster read-write speeds and smoother use experience.
In the prior art, for example, the technical scheme disclosed in the patent with the publication number of CN116414797A is that a method for copying the system file is provided, and by integrating a plurality of types of hard disk interfaces into a hard disk read-write device, the method can copy the file of an operating system into a copy disc based on the technical scheme that the established copy copies the file of the operating system into the copy disc, and the file of the operating system can be copied without limiting the type and the size of the copy disc.
In the prior art, the system is copied by integrating the hard disk interfaces into the hard disk read-write device, and in practical application, the performance of the USB3.0 interface is affected by other factors (such as host performance, file size, number, etc.), so that the Windows system cannot be migrated onto other disks efficiently.
Disclosure of Invention
The invention aims to provide a method for migrating a Windows system by a file copy mode, which aims to solve the problem that the prior art proposal provided in the background art cannot efficiently migrate the Windows system to other disks.
In order to solve the technical problems, the invention adopts the following technical scheme:
A method for migrating a Windows system by means of file copying, comprising the steps of:
step S1, firstly judging whether the backup system environment is a PE system or not, if so, not creating a snapshot, and if not, firstly creating a snapshot for a partition of a source system;
step S2, traversing all files or folders in the source system partition;
Step S3, judging whether the file name in the traversal return value is a special character, if so, skipping and jumping to step S6, and if not, entering step S4;
Step S4, judging whether the file attribute is a folder, if so, entering step S5, if so, copying the document to a target partition and jumping to step S6;
S5, judging whether the folder is a redirection folder, if so, configuring the redirection folder in a target partition so that the redirection folder keeps the original direction, if not, creating the folder in the target partition, setting file attributes in the source folder into the folder created in the target partition, and acquiring ownership and ACL information of the source folder and setting the ownership and ACL information into the newly created folder;
Step S6, searching for the rest files or folders continuously until all files or folders are copied;
and step S7, repairing MountedDevices and repairing system guidance to finish migration.
According to the above technical solution, in step S1, when a snapshot of the source system is created, the snapshot is created through create in the ISn apshotMgr module, and after the snapshot is created successfully, the sign link of the snapshot is obtained by using GetSymbolByDriveLetter function in the ISnap shotMgr module.
According to the above technical solution, in step S2, the windows api function FINDFIRSTFILE is used to search the file from the source partition root directory.
According to the technical scheme, in the step S3, whether the FILE ATTRIBUTE is the folder body is judged, namely whether the FILE ATTRIBUTE is the folder is judged according to the FILE ATTRIBUTE in the traversal return value, if dwFileAttributes & file_attribute_direction condition is true, the FILE is indicated to be the folder, and otherwise, the FILE is the FILE.
According to the technical scheme, in the step S5, whether the folder is redirected is judged to be a common folder or not if dwFileAttributes & file_ATTRIBUTE_REPARSE_POIN condition is true, which indicates that the folder is redirected to other folders, and if false.
According to the above technical solution, in step S5, the configuration of the redirection folder includes creating the same folder, setting the folder attribute, obtaining the redirection directory, and setting the redirection directory.
According to the technical scheme, the same folder is created in the target partition, and the folder attribute is set by using windowsAPICreateDirectory to create the redirection folder in the target partition, and setting the dwFileAttributes value read from the source file into the newly created folder by using an API function SetFileAttributes.
According to the technical scheme, the redirection catalog is obtained from the source folder, specifically, an API function CreateFile function is used for opening a handle of the source folder, a DeviceIoControl function is used, and an FSCTL_GET_REPARSE_POINT control code is used for obtaining redirection data in the source folder;
Judging the type of the data according to the link type in the redirected data, wherein the judging method is REPARSETAG = = IO_REPARSE_TAG_MOUNT_POINT, if the condition is true, the obtained data is mounting POINT data, a redirected folder address is contained in the obtained data, and otherwise, the obtained data is not contained;
Further, the method comprises the steps of, the data type includes IO_REPARSE tag_MOUNT_POINT tag_mobile POINT. Wherein the type of IO_REPARSE_TAG_MOUNT_POINT corresponds to MountPointReparseBuffer fabric in the REPARSE_DATA_BUFFER's complex, the required redirection folder is inside PathBuffer in MountPointReparseBuffer fabric.
According to PathBuffer in the REPARSE_DATA_BUFFER structure, the path is the path of the redirection folder, and the address of the redirection folder is saved so as to be set in the newly built folder of the target partition.
According to the technical scheme, the redirection catalog is set for the newly created folder in the target partition, specifically, a windowsAPI function CreateFile function is used for opening a handle of the folder created in the target partition, and data of a REPARSE structure is initialized, wherein REPARSETAG is equal to the length of IO_REPARSE_TAG_MOUNT_ POINT, reparseDataLength and calculated according to the actual length of the redirection catalog;
Next, the complex in the structure of reparse_data_buffer uses the structure of MountPointReparseBuffer, the DATA in MountPointReparseBuffer is populated according to the acquired DATA of the redirection folder, and then the REPARSE DATA of the folder in the target partition is set using the windowsAPI function DeviceIoControl function and using the fsctl_get_reparse_point control code.
According to the technical scheme, ownership and ACL information of the source folder are set into the newly created folder of the target partition:
The size of the source file or folder security attribute is obtained using windowsAPI function GetFileSecurity, a piece of memory space of the obtained size is allocated using HeapAlloc function and the space data is all initialized to 0, the security attribute of the source file or folder is obtained using windows API function GetFileSecurity, then the obtained security attribute is set to the file or folder of the target partition using windowsAPI function SetFileSecurity, and finally the allocated memory space is released.
Compared with the prior art, the invention has the following beneficial effects:
According to the scheme, all data in the source system, including system files, application program files, user data and the like, can be completely migrated to the target partition through traversing and copying file by file and folder. When copying the folder, the attributes (such as authority, ownership, access Control List (ACL), etc.) of the source folder are copied to the target folder, so that the user authority and the file security are ensured to be consistent. Special handling of the redirection folders can keep the original pointing of these folders, such as "my documents", "desktop", etc., ensuring that the user's settings and habits remain unchanged after migration. By repairing MountedDevices and system guiding, the new system can be ensured to be started normally, and the starting problem caused by migration is avoided. By skipping special character files and flexibly processing different types of files, the user friendliness of the migration process is enhanced, and the possibility of manual intervention and operation errors of a user is reduced. The method is suitable for migration of various Windows systems, whether data migration of individual users or migration of systems in enterprise environments.
Drawings
FIG. 1 is a main flow chart of system migration in the present invention;
FIG. 2 is a flow chart of system migration in accordance with the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1
As shown in fig. 1, a method for migrating a Windows system by means of file copying includes the following steps:
step S1, firstly judging whether the backup system environment is a PE system or not, if so, not creating a snapshot, and if not, firstly creating a snapshot for a partition of a source system;
Step S2, traversing all files in the source system partition;
Step S3, judging whether the file name in the traversal return value is a special character, if so, skipping and jumping to step S6, and if not, entering step S4;
Step S4, judging whether the file attribute is a folder, if so, entering a step S5, and if so, copying the file to a target partition and jumping to a step S6;
S5, judging whether the folder is a redirection folder, if so, configuring the redirection folder in a target partition so that the redirection folder keeps the original direction, if not, creating the folder in the target partition, setting file attributes in the source folder into the folder created by the target partition, and acquiring ownership and ACL information of the source folder and setting the ownership and ACL information into the newly created folder;
Step S6, searching for the rest files or folders continuously until all files or folders are copied;
and step S7, repairing MountedDevices and repairing system guidance to finish migration.
According to the scheme, all data in the source system, including system files, application program files, user data and the like, can be completely migrated to the target partition through traversing and copying file by file and folder. When copying the folder, the attributes (such as authority, ownership, access Control List (ACL), etc.) of the source folder are copied to the target folder, so that the user authority and the file security are ensured to be consistent. Special handling of the redirection folders can keep the original pointing of these folders, such as "my documents", "desktop", etc., ensuring that the user's settings and habits remain unchanged after migration. By repairing MountedDevices and system guiding, the new system can be ensured to be started normally, and the starting problem caused by migration is avoided. By skipping special character files and flexibly processing different types of files, the user friendliness of the migration process is enhanced, and the possibility of manual intervention and operation errors of a user is reduced. The method is suitable for migration of various Windows systems, whether data migration of individual users or migration of systems in enterprise environments.
Example two
The present example provides a specific implementation.
And step 1, when the partition is migrated under the non-pe system, firstly, taking a snapshot of the partition of the source system, creating the snapshot by using the existing module ISnapshotMgr, calling the create in the module to create the snapshot, and obtaining the symbolic link of the snapshot by using the GetSymbolByDriveLetter function in the module after the snapshot is successfully created. The snapshot step is skipped under pe, directly using the source-and-path.
Step 2, traversing all files/folders in the source partition. Files/folders are looked up starting from the source partition and directory using the windows api function FINDFIRSTFILE, and the file names are compared using the _ tcsicmp function to skip special character files according to the file names in the return value of FINDFIRSTFILE function parameter 2, including the "," $recycle. Bin "and" SyetemVolume Information "directories (which are available for each partition, skipped to increase traversal speed).
Further, parameter 2 of FINDFIRSTFILE is a structure of WIN32_FIND_DATA, which is defined by Microsoft, and contains some basic information of files, including information of attributes, names, dates, and the like of the files.
Further, the file name is a member of the WIN32_FIND_DATA structure and is consistent with the file name exposed in the windows file browser.
The next file is looked up using FindnextFileAPI functions (beginning traversal inside each folder is using FINDFIRSTFILE, looking up the remaining files is using FindnextFile, and traversing through the api to all documents under a folder is accomplished using a combination of both apis).
If the FILE name returned in the parameter 2 is not the FILE to be skipped, judging whether the FILE is a folder according to dwFileAttributes FILE ATTRIBUTEs in the parameter 2 structure, wherein the judging method is dwFileAttributes & file_attribute_direction, if the condition is true, the FILE is indicated to be the folder, otherwise, the FILE is the FILE.
Specifically, dwFileAttributes is the first parameter in WIN32_FIND_DATA (Structure defined by Microsoft), which is used as a parameter for FINDFIRSTFILE or FindNextFile. Types dwFileAttributes include FILE_ATTRIBUTE_HIDDEN、FILE_ATTRIBUTE_SYSTEM、FILE_ATTRIBUTE_DIRECTORY、FILE_ATTRIBUTE_NORMAL、FILE_ATTRIBUTE_REPARSE_POINT (these types are defined by microsoft), so that dwFileAttributes and file_attribute_direction in the WIN32_find_data DATA obtained in FINDFIRSTFILE or FindNextFile are used to determine whether a FILE is a folder.
If it is a folder:
Step 201, it is determined whether the folder is a redirection folder, and the determination method is dwFileAttributes & file_attrip_reparse_point, if the condition is true, it indicates that the folder is redirected to another folder, when the folder is accessed, it is actually the location of the accessed redirection folder, and if the condition is false, it indicates that it is a common folder.
If it is a redirect folder, the condition is true:
in step 2011, the folder is created in the target partition using windows APICreateDirectory, and the value of dwFileAttributes read from the source file is set into the newly created folder using API function SetFileAttributes.
In step 2012, the folder to which the folder is redirected is obtained from the source folder, namely, a handle of the source folder is opened by using an API function CreateFile function, and redirection data in the source folder is obtained by using a DeviceIoControl function and using an FSCTL_GET_REPARSE_POINT control code. According to the link type judgment in the redirection DATA, the judgment method is REPARSETAG = = IO_REPARSE_TAG_MOUNT_POINT, if the condition is true, the obtained DATA is the mounting POINT DATA, a redirection folder address is contained inside, and according to the structure of the REPARSE_DATA_BUFFER (the redirection folder is saved in PathBuffer in MountPointReparseBuffer in the REPARSE_DATA_BUFFER structure, wherein the REPARSE_DATA_BUFFER is a structure defined by a user.
Since "\??\C:\xxxx", is only needed after "C: \" in PathBuffer, 4 is needed after PathBuffer in wcscpy _s (PATH, MAX_PATH, pReparse- > MountPointReparteBuffer.PathBuffer+4) is used at the time of copying, wherein PATH is the PATH for redirecting folders, and the PATH is needed when the PATH is set to the folder corresponding to the target partition.
And step 2013, saving the address of the redirected folder so as to be set in the newly-built folder of the target partition later. Because the source folder is redirected to other folders, when the source folder is opened, the redirected directory is actually accessed, and the target partition needs to create the same folder as the source folder and has the characteristics, the newly created folder needs to be provided with the same redirected directory, that is, the characteristics of the folders in the source folder need to be all set in the corresponding folder of the target partition.
The structure of the REPARSE_DATA_BUFFER is as follows:
In step 2014, creating a redirection directory for the newly created folder in the target partition, opening a handle of the folder created in the target partition by using a windows API function create function, initializing DATA of a REPARSE structure, wherein REPARSETAG is equal to the length of IO_REPARSE_TAG_MOUNT_ POINT, reparseDataLength and calculated according to the actual length of the redirection directory, fixing the value of Reserved to be equal to 2, then using a MountPointReparseBuffer structure by a union in the REPARSE_DATA_BUFFER structure, filling DATA in MountPointReparseBuffer according to the acquired DATA of the redirection folder, wherein PathBuffer under filling MountPointReparseBuffer needs to be filled "\??\" before copying the redirection address saved above to the back, initializing the DATA in detail as follows, and then setting the REPARSE DATA of the folder in the target partition by using a windowsAPI function DeviceIorol function and using an FSCTL_GET_REPAR_POINT control code. Where parameter 1 in CreateMountPoint is the folder created in the target partition and parameter 2 is the redirect folder obtained in step 2012 above.
Initialization code of REPARSE_DATA_BUFFER structure:
In step 2015, the ownership and ACL INFORMATION of the source folder are set to the newly created folder of the target partition, a windowsAPI function GetFileSecurity is used to acquire the size of the source file/folder SECURITY attribute, wherein the second parameter needs to contain three INFORMATION of OWNER, group and authority corresponding to the source file/folder, the size is returned through the last parameter of the function, heapAlloc function is used to allocate a section of memory space with acquired size and initialize all space data to 0, windows API function GetFileSecurity is used to acquire the SECURITY attribute of the source file/folder, the second parameter needs to contain macros corresponding to the OWNER, group and authority, and then windows API function SetFileSecurity is used to set the acquired SECURITY attribute to the file/folder of the target partition, wherein the second parameter also needs to contain the OWNERs, group and finally the allocated memory space with the corresponding macros.
Step 2016, the next file/folder is continued to be looked up using FindNextFile API functions.
Step 202, if the folder is only a normal folder:
In step 2021, the folder is created in the target partition using the windows API function CreateDirectory, and the file attributes dwFileAttributes in the source folder are set into the folder created in the target partition using the windows API function SetFileAttributes.
Step 2022, the ownership and ACL information of the source folder is obtained and set into the newly created folder.
Step 2023, go back to step 2022 to recursively refer to other files/folders under the current directory.
And 3, if the file is not a folder, copying the file from the source directory to the corresponding directory in the target partition by using a windows API function copyfile.
In step 301, dwFileAttributes attributes in the source file are set to the file corresponding to the target partition using windowsAPI function SetFileAttributes.
Step 302, continue searching for the next file using FindNextFileAPI functions. Steps 301 through 302 are then repeated until FindNextFile returns to FALSE.
At step 303, repair System under file MountedDevices, mount the SYSTEM registry file in the Windows\System32\config directory in the registry using the regLoadKey API function, delete MountedDevices all values in the mounted registry directory computer\HKEY_local_MACHINE\xxx MountedDevices (where xxx is the name of the SYSTEM file mounted in the registry). Preparing new binary data, wherein if the disk of the target partition is MBR, the data is 4-byte disk signature+8-byte starting position of the target partition, and if the disk of the target partition is GPT, the data is DMIO:ID+GUID of the partition. Then, a numerical name of DosDevices \C is created under MountedDevices, and the numerical data is the value of the binary data so as to achieve the aim of repairing the target partition system DosDevices, thereby avoiding the problem of always displaying a black screen or a splash screen after the power-on.
And step 4, repairing the system guidance of the target partition by using the existing module, and ensuring that the system can be normally booted.
Technical term analysis:
Redirecting folders-is the directing or "redirecting" of the contents of one folder to another location. When a user accesses the redirect directory, the system will automatically direct them to access the contents of the target location, rather than the actual path of the redirect directory itself.
Ownership and ACL information of the folder are two important rights management concepts in a file system, and are mainly used for controlling access rights of users and groups to files or folders.
GPT/MBR is a type of two disks, differing in the manner of management of the partition that maximally supports the size of the disk.
Registry is an important database in microsoft windows for storing system and application settings information.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that the above-mentioned embodiments are merely preferred embodiments of the present invention, and the present invention is not limited thereto, but may be modified or substituted for some of the technical features thereof 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.一种通过文件拷贝的方式迁移Windows系统的方法,其特征在于:包括以下步骤:1. A method for migrating a Windows system by copying files, characterized in that it comprises the following steps: 步骤S1,首先判断备份系统环境是否为PE系统;如果是,则不需要创建快照;如果不是,则需要先对源系统分区创建快照;Step S1, first determine whether the backup system environment is a PE system; if it is, then there is no need to create a snapshot; if not, then it is necessary to first create a snapshot of the source system partition; 步骤S2,遍历源系统分区中的所有文件;Step S2, traversing all files in the source system partition; 步骤S3,判断遍历返回值中的文件名是否为特殊字符,如果是,则跳过该文件并跳转到步骤S6;如果不是,则进入步骤S4;Step S3, determine whether the file name in the traversal return value is a special character, if so, skip the file and jump to step S6; if not, go to step S4; 步骤S4,判断文件属性是否为文件夹;如果是文件夹,则进入步骤S5,如果是文档,则复制文档到目标分区并跳转到步骤S6;Step S4, determine whether the file attribute is a folder; if it is a folder, proceed to step S5; if it is a document, copy the document to the target partition and jump to step S6; 步骤S5,判断文件夹是否为重定向文件夹,如果是,则在目标分区对重定向文件夹进行配置,使得重定向文件夹保持原有的指向;如果不是,则在目标分区中创建该文件夹,将源文件夹中的文件属性设置到目标分区中创建的文件夹中,并将源文件夹的所有权和ACL信息获取出来并设置到新创建的文件夹中;Step S5, determining whether the folder is a redirected folder. If so, configuring the redirected folder in the target partition so that the redirected folder maintains its original direction; if not, creating the folder in the target partition, setting the file attributes in the source folder to the folder created in the target partition, and obtaining the ownership and ACL information of the source folder and setting them to the newly created folder; 步骤S6,继续查找剩余的文件直到拷贝完所有文件;Step S6, continue searching for remaining files until all files are copied; 步骤S7,修复MountedDevices以及修复系统引导,完成迁移。Step S7, repair MountedDevices and repair system boot to complete the migration. 2.根据权利要求1所述的一种通过文件拷贝的方式迁移Windows系统的方法,其特征在于:步骤S1中,创建源系统的快照时,通过ISnapshotMgr模块中的create创建快照,快照创建成功后,使用ISnapshotMgr模块中的GetSymbolByDriveLetter函数获取快照的符号链接。2. According to claim 1, a method for migrating a Windows system by means of file copying is characterized in that: in step S1, when creating a snapshot of the source system, the snapshot is created by using create in the ISnapshotMgr module, and after the snapshot is successfully created, the GetSymbolByDriveLetter function in the ISnapshotMgr module is used to obtain the symbolic link of the snapshot. 3.根据权利要求2所述的一种通过文件拷贝的方式迁移Windows系统的方法,其特征在于:步骤S2中,使用windows的api函数FindFirstFile从源分区根目录开始查找文件。3. The method for migrating a Windows system by copying files according to claim 2, characterized in that: in step S2, the Windows API function FindFirstFile is used to search for files starting from the root directory of the source partition. 4.根据权利要求3所述的一种通过文件拷贝的方式迁移Windows系统的方法,其特征在于:步骤S3中,判断文件属性是否为文件夹具体为:根据遍历返回值中的文件属性判断是否为文件夹,如果dwFileAttributes&FILE_ATT RIBUTE_DIRECTORY条件为真就说明该文件是文件夹,反之则是文档。4. According to claim 3, a method for migrating a Windows system by copying files is characterized in that: in step S3, judging whether the file attribute is a folder is specifically: judging whether it is a folder according to the file attributes in the traversal return value, if the dwFileAttributes&FILE_ATT RIBUTE_DIRECTORY condition is true, it means that the file is a folder, otherwise it is a document. 5.根据权利要求4所述的一种通过文件拷贝的方式迁移Windows系统的方法,其特征在于:步骤S5中,判断文件夹是否为重定向文件夹具体为:如果dwFileAttributes&FILE_ATTRIBUTE_REPARSE_POIN条件为真,说明该文件夹被重定向到了其他文件夹,如果条件为假则是普通文件夹。5. According to claim 4, a method for migrating a Windows system by copying files is characterized in that: in step S5, judging whether a folder is a redirected folder is specifically: if the condition of dwFileAttributes&FILE_ATTRIBUTE_REPARSE_POIN is true, it means that the folder is redirected to other folders; if the condition is false, it is an ordinary folder. 6.根据权利要求5所述的一种通过文件拷贝的方式迁移Windows系统的方法,其特征在于:步骤S5中,对于重定向文件夹的配置包括创建相同的文件夹,并设置文件夹属性、获取重定向目录以及设定重定向目录。6. A method for migrating a Windows system by copying files according to claim 5, characterized in that: in step S5, the configuration of the redirected folder includes creating the same folder, setting folder attributes, obtaining the redirected directory, and setting the redirected directory. 7.根据权利要求6所述的一种通过文件拷贝的方式迁移Windows系统的方法,其特征在于:在目标分区创建相同的文件夹,设置文件夹属性具体为:使用windowsAPICreateDirectory在目标分区创建该重定向文件夹,将从源文件中读到的dwFileAttributes的值使用API函数SetFileAttributes设置到新创建的文件夹中。7. A method for migrating a Windows system by copying files according to claim 6, characterized in that: creating the same folder in the target partition, setting the folder attributes specifically includes: using windowsAPICreateDirectory to create the redirected folder in the target partition, and using the API function SetFileAttributes to set the value of dwFileAttributes read from the source file to the newly created folder. 8.根据权利要求7所述的一种通过文件拷贝的方式迁移Windows系统的方法,其特征在于:从源文件夹中获取重定向目录具体为:使用API函数CreateFile函数打开源文件夹的句柄,使用DeviceIoControl函数并使用FSCTL_GET_REPARSE_POINT控制码来获取源文件夹中的重定向数据;8. A method for migrating Windows system by file copying according to claim 7, characterized in that: obtaining the redirection directory from the source folder specifically comprises: using the API function CreateFile function to open the handle of the source folder, using the DeviceIoControl function and using the FSCTL_GET_REPARSE_POINT control code to obtain the redirection data in the source folder; 根据重定向数据中的链接类型判断数据类型,判断方法是ReparseTag==IO_REPARSE_TAG_MOUNT_POINT,如果条件为真,则说明获取到的数据是挂载点数据,里面包含了一个重定向的文件夹地址,反之,则没有;The data type is determined based on the link type in the redirected data. The determination method is ReparseTag == IO_REPARSE_TAG_MOUNT_POINT. If the condition is true, it means that the acquired data is mount point data, which contains a redirected folder address. Otherwise, there is no such data. 根据REPARSE_DATA_BUFFER的结构中的PathBuffer,其中path里面就是重定向文件夹的路径,保存其中重定向文件夹的地址,以便设置到目标分区新建的文件夹中。According to the PathBuffer in the REPARSE_DATA_BUFFER structure, the path contains the path of the redirected folder, and the address of the redirected folder is saved so that it can be set to the newly created folder in the target partition. 9.根据权利要求8所述的一种通过文件拷贝的方式迁移Windows系统的方法,其特征在于:为目标分区中新创建的文件夹设定重定向目录具体为:使用windows API函数CreateFile函数打开目标分区中创建的文件夹的句柄,初始化重解析结构的数据,其中ReparseTag等于IO_REPARSE_TAG_MOUNT_POI NT,ReparseDataLength的长度根据重定向目录的实际长度计算;9. A method for migrating Windows system by file copying according to claim 8, characterized in that: setting a redirection directory for a newly created folder in the target partition specifically comprises: using the Windows API function CreateFile function to open the handle of the folder created in the target partition, initializing the data of the reparse structure, wherein ReparseTag is equal to IO_REPARSE_TAG_MOUNT_POI NT, and the length of ReparseDataLength is calculated according to the actual length of the redirection directory; 接下来REPARSE_DATA_BUFFER的结构中的联合体使用MountPointReparse Buffer的结构,MountPointReparseBuffer中的数据根据获取到的重定向文件夹的数据填充,然后使用windows API函数DeviceIoControl函数并使用FSC TL_GET_REPARSE_POINT控制码来设置目标分区中文件夹的重解析数据。Next, the union in the REPARSE_DATA_BUFFER structure uses the MountPointReparse Buffer structure. The data in the MountPointReparseBuffer is filled according to the data of the redirected folder obtained. Then, the Windows API function DeviceIoControl function is used and the FSC TL_GET_REPARSE_POINT control code is used to set the reparse data of the folder in the target partition. 10.根据权利要求9所述的一种通过文件拷贝的方式迁移Windows系统的方法,其特征在于:将源文件夹的所有权和ACL信息设置到目标分区新创建的文件夹中:10. A method for migrating a Windows system by copying files according to claim 9, characterized in that: the ownership and ACL information of the source folder is set to the newly created folder of the target partition: 使用windows API函数GetFileSecurity来获取源文件或文件夹安全属性的大小,使用HeapAl loc函数分配一段获取到大小的内存空间并将空间数据全部初始化为0,使用windows API函数GetFileSecurity获取源文件或文件夹的安全属性,然后使用windowsAPI函数SetFileSecurity将获取到的安全属性设置到目标分区的文件或文件夹中去,最后释放分配的内存空间。Use the Windows API function GetFileSecurity to obtain the size of the source file or folder security attributes, use the HeapAlloc function to allocate a memory space of the obtained size and initialize all the space data to 0, use the Windows API function GetFileSecurity to obtain the security attributes of the source file or folder, and then use the Windows API function SetFileSecurity to set the obtained security attributes to the file or folder in the target partition, and finally release the allocated memory space.
CN202411992032.4A 2024-12-31 2024-12-31 Method for migrating Windows system by file copy mode Pending CN119884031A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411992032.4A CN119884031A (en) 2024-12-31 2024-12-31 Method for migrating Windows system by file copy mode

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411992032.4A CN119884031A (en) 2024-12-31 2024-12-31 Method for migrating Windows system by file copy mode

Publications (1)

Publication Number Publication Date
CN119884031A true CN119884031A (en) 2025-04-25

Family

ID=95428927

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411992032.4A Pending CN119884031A (en) 2024-12-31 2024-12-31 Method for migrating Windows system by file copy mode

Country Status (1)

Country Link
CN (1) CN119884031A (en)

Similar Documents

Publication Publication Date Title
CN109906433B (en) Storage isolation for containers
US8370835B2 (en) Method for dynamically generating a configuration for a virtual machine with a virtual hard disk in an external storage device
US7882065B2 (en) Processing a request to update a file in a file system with update data
US6279109B1 (en) Computing system and operating method for booting and running a graphical user interface (GUI) with r/w hard drive partition unavailable
US9785370B2 (en) Method and system for automatically preserving persistent storage
US7519806B2 (en) Virtual partition for recording and restoring computer data files
US9286098B1 (en) Using master file template area to increase density of virtual machines in a computer system
US8290996B2 (en) Data sharing for file clones using reverse ditto references
US6934822B2 (en) Organization of multiple snapshot copies in a data storage system
US7440980B2 (en) Computer file management system
US6792518B2 (en) Data storage system having mata bit maps for indicating whether data blocks are invalid in snapshot copies
JP4663878B2 (en) Method and apparatus for managing files in a storage medium
US9459899B2 (en) Apparatus and method for providing services using a virtual operating system
US20080109908A1 (en) Reverse Name Mappings In Restricted Namespace Environments
US20070136723A1 (en) Using virtual hierarchies to build alternative namespaces
JPH1031612A (en) Advanced file server
CN119025270A (en) Memory allocation method, device, electronic device and storage medium
US10037328B2 (en) Non-privileged access to data independent of filesystem implementation
Paliy et al. The logical structure of the software file archive formation as a part of industrial management
US7725507B1 (en) Dynamic directories
US20190179803A1 (en) Apparatus and method for file sharing between applications
CN119884031A (en) Method for migrating Windows system by file copy mode
Palakollu Files and Directories
KR100545654B1 (en) How to detect flawlessness of files on disk after system startup
Mohan et al. Mounting of version control repositories: Repofs

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