Disclosure of Invention
The embodiment of the invention provides a PXE-based operating system remote installation method and system, which are used for improving the installation efficiency of operating systems installed in batches and reducing the cost.
According to one aspect of the invention, a PXE-based operating system remote installation method is provided, which comprises the following steps:
the method comprises the steps that a PXE client is started from a PXE, a PXE boot program is downloaded from a PXE server and runs, and the PXE boot program reads a boot file corresponding to an MAC address of the PXE client from a PXE operating system configuration directory in the PXE server;
the PXE boot program obtains the boot configuration file according to the address of the boot configuration file recorded in the read boot file, and after loading a system kernel program and an initialization memory disk program, the system kernel program provides an installation environment of an operating system for the PXE client, and the initialization memory disk program performs installation of the operating system according to the boot configuration file.
Further, before the PXE client starts from the PXE, the method further includes:
the PXE server correspondingly stores the client identification and the MAC address which are input by a user aiming at each PXE client into a database.
Further, before the PXE client starts from the PXE, the method further includes:
after receiving a submission instruction for selecting an operating system to be installed, the PXE server searches an MAC address corresponding to the client identifier in the database for each client identifier related to the submission instruction, determines a starting configuration file corresponding to the operating system type according to the operating system type corresponding to the client identifier related to the submission instruction, generates a boot file corresponding to the MAC address under the PXE operating system configuration directory, and records the determined address of the starting configuration file in the generated boot file.
Further, the script code of the installed operation module of the start configuration file includes: returning the script code of the installation completion notice; and
in the process of installing the operating system by the initialized memory disk program according to the startup configuration file, the method specifically includes:
the initialization memory disk program returns an installation completion notification carrying the MAC address of the PXE client to the PXE server according to the script code returning the installation completion notification in the starting configuration file;
after receiving the installation completion notification, the PXE server records, in an installation log, installation information of the client identifier corresponding to the MAC address carried in the installation completion notification, including: the operating system model corresponding to the client identification, and installation completion information.
According to another aspect of the present invention, there is also provided a PXE-based operating system remote installation system, including: a PXE server, and a plurality of PXE clients; wherein,
the PXE server is used for storing a PXE boot program, client identifiers and MAC addresses of all PXE clients, start configuration files corresponding to all operating system models respectively and boot files corresponding to the MAC addresses of all the PXE clients;
the PXE client is used for starting from the PXE and downloading and running the PXE bootstrap program from the PXE server; the PXE bootstrap program is used for reading a bootstrap file corresponding to the MAC address of the PXE client from a PXE operating system configuration directory in the PXE server; and obtaining the boot configuration file according to the address of the boot configuration file recorded in the read boot file, and after loading a system kernel program and an initialization memory disk program, the system kernel program provides an installation environment of the operating system for the PXE client, and the initialization memory disk program performs installation of the operating system according to the boot configuration file.
Preferably, the PXE server is further configured to receive a client identification and a MAC address of the PXE client entered by a user.
Preferably, the PXE server is further configured to, after receiving a commit instruction for selecting an operating system to be installed, find, for each client identifier related to the commit instruction, an MAC address corresponding to the client identifier, determine, according to an operating system model related to the commit instruction and corresponding to the client identifier, a start configuration file corresponding to the operating system model, generate, under the PXE operating system configuration directory, a boot file corresponding to the MAC address, and record, in the generated boot file, an address of the determined start configuration file.
Preferably, the script code of the installed operation module of the start configuration file includes: returning the script code of the installation completion notice, and in the process that the initialization memory disk program performs the installation of the operating system according to the starting configuration file, returning the installation completion notice carrying the MAC address of the PXE client to the PXE server by the initialization memory disk program according to the script code of the installation completion notice returned in the starting configuration file; and
the PXE server is further configured to record, after receiving the installation completion notification, installation information of the client identifier corresponding to the MAC address carried in the installation completion notification in an installation log, where the installation information includes: the operating system model corresponding to the client identification, and installation completion information.
According to another aspect of the present invention, there is also provided a PXE server, including:
the recording module is used for correspondingly storing the client identifier and the MAC address recorded by the user aiming at each PXE client into the database;
and the operating system to be installed selection module is used for searching the MAC address corresponding to the client identifier in the database aiming at each client identifier related to the submission instruction after receiving the submission instruction for selecting the operating system to be installed, determining a starting configuration file corresponding to the operating system type according to the operating system type corresponding to the client identifier related to the submission instruction, generating a guide file corresponding to the MAC address under the PXE operating system configuration directory, and recording the determined address of the starting configuration file in the generated guide file.
Preferably, the log recording module is configured to record, in the installation log, installation information of the client identifier corresponding to the MAC address carried in the installation completion notification after receiving the installation completion notification, and includes: the operating system model corresponding to the client identification, and installation completion information.
In the technical scheme of the embodiment of the invention, a PXE server correspondingly stores a client identifier and an MAC address which are input by a user aiming at each PXE client in advance into a database; the method comprises the steps of providing a selection menu containing a client identifier and an operating system to be installed for a user through display, determining an MAC address corresponding to a submission instruction according to the submission instruction after receiving the submission instruction for selecting the operating system to be installed, starting a configuration file, and recording the determined address of the file in a generated guide file. After the PXE client is started from the PXE, the initialized memory disk program loaded by the bootstrap program automatically installs the operating system according to the downloaded starting configuration file without the need of an operator to perform the operation system selection operation or any intervention for the PXE client. Therefore, the operation of selecting the operating system for each PXE client to be installed can be performed by an operator only by performing the operation of selecting the operating system for each PXE client to be installed once on the PXE server, and compared with the existing operation that the operator needs to perform the operation of selecting the operating system on each PXE client one by one, a great deal of time and energy are saved, and therefore the installation efficiency of installing the operating systems in batches is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail below with reference to the accompanying drawings by way of examples of preferred embodiments. It should be noted, however, that the numerous details set forth in the description are merely for the purpose of providing the reader with a thorough understanding of one or more aspects of the present invention, which may be practiced without these specific details.
As used in this application, the terms "module," "system," and the like are intended to include a computer-related entity, such as but not limited to hardware, firmware, a combination of hardware and software, or software in execution. For example, a module may be, but is not limited to: a process running on a processor, an object, an executable, a thread of execution, a program, and/or a computer. For example, an application running on a computing device and the computing device may both be a module. One or more modules may reside within a process and/or thread of execution.
The inventors of the present invention consider that, before each PXE client starts from a PXE, preparation before installation is performed by the PXE server: a client identifier of a server to be installed as a PXE client and a Media Access Control (MAC) address corresponding to the client identifier are stored in a database of the PXE server in advance. And then, the PXE server determines a corresponding starting configuration file according to the model of the operating system selected by the operator in the operating system selection menu, and adds the address of the determined starting configuration file to a boot file corresponding to the MAC address according to the MAC address selected by the operator in the operating system selection menu.
Therefore, after the PXE client is started from the PXE, an operator does not need to perform operation system selection operation or any intervention on the PXE client, the PXE client obtains the starting configuration file from the PXE server by reading the address of the starting configuration file in the boot file, and the operating system can be automatically installed according to the starting configuration file. The operating personnel can automatically install each PXE client only by selecting the operating system for each PXE client of the operating system to be installed once in the PXE server, and compared with the existing method that the operating personnel need to execute the operation of selecting the operating system on each PXE client one by one, a large amount of time and energy are saved, so that the installation efficiency of installing the operating systems in batches is improved, and the cost is reduced.
The technical scheme of the invention is explained in detail in the following with the accompanying drawings.
The structure of the operating system remote installation system based on the PXE provided by the embodiment of the present invention is shown in fig. 1, and includes: aPXE server 101, and a plurality ofPXE clients 102.
ThePXE server 101 provides an entry interface containing a client identifier and an MAC address filling column corresponding to the client identifier for a user through a display, and correspondingly stores the client identifier and the MAC address related to entry information into a database after receiving the entry information input by the user; before thePXE client 102 starts from the PXE, thePXE server 101 also provides the user with a selection menu containing the client identification and the operating system to be installed through the display, and the user can select the operating system to be installed for asingle PXE client 102 ormultiple PXE clients 102 through the selection menu.
In fact, the PXEserver 101 stores therein a PXE boot program, a client identifier and a MAC address of each PXE client, a boot configuration file corresponding to each operating system model, respectively, and a boot file corresponding to the MAC address of each PXE client.
ThePXE client 102 is used to boot from the PXE and download and run the PXE boot program from thePXE server 101.
After receiving a commit instruction, which is input by a user and used for selecting an operating system to be installed, of thePXE server 101, a specific method for preparing before installation is performed by thePXE server 101, where a flow is shown in fig. 2, and includes the following steps:
s201: after receiving a commit instruction for selecting an operating system to be installed, thePXE server 101 determines, according to the commit instruction, a MAC address corresponding to the commit instruction.
In this step, after receiving a commit instruction for selecting an operating system to be installed, thePXE server 101 searches, for each client identifier related to the commit instruction, an MAC address corresponding to the client identifier in the database; the client identifier may specifically include: the identification of PXE client IP (internet protocol, protocol for interconnection between networks) address, gateway, network mask information, and may also include physical address information, such as identification of machine room number, inventory number.
In practical applications, the PXEclient 102 involved in the commit instruction for selecting the operating system to be installed received by the PXEserver 101 may be a client of a single operating system to be installed, or may be multiple clients of operating systems of the same model to be installed. Therefore, the method for remotely installing the operating system based on the PXE provided by the embodiment of the invention is not limited to the number of the PXE clients which are installed at one time, and the operating system can be installed for a plurality of PXE clients at one time according to actual needs.
S202: thePXE server 101 determines the boot configuration file corresponding to the submit instruction according to the submit instruction.
In this step, thePXE server 101 determines, according to the operating system model corresponding to the client identifier and related to the submitted instruction, a start configuration file corresponding to the operating system model. In addition, thePXE server 101 may also search, according to the operating system model related to the submitted instruction and corresponding to the client identifier, a starting configuration file template corresponding to the operating system model from a pre-stored starting configuration file template library, and generate a corresponding starting configuration file; the start configuration file is specifically a ks.cfg (kickstart) file.
S203: thePXE server 101 generates a boot file corresponding to the determined MAC address under the PXE operating system configuration directory, and records the address of the determined boot configuration file in the generated boot file.
In this step, after determining the start configuration file corresponding to the operating system model, thePXE server 101 generates a boot file corresponding to the MAC address determined in step S201 in the PXE operating system configuration directory, and records the address of the start configuration file determined in step S202 in the generated boot file; wherein the operating system configuration is specifically pxelinux.
After that, after eachPXE client 102 starts from the PXE, it does not need any intervention or operation by an operator, and automatically completes the installation of its operating system, and a specific method flow, as shown in fig. 3, includes the following steps:
s301: thePXE client 102 starts from the PXE and downloads and runs the PXE boot program from thePXE server 101.
In this step, thePXE client 102 starts from the PXE, downloads the PXE boot program from thePXE server 101 through TFTP or MTETP (multicast file transfer protocol), and then runs the program.
S302: the PXE boot program reads the boot file corresponding to the MAC address of thepresent PXE client 102 from the PXE operating system configuration directory in thePXE server 101.
In this step, after thePXE client 102 runs the PXE boot loader, the boot loader will automatically read the boot file corresponding to the MAC address of thePXE client 102 from the PXE operating system configuration directory in thePXE server 101.
Therefore, the situation that after thePXE client 102 runs the PXE bootstrap program, the operating system which can be selectively installed needs to be displayed for technicians through a display, and the installation of the corresponding operating system can be completed according to the selection of the operators is avoided. For a plurality of PXE client sides 102 needing to install different operating systems, the installation method provided by the embodiment of the invention can not only reduce the use of a display so as to save the cost, but also avoid the operation of selecting the operating system for eachPXE client side 102 so as to improve the installation efficiency of installing the operating systems in batches.
S303: and the PXE boot program acquires the boot configuration file according to the address of the boot configuration file recorded in the read boot file, and loads a system kernel program and an initialization memory disk program.
In this step, the PXE boot program obtains, according to the read boot file, an image file (vmlinux) for downloading the system kernel program and an image file (initrd.img) for initializing the memory disk program from thePXE server 101, obtains the start configuration file according to the address of the start configuration file recorded in the boot file, and loads the system kernel program and initializes the memory disk program according to the downloaded image file.
S304: and initializing the memory disk program to install the operating system according to the acquired starting configuration file.
In this step, after the PXE boot program loads the system kernel program and the initialized memory disk program according to the downloaded image file, the system kernel program provides an installation environment of the operating system for thePXE client 102, and the initialized memory disk program performs installation of the operating system according to the start configuration file.
Preferably, script codes for returning installation completion notice are embedded in the starting configuration file; therefore, in the process of installing the operating system according to the start configuration file, the initialized memory disk program returns an installation completion notification carrying the MAC address of thePXE client 102 to thePXE server 101 according to the script code in the start configuration file that returns the installation completion notification; after receiving the installation completion notification, thePXE server 101 records the installation information of the client identifier corresponding to the MAC address carried in the installation completion notification in the installation log, so that a user can conveniently check the installation state of eachPXE client 102 through the installation log; wherein the installation information includes: the operating system model corresponding to the client identification, and installation completion information.
As shown in fig. 4, an internal structure block diagram of thePXE server 101 according to the embodiment of the present invention includes: alogging module 401 and a to-be-installed operatingsystem selection module 402.
Theentry module 401 is configured to store the client identifier and the MAC address entered by the user for eachPXE client 102 into the database correspondingly.
The to-be-installed operatingsystem selection module 402 is configured to, after receiving a commit instruction for selecting an operating system to be installed, search, for each client identifier related to the commit instruction, a MAC address corresponding to the client identifier in the database, determine, according to an operating system model related to the commit instruction and corresponding to the client identifier, a start configuration file corresponding to the operating system model, generate a boot file corresponding to the MAC address under the PXE operating system configuration directory, and record, in the generated boot file, an address of the determined start configuration file.
Further, thePXE server 101 further includes: alogging module 403;
thelog recording module 403 is configured to record, after receiving the installation completion notification, installation information of the client identifier corresponding to the MAC address carried in the installation completion notification in an installation log; wherein the installation information includes: the operating system model corresponding to the client identification, and installation completion information.
In the technical scheme of the invention, before the PXE client is started from the PXE, the PXE server correspondingly stores the client identifier and the MAC address which are input by an operator aiming at each PXE client in a database in advance; and providing a selection menu containing the client identification and the operating system to be installed for the operator through display. And then, the PXE server determines a corresponding starting configuration file according to the model of the operating system selected by the operator in the operating system selection menu, and adds the address of the determined starting configuration file to a boot file corresponding to the MAC address according to the MAC address selected by the operator in the operating system selection menu. After the PXE client is started from the PXE, an operator does not need to perform operation system selection operation or any intervention on the PXE client, the PXE client obtains the starting configuration file from the PXE server by reading the address of the starting configuration file in the boot file, and the operating system can be automatically installed according to the starting configuration file. Therefore, the operation of selecting the operating system for each PXE client to be installed can be performed by an operator only by performing the operation of selecting the operating system for each PXE client to be installed once on the PXE server, and compared with the existing operation that the operator needs to perform the operation of selecting the operating system on each PXE client one by one, a great deal of time and energy are saved, and therefore the installation efficiency of installing the operating systems in batches is improved.
Those skilled in the art will appreciate that all or part of the steps in the method for implementing the above embodiments may be implemented by relevant hardware instructed by a program, and the program may be stored in a computer readable storage medium, such as: ROM/RAM, magnetic disk, optical disk, etc.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be construed as the protection scope of the present invention.