Method for network duplicating domestic machine based on PXE (PCI eXtensions for Ethernet) mode

Extracting and modifying the operating system image through PXE and embedding network replication tools solves the problem of the universality of localized machine replication, achieves efficient and safe replication operations, and supports multi-machine management and data encryption and decryption functions.

CN118567665APending Publication Date: 2024-08-30KUSN JIUHUA ELECTRONICS EQUIP FACTORY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410647277.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Existing re-engraving methods lack universal applicability on domestically produced machines, making it difficult to achieve efficient and safe re-engraving operations.

Method used

Using PXE method, by pre-confirming the operating system image of the target machine, extracting and modifying the kernel, ramdisk and root file system in the image, embedding the network cloning tool, and setting startup parameters on the PXE server, so that the target machine automatically starts through PXE Perform a copy or recovery operation.

Benefits of technology

It achieves efficient and safe reproduction of domestic machines, has versatility and multi-machine management capabilities, does not require the installation of software or external media, supports data compression, encryption and decryption functions, and has good scalability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118567665A
    Figure CN118567665A
Patent Text Reader

Abstract

The invention discloses a PXE (PCI eXtensions for Ethernet) mode-based method for network duplicating a domestic machine, which comprises the following steps of: pre-confirming a target machine installation or adaptive operating system installation mirror image version, and obtaining an installation mirror image of the corresponding version; extracting a kernel file, a ramdisk file and a root file system in the installation mirror image; the ramdisk file is decompressed, a network module and a mounting module are added, the network module is used for supporting a PXE environment, and the mounting module is used for mounting a root file system; decompressing the root file system, and adding a network duplicating tool; the PXE server environment is maintained, and PXE starting parameters are set; the kernel file, the modified ramdisk file and the root file system are copied to a PXE environment of a server side; and starting the target machine from the PXE, and automatically executing the copying or restoring operation according to the starting parameters. Through the above mode, based on the PXE mode, bare machine type mirror image distribution without installing software on the target machine is realized, according to the added network duplicating tool, the duplicating operation on the target disk or partition can be supported, and meanwhile, according to the installation mirror image version adapted to the target machine, the corresponding localized platform is supported.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method for replicating a domestic machine through a PXE network. Background Art

[0002] To prevent data loss or system damage, users can replicate the system regularly. Traditional replication methods usually require installing specific software on the target machine, or using external media such as USB, CD / DVD to start the PE (Windows Preinstallation Environment) system. Due to compatibility issues between the application environment of the domestic platform and the general platform, the replication solutions currently on the market are mostly suitable for specific scenarios and are not universal on domestic machines.

[0003] PXE (Pre-boot Execution Environment) is a network boot technology that can run before the operating system. It can obtain the boot program and system image files from the server through the network to achieve diskless or unattended startup. PXE provides technical possibilities for network boot replication tools, and currently most mainstream domestic machines support PXE boot. Therefore, in combination with PXE technology, it is further expanded to provide an adapted operating system image file on the PXE server and embed a network replication tool in the image file, thus proposing the present invention.

[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the invention

[0005] The main technical problem solved by the present invention is to provide a method for replicating a domestic machine based on a PXE network, the purpose of which is to achieve efficient and safe replication of a domestic machine.

[0006] In order to solve the above technical problems, a technical solution adopted by the present invention is to provide a method for replicating a domestic machine through a network based on a PXE mode, comprising the following steps:

[0007] S1. Pre-confirm the installation image version of the operating system installed or adapted on the target machine, and obtain the installation image of the corresponding version;

[0008] S2, extract the kernel file, ramdisk file and root file system in the installation image;

[0009] S3. Decompress the ramdisk file, add a network module and a mount module. The network module is used to support the PXE environment, and the mount module is used to mount the root file system.

[0010] S4. Unzip the root file system and add network replication tools;

[0011] S5. Maintain the PXE server environment and set PXE startup parameters;

[0012] S6. Copy the kernel file, the modified ramdisk file, and the root file system to the PXE environment of the server.

[0013] S7. The target machine starts from PXE and automatically performs the replication or restoration operation according to the startup parameters.

[0014] Preferably, the kernel file, ramdisk file and root file system in step S2 are all stored in the path in the installation image, wherein the kernel file is the vmlinuz file in the path, the ramdisk file is the initrd.img file in the path, and the root file system is the filesystem.squashfs file in the path.

[0015] Preferably, in step S3, the decompression and compression of the ramdisk file are both implemented by the gzip command, and the output of the file content is implemented by the cpio command.

[0016] Preferably, after decompression in step S3, a ramdisk directory is obtained, and a network module and a mounting module are added to the ramdisk directory, wherein the network module includes a network card driver corresponding to the target machine network card, an ifconfig command for opening the network port, and a dhclient command for connecting to the DHCP service in the server-side PXE environment; the mounting module includes a mount.nfs command for mounting the NFS service in the server-side PXE environment, a chroot command for switching the root directory, and an init script for automatically executing initialization.

[0017] Preferably, in step S4, both decompressing and compressing the root file system are implemented by squashfs-tools, wherein the decompressing the root file system is implemented by unsquashfs, and the compressing the root file system is implemented by mksquashfs.

[0018] Preferably, after decompression in step S4, a root directory is obtained, and a network replication tool is added to the root directory, wherein the network replication tool includes a remote transmission module, a disk management module, a replication command module, a recovery command module, a file verification module, and a target host control module;

[0019] The remote transmission module is supported by the NFS service and is used to mount the server directory at the beginning of the replication or recovery operation so as to save the data on the server;

[0020] The disk management module is used to view the partition table, disk format, and obtain disk information of the target machine;

[0021] The replication command module is used to perform operations such as compressing data and encrypting data when performing replication tasks;

[0022] The recovery command module is used to perform operations such as decompressing data and decrypting data when performing recovery tasks;

[0023] The file verification module is used to check the integrity of the data saved to the server;

[0024] The target host control module is used to shut down or restart the target machine when completing the replication or recovery operation.

[0025] Preferably, in step S5, the PXE server is deployed on a CentOS operating system, and the PXE startup parameters include DHCP service parameters, TFTP service parameters, NFS service parameters, image file startup parameters, and network replication commands;

[0026] The DHCP service parameters need to modify the server-side DHCP service configuration file dhcpd.conf, specify the NBP file location corresponding to the DHCP message option parameter, as well as the DHCP allocation address range and the tftp service address;

[0027] The TFTP service parameters need to modify the TFTP service configuration file tftp, specify the TFTP service path, and store the program files and configuration files that can be loaded by the target machine BIOS firmware under the TFTP service path;

[0028] The NFS service parameters need to modify the NFS service configuration file exports and add a mountable directory for the target machine to read and write the replicated data;

[0029] The image file startup parameters need to modify the configuration file supported by the corresponding BIOS firmware, add the kernel file, ramdisk file and root file system required for startup, and specify the initialization script as init;

[0030] The network replication command can be added to the image file startup parameters, and the reading method can be set in the initialization script init to automatically perform the replication or recovery operation.

[0031] Preferably, in step S6, the kernel file and the modified ramdisk file are copied to the TFTP service path of the PXE server, and the root file system is copied to the NFS service path of the PXE server.

[0032] Compared with the prior art, the present invention has the following beneficial effects:

[0033] (1) The present invention provides a method for replicating a domestic machine based on a PXE network, by obtaining an operating system installation image adapted to the target machine, modifying the ramdisk file and the root file system in the installation image, and then copying the kernel file and the modified ramdisk file and the root file system in the installation image to a PXE environment maintained by a server, so that the target machine can automatically perform a replica or restore operation after being started through PXE.

[0034] (2) This method is universal and can adapt to the usage requirements of domestic machines with different architectures, and can simultaneously manage the operating system image files of multiple domestic machines on a single server machine.

[0035] (3) This method only starts the network replication tool in the memory. There is no need to install software on the target machine, nor is there a need for external media such as USB, CD / DVD, etc., which ensures the security and stability of the target machine. Based on the network replication tool embedded in the root file system, it not only supports selective replication or recovery of the target machine's disk or partition, but also supports compression and encryption functions when replicating data and decompression and decryption functions when restoring data. At the same time, this method also has good scalability for subsequent required functions. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 The figure is a flowchart of a method for replicating a domestically produced machine through a PXE network.

[0037] Figure 2 This is a schematic diagram of the modified ramdisk file structure in an example of the present invention.

[0038] Figure 3 It is a schematic diagram of the functional module structure of the network replication tool in the example of the present invention.

[0039] Figure 4 The figure is a schematic diagram of the overall architecture of the PXE environment maintained by the server in the example of the present invention.

[0040] Figure 5 This is a timing diagram of the target machine in an example of the present invention starting from PXE and automatically performing the replication operation according to the startup parameters. DETAILED DESCRIPTION

[0041] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the invention can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present invention.

[0042] See also Figures 1 to 5 , the embodiment of the present invention includes:

[0043] A method for replicating a domestic machine based on a PXE network, the method comprising the following steps:

[0044] S1. Pre-confirm the installation image version of the operating system installed or adapted on the target machine, and obtain the installation image of the corresponding version;

[0045] In the embodiment of the present invention, the target machine is a Lenovo server, the CPU is the FT2000plus domestic platform, the operating system is the Kylin V4 domestic operating system, and for the target machine, the installation image obtained is Kylin-4.0.2-server-sp2-arm64.iso;

[0046] S2, extract the kernel file, ramdisk file and root file system in the installation image;

[0047] In the embodiment of the present invention, the kernel file, ramdisk file and root file system are all stored in the / casper path in the Kylin-4.0.2-server-sp2-arm64.iso installation image, wherein the kernel file is the vmlinuz file under the path, the ramdisk file is the initrd.img file under the path, and the root file system is the filesystem.squashfs file under the path;

[0048] S3. Decompress the ramdisk file, add a network module and a mount module. The network module is used to support the PXE environment, and the mount module is used to mount the root file system.

[0049] In the embodiment of the present invention, the decompression and compression of the ramdisk file are both implemented by the gzip command, and the output file content is implemented by the cpio command. First, the gzip and cpio commands are used to decompress and output the ramdisk file content to obtain the decompressed ramdisk directory. Figure 2 , add network modules and mount modules in the ramdisk directory;

[0050] The network module includes: the network card driver corresponding to the target machine network card, the ifconfig command to open the network port, and the dhclient command to connect to the DHCP service in the PXE environment of the server;

[0051] The mount module includes: the mount.nfs command for mounting the NFS service in the PXE environment of the server, the chroot command for switching the root directory, and the init script for automatic execution of the initialization;

[0052] After adding all modules, use the gzip and cpio commands to compress the ramdisk directory to get the modified ramdisk file;

[0053] S4. Unzip the root file system and add network replication tools;

[0054] In the embodiment of the present invention, the decompression and compression of the root file system are both implemented by the squashfs-tools tool. First, the root file system is decompressed using the unsquashfs command to obtain the decompressed root directory. Figure 3 , add the network replication tool in the root directory, including six modules: remote transmission module, disk management module, replication command module, recovery command module, file verification module, and target host control module;

[0055] Among them, the remote transmission module is supported by the NFS service, which is used to mount the server directory at the beginning of the replication or recovery operation so as to save the data on the server;

[0056] The disk management module is used to view the partition table, disk format, and obtain the disk information of the target machine;

[0057] The replication command module is used to perform operations such as compressing data and encrypting data when performing replication tasks;

[0058] The recovery command module is used to perform operations such as decompressing and decrypting data when performing recovery tasks;

[0059] The file verification module is used to check the integrity of the data saved to the server;

[0060] The target host control module is used to shut down or restart the target machine when completing the replication or recovery operation;

[0061] S5. Maintain the PXE server environment and set PXE startup parameters;

[0062] In the embodiment of the present invention, the PXE server is deployed on the CentOS operating system. Figure 4 , maintain DHCP service, TFTP service, and NFS service in the PXE environment. PXE startup parameters include DHCP service parameters, TFTP service parameters, NFS service parameters, image file startup parameters, and network replication commands;

[0063] Among them, the DHCP service parameters need to modify the server-side DHCP service configuration file dhcpd.conf, specify the NBP file location corresponding to the DHCP message option parameter, as well as the DHCP allocation address range and tftp service address;

[0064] TFTP service parameters require modifying the TFTP service configuration file tftp, specifying the TFTP service path, and storing program files and configuration files that can be loaded by the target machine's BIOS firmware under the TFTP service path;

[0065] NFS service parameters require modifying the NFS service configuration file exports to add a mountable directory for the target machine to read and write replicated data;

[0066] The image file startup parameters need to modify the configuration file supported by the corresponding BIOS firmware, add the kernel file, ramdisk file and root file system required for startup, and specify the initialization script as init;

[0067] The network replication command can be added to the image file startup parameters and written into the configuration file supported by the corresponding BIOS firmware. When PXE starts the ramdisk environment, the startup parameters in the configuration file can be written into the system environment variables. Therefore, add custom parameters to the configuration file and set the reading method of custom parameters in the initialization script init. After initializing the ramdisk environment, the network replication tool can be automatically called to perform replication or recovery operations;

[0068] S6. Copy the kernel file, the modified ramdisk file, and the root file system to the PXE environment of the server.

[0069] Combined with Figure 4 In the embodiment of the present invention, the kernel file and the modified ramdisk file will be copied to the TFTP service path of the PXE server, and the modified root file system will be copied to the NFS service path of the PXE server;

[0070] S7, the target machine starts from PXE and automatically performs the replication or restoration operation according to the startup parameters;

[0071] Combined with Figure 5 In the embodiment of the present invention, after the target domestic machine is set to start from PXE in the BIOS startup item, the following steps are performed to complete the replication operation:

[0072] 1) Request IP from the PXE server, and the DHCP service of the PXE server returns the IP and NBP file location;

[0073] 2) Request the NBP file from the PXE server, and the TFTP service of the PXE server returns the NBP file;

[0074] 3) Execute the NBP file;

[0075] 4) Request the configuration file from the PXE server, and the TFTP service of the PXE server returns the configuration file;

[0076] 5) Read configuration file information;

[0077] 6) Request the kernel file from the PXE server, and the TFTP service of the PXE server returns the kernel file;

[0078] 7) Request the ramdisk file from the PXE server, and the TFTP service of the PXE server returns the ramdisk file;

[0079] 8) Kernel initialization, kernel startup, ramdisk module loading, and init script execution;

[0080] 9) Request the root file system from the PXE server, and the NFS service of the PXE server returns the root file system;

[0081] 10) Mount the root file system and start the network replication tool;

[0082] 11) Perform the replication operation and write the replication data to the NFS mount path of the PXE server.

[0083] In the embodiment of the present invention, optionally, when performing the recovery operation, step 11) needs to read data from the NFS mount path of the PXE server and write it to the hard disk of the target machine.

[0084] The present invention discloses a method for replicating a domestic machine based on a PXE mode network. Based on the PXE mode, bare metal image distribution without installing software on a target machine is realized. According to an added network replica tool, the replica operation on a target disk or partition can be supported. At the same time, according to the installation image version adapted by the target machine, the corresponding domestic platform is supported.

[0085] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for replicating a domestic machine based on a PXE network, characterized in that: The following steps are involved: S1. Pre-confirm the installation image version of the operating system installed or adapted on the target machine, and obtain the installation image of the corresponding version; S2, extract the kernel file, ramdisk file and root file system in the installation image; S3. Decompress the ramdisk file, add a network module and a mount module. The network module is used to support the PXE environment, and the mount module is used to mount the root file system. S4. Unzip the root file system and add network replication tools; S5. Maintain the PXE server environment and set PXE startup parameters; S6. Copy the kernel file, the modified ramdisk file and the root file system to the PXE environment of the server. S7. The target machine starts from PXE and automatically performs the replication or restoration operation according to the startup parameters.

2. According to claim 1, a method for replicating a domestic machine based on a PXE network is characterized in that: The kernel file, ramdisk file and root file system in step S2 are all stored in the path in the installation image, wherein the kernel file is the vmlinuz file in the path, the ramdisk file is the initrd.img file in the path, and the root file system is the filesystem.squashfs file in the path.

3. According to claim 1, a method for replicating a domestic machine based on a PXE network is characterized in that: In step S3, the decompression and compression of the ramdisk file are both implemented by the gzip command, and the output of the file content is implemented by the cpio command.

4. According to claim 1, a method for replicating a domestic machine based on a PXE network is characterized in that: After decompression in step S3, a ramdisk directory is obtained, and a network module and a mounting module are added to the ramdisk directory. The network module includes a network card driver corresponding to the target machine network card, an ifconfig command for opening the network port, and a dhclient command for connecting to the DHCP service in the server-side PXE environment; the mounting module includes a mount.nfs command for mounting the NFS service in the server-side PXE environment, a chroot command for switching the root directory, and an init script for automatically executing initialization.

5. The method for replicating a domestic machine based on a PXE network according to claim 1, characterized in that: In step S4, the decompression and compression of the root file system are both implemented by the squashfs-tools tool, wherein the decompression of the root file system is implemented by unsquashfs, and the compression of the root file system is implemented by mksquashfs.

6. The method for replicating a domestic machine based on a PXE network according to claim 1, characterized in that: After decompression in step S4, a root directory is obtained, and a network replication tool is added to the root directory, wherein the network replication tool includes a remote transmission module, a disk management module, a replication command module, a recovery command module, a file verification module, and a target host control module; The remote transmission module is supported by the NFS service and is used to mount the server directory at the beginning of the replication or recovery operation so as to save the data on the server; The disk management module is used to view the partition table, disk format, and obtain disk information of the target machine; The replication command module is used to perform operations such as compressing data and encrypting data when performing replication tasks; The recovery command module is used to perform operations such as decompressing data and decrypting data when performing recovery tasks; The file verification module is used to check the integrity of the data saved to the server; The target host control module is used to shut down or restart the target machine when completing the replication or recovery operation.

7. The method for replicating a domestic machine based on a PXE network according to claim 1, characterized in that: In step S5, the PXE server is deployed on the CentOS operating system, and the PXE startup parameters include DHCP service parameters, TFTP service parameters, NFS service parameters, image file startup parameters, and network replication commands; The DHCP service parameters need to modify the server-side DHCP service configuration file dhcpd.conf, specify the NBP file location corresponding to the DHCP message option parameter, as well as the DHCP allocation address range and tftp service address; The TFTP service parameters need to modify the TFTP service configuration file tftp, specify the TFTP service path, and store the program files and configuration files that can be loaded by the target machine BIOS firmware under the TFTP service path; The NFS service parameters need to modify the NFS service configuration file exports and add a mountable directory for the target machine to read and write the replicated data; The image file startup parameters need to modify the configuration file supported by the corresponding BIOS firmware, add the kernel file, ramdisk file and root file system required for startup, and specify the initialization script as init; The network replication command can be added to the image file startup parameters, and the reading method can be set in the initialization script init to automatically perform the replication or recovery operation.

8. The method for replicating a domestic machine based on a PXE network according to claim 1, characterized in that: In step S6, the kernel file and the modified ramdisk file are copied to the TFTP service path of the PXE server, and the root file system is copied to the NFS service path of the PXE server.