A method, system, electronic device, and storage medium for installing an operating system via PXE.
By obtaining the diskless system kernel file and PXE boot file of the TFTP server, loading the diskless operating system and installing the network card driver, the problem of PXE clients being unable to install the operating system in a network-free environment is solved, achieving efficient operating system installation.
Patent Information
- Application Number
- CN202211685862.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-27
- Publication Date
- 2025-11-14
- Estimated Expiration
- 2042-12-27
AI Technical Summary
In the absence of a network environment, the PXE client cannot load the network card driver, thus preventing the installation of the operating system via PXE.
By obtaining the diskless system kernel file from the TFTP server, the diskless operating system is loaded using the PXE boot file, the network card driver is installed, and the installation resources are obtained from the HTTP server through the network card driver to complete the installation of the operating system.
Even without an operating system or network card driver, the loading of the network card driver and the installation of the operating system were achieved, improving installation efficiency.
Smart Images

Figure CN116048552B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of operating system installation technology, and in particular to a method, system, electronic device, and storage medium for installing an operating system via PXE. Background Technology
[0002] Installing a Linux operating system via PXE is a mature installation method. In the server testing field, due to its characteristics, frequent operating system installations are necessary, making PXE a commonly used approach. Since PXE installation is network-based, the machine being installed (the PXE client) must have a usable network environment. Typically, the PXE client's network environment is provided by its network card, requiring the operating system to have a working network card driver. However, since the PXE client itself needs an operating system installed, the network card driver must be loaded on the PXE client before installing the operating system. Summary of the Invention
[0003] In view of this, the present invention provides a method, system, electronic device, and storage medium for installing an operating system via PXE. It aims to load network card drivers for PXE clients in offline environments.
[0004] In a first aspect of the present invention, a method for installing an operating system via PXE is provided, applied to a PXE client, the method comprising:
[0005] The diskless system kernel file in the TFTP server is obtained by sending a first retrieval request to the TFTP server.
[0006] The diskless system kernel file is loaded and executed using the PXE boot file to load the diskless operating system.
[0007] Install the network card driver using the diskless operating system;
[0008] Based on the network card driver, a request to obtain installation resources is sent to the HTTP server;
[0009] Based on the installation resource retrieval request, obtain the installation resources from the HTTP server;
[0010] Based on the installation resources, the operating system is installed.
[0011] Optionally, obtaining the PXE boot file includes:
[0012] By sending an IP address request to the DHCP server, the IP address and PXE boot file address returned by the DHCP server are obtained;
[0013] The PXE boot file in the TFTP server is obtained by sending a second retrieval request to the TFTP server.
[0014] Optionally, loading and executing the diskless system kernel file via the PXE boot file to load the diskless operating system includes:
[0015] The configuration file in the TFTP server is obtained by sending a third retrieval request to the TFTP server;
[0016] The kernel initial image file in the TFTP server is obtained by sending a fourth retrieval request to the TFTP server;
[0017] The configuration file is read through the PXE boot file;
[0018] The initial kernel image file is loaded using the configuration file to start the Linux kernel;
[0019] The booted Linux system mounts and executes the diskless system kernel file to load the diskless operating system.
[0020] Optionally, before obtaining the diskless system kernel file in the TFTP server by sending a first retrieval request to the TFTP server, the method further includes:
[0021] Determine the kernel of the operating system to be installed;
[0022] Based on the kernel of the operating system to be installed, construct a diskless system kernel file that includes the same diskless operating system kernel as the operating system to be installed.
[0023] Optionally, the diskless system kernel file includes at least a shell program module, a make program module, a C language compiler, and linux-devel.
[0024] A second aspect of the present invention provides a method for installing an operating system via PXE, applied to a TFTP server, the method comprising:
[0025] Based on the first acquisition request from the PXE client, the diskless system kernel file is sent to the PXE client;
[0026] The PXE client loads and executes the diskless system kernel file through the PXE boot file to build the diskless operating system of the PXE client;
[0027] The PXE client installs the network card driver through the diskless operating system.
[0028] The PXE client sends an installation resource acquisition request to the HTTP server based on the network card driver.
[0029] The PXE client obtains the installation resources from the HTTP server based on the installation resource acquisition request;
[0030] The PCE client executes the operating system installation based on the installation resources.
[0031] Optionally, obtaining the PXE boot file includes:
[0032] The PXE client obtains the IP address and PXE boot file address returned by the DHCP server by sending an IP address request to the DHCP server;
[0033] Based on the second acquisition request from the PXE client, the PXE boot file is sent to the PXE client.
[0034] Optionally, the PXE client loads and executes the diskless system kernel file through the PXE boot file to build the diskless operating system of the PXE client, including:
[0035] Based on the third retrieval request from the PXE client, the configuration file is sent to the PXE client;
[0036] Based on the fourth retrieval request from the PXE client, the kernel initial image file is sent to the PXE client;
[0037] The PXE client reads the configuration file through the PXE boot file;
[0038] The PXE client loads the initial kernel image file through the configuration file to start the Linux kernel;
[0039] The PXE client mounts and executes the diskless system kernel file based on the booted Linux to load the diskless operating system.
[0040] In a third aspect of the present invention, a system for installing an operating system via PXE is provided, the system comprising:
[0041] The diskless system kernel file acquisition module is used to obtain the diskless system kernel file in the TFTP server by sending a first acquisition request to the TFTP server;
[0042] The diskless operating system loading module is used to load and execute the diskless system kernel file through the PXE boot file, thereby loading the diskless operating system.
[0043] A network card driver installation module is used to install network card drivers through the diskless operating system.
[0044] The installation resource acquisition request sending module is used to send an installation resource acquisition request to the HTTP server based on the network card driver.
[0045] The installation resource acquisition module is used to obtain installation resources from the HTTP server according to the installation resource acquisition request;
[0046] An operating system installation module is used to perform the installation of the operating system based on the installation resources.
[0047] In a fourth aspect of the present invention, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus.
[0048] Memory, used to store computer programs;
[0049] When a processor executes a program stored in memory, it implements the steps of a method for installing an operating system via PXE provided in the first aspect of the present invention.
[0050] In a fifth aspect of the present invention, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements a method for installing an operating system via PXE as described in the first aspect of the present invention.
[0051] Compared with prior art, the present invention has the following advantages:
[0052] This invention provides a method for installing an operating system via PXE. It obtains a pre-built diskless system kernel file from a TFTP server and loads and executes this kernel file using a PXE boot file, thereby loading a diskless operating system onto the PXE client. Once the PXE client has this diskless operating system, it installs a network card driver using it. After the network card driver installation is complete, it sends an installation resource request to an HTTP server. Upon obtaining the installation resources, it installs the operating system on the PXE client based on these resources. This invention allows for the loading of a network card driver and subsequent operating system installation even when the PXE client lacks both an operating system and a network card driver.
[0053] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0054] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0055] Figure 1 A flowchart illustrating a method for installing an operating system via PXE, provided as an embodiment of the present invention;
[0056] Figure 2 Another flowchart of a method for installing an operating system via PXE provided in an embodiment of the present invention;
[0057] Figure 3 This is a schematic diagram illustrating the installation of an operating system via PXE, as provided in an embodiment of the present invention. Detailed Implementation
[0058] Exemplary embodiments of the present invention will now be described in more detail with reference to the accompanying drawings.
[0059] Before describing this invention, the background of this invention should be explained. PXE installation of Linux operating systems is a mature solution for batch installation of operating systems on terminals. In the field of server testing, due to the nature of server testing, operating systems are installed on servers more frequently. If staff were to install the operating system on each server individually, it would be time-consuming and labor-intensive, and if one installation failed, it would prevent the installation on other servers. Therefore, the PXE batch operating system installation method has gradually become a convenient and commonly used method. However, since PXE installation is performed over a network, the devices to be installed, i.e., the PXE clients, must have a usable network environment.
[0060] Currently, there are two main ways to install an operating system using PXE: First, if the pre-installed kernel (initrd.img) of the operating system on the PXE client terminal contains network card drivers, the network card with the built-in drivers from the PXE client's operating system can be used for installation. Second, for scenarios where a network card without drivers must be used for PXE installation, an operating system needs to be installed on the PXE terminal first, then the network card driver needs to be installed, the corresponding driver files need to be copied, the pre-installed kernel (initrd.img) needs to be extracted, the previously installed driver files need to be copied to the extracted pre-installed kernel, the relevant configuration files need to be modified, and then a long initrd.img file needs to be packaged. This second approach creates a paradox: the PXE client is essentially a terminal that wants to install an operating system, and to install an operating system on the PXE client, it needs to have the driver files (usually ending in xxx.ko) generated by the driver installation process. In other words, the PXE client needs an operating system to install drivers and generate driver files, and only with these driver files can the operating system be installed. In this case, the PXE client must first install the operating system through other means before the operating system can be installed via PXE.
[0061] In view of this, the present invention proposes a novel method for installing an operating system via PXE. For scenarios where a network card without a network card driver must be used for PXE installation, the present invention obtains a pre-built diskless system kernel file from a TFTP server and loads and executes the diskless system kernel file using a PXE boot file, thereby loading a diskless operating system for the PXE client. After the PXE client has this diskless operating system, it installs the network card driver using this operating system. After the network card driver installation is complete, it sends an installation resource retrieval request to an HTTP server. Upon obtaining the installation resource, it installs the operating system on the PXE client based on this installation resource. Through the embodiments of the present invention, even when the PXE client has neither an operating system nor a network card driver, the network card driver can be installed and loaded based on the diskless system kernel file of the present invention, and subsequent operating system installation can proceed.
[0062] Figure 1 A flowchart illustrating a method for installing an operating system via PXE, as provided in this embodiment of the invention, is shown below. Figure 1 As shown, applied to a PXE client, the method includes:
[0063] Step S101: Obtain the diskless system kernel file in the TFTP server by sending a first acquisition request to the TFTP server;
[0064] Step S102: Load and execute the diskless system kernel file through the PXE boot file to load the diskless operating system;
[0065] Step S103: Install the network card driver using the diskless operating system;
[0066] Step S104: Send an installation resource acquisition request to the HTTP server based on the network card driver;
[0067] Step S105: Obtain the installation resources from the HTTP server according to the installation resource acquisition request;
[0068] Step S106: Install the operating system according to the installation resources.
[0069] In embodiments of this invention, PXE (preboot execute environment) is referred to as the preboot execution environment. Installing a Linux operating system via PXE is a mature operating system installation method. The terminal that needs to install the operating system is referred to as the PXE client. The PXE client that needs to install the operating system sends a first retrieval request to the TFTP server to obtain the diskless system kernel file pre-stored on the TFTP server. After receiving the first retrieval request from the PXE client that needs to install the operating system, the TFTP server determines the validity of the first retrieval request. If the determination result indicates that the first retrieval request is valid, the TFTP server sends the stored diskless system kernel file to the PXE client that needs to install the operating system.
[0070] In an embodiment of the present invention, after the PXE client requiring operating system installation obtains the diskless system kernel file, the PXE boot file in the PXE client guides the client to load and execute the diskless system kernel file obtained from the TFTP server. By loading and executing the diskless system kernel file, a diskless operating system, namely RAMOS (Random Access Memory Operating System), is created and loaded in the PXE client requiring operating system installation.
[0071] In an embodiment of the present invention, the PXE boot file is used to guide the PXE client that needs to install the operating system to perform the operating system installation.
[0072] In an embodiment of the present invention, after loading the diskless operating system into the PXE client requiring operating system installation, the network card driver is installed using the diskless operating system. After the network card driver installation is complete, the PXE client sends an installation resource retrieval request to the HTTP server based on the installed network card driver to obtain the corresponding operating system installation resources. Upon receiving the installation resource retrieval request, the HTTP server sends the stored installation resources to the PXE client. After receiving the installation resources, the PXE boot file guides the PXE client to install the operating system based on the received installation resources.
[0073] In this embodiment of the invention, the diskless kernel file (initrd-ramos.img) is transferred to the PXE client requiring operating system installation via a TFTP server. Since TFTP does not require a network card driver for data transfer, based on this characteristic, the PXE client requiring operating system installation in this invention first loads a diskless operating system, RAMOS (Random Access Memory Operating System), through the diskless kernel file. Then, under this diskless operating system, the network card driver required for subsequent data transfer with HTTP is installed. Finally, the network card connects to the HTTP server to obtain the installation resources transferred from the HTTP server to the PXE client requiring operating system installation, and then the operating system is installed based on these installation resources. This embodiment of the invention, for network cards without built-in drivers, eliminates the need for a pre-installed operating system before installing the operating system via PXE. Instead, it utilizes the fact that TFTP does not require a network card to achieve a complete PXE installation process in one step.
[0074] The embodiment of this invention expands the pre-installation kernel (i.e., initrd.img), which only provides a pre-installation environment during the PXE installation process, into a diskless system kernel file (i.e., initrd-ramos.img). This diskless system kernel file provides a basically complete RAMOS (Random Access Memory Operating System), thereby enabling the installation of network cards and other operations on the basis of RAMOS, thus improving the installation efficiency of the operating system.
[0075] This invention provides a method for installing an operating system via PXE. It obtains a pre-built diskless system kernel file from a TFTP server and loads and executes this kernel file using a PXE boot file, thereby loading a diskless operating system onto the PXE client. Once the PXE client has this diskless operating system, it installs a network card driver using it. After the network card driver installation is complete, it sends an installation resource request to an HTTP server. Upon obtaining the installation resources, it installs the operating system on the PXE client based on these resources. This invention allows for the loading of a network card driver and subsequent operating system installation even when the PXE client lacks both an operating system and a network card driver.
[0076] In this invention, obtaining the PXE boot file includes: obtaining the IP address and PXE boot file address returned by the DHCP server by sending an IP address request to the DHCP server; and obtaining the PXE boot file in the TFTP server by sending a second acquisition request to the TFTP server.
[0077] In an embodiment of the present invention, obtaining the PXE boot file for guiding the PXE client to install the operating system includes: the PXE client sending an IP address request to a DHCP server; upon receiving the IP address request, the DHCP server automatically allocates an IP address from its IP address pool to the PXE client and informs the PXE client of the IP address of the TFTP server and the location of the PXE boot file pxelinux.0; specifically, the allocated IP address, the TFTP server's IP address, and the location of the PXE boot file pxelinux.0 are returned to the PXE client.
[0078] In an embodiment of the present invention, after the PXE client requiring operating system installation receives the assigned IP address from the DHCP server, the IP address of the TFTP server, and the location of the PXE boot file pxelinux.0, it sends a second retrieval request to the TFTP server based on the TFTP server's IP address and the location of the PXE boot file pxelinux.0, requesting to retrieve the PXE boot file pxelinux.0 from the TFTP server so that it can be used to boot the subsequent operating system installation for the PXE client requiring operating system installation. Upon receiving the second retrieval request from the PXE client requiring operating system installation, the TFTP server determines the legitimacy of the second retrieval request based on the information regarding the location of the PXE boot file pxelinux.0 in the second retrieval request. After determining the legitimacy of the second retrieval request, the TFTP server returns the PXE boot file pxelinux.0 to the PXE client requiring operating system installation for booting the operating system installation.
[0079] In this invention, the step of loading and executing the diskless system kernel file through the PXE boot file to load the diskless operating system includes: obtaining a configuration file in the TFTP server by sending a third retrieval request to the TFTP server; obtaining an initial kernel image file in the TFTP server by sending a fourth retrieval request to the TFTP server; reading the configuration file through the PXE boot file; loading the initial kernel image file through the configuration file to start the Linux kernel; and mounting and executing the diskless system kernel file based on the started Linux kernel to load the diskless operating system.
[0080] In embodiments of the present invention, except for the installation resources required by the PXE client for operating system installation, which need to be obtained from the HTTP server, all other related files are obtained through the TFTP server. Specifically, the PXE client for operating system installation sends a third acquisition request to the TFTP server to obtain the configuration file in the TFTP server. In response to the received third acquisition request, the TFTP server sends the configuration file to the PXE client for operating system installation. The PXE client for operating system installation then sends a fourth acquisition request to the TFTP server to obtain the kernel initial image file in the TFTP server. In response to the received fourth acquisition request, the TFTP server sends the kernel initial image file to the PXE client for operating system installation. The diskless system kernel file in the PXE client for operating system installation is obtained by the PXE client for operating system installation sending a first acquisition request to the TFTP server, and the TFTP server, in response to the received fourth acquisition request, sending the diskless system kernel file to the PXE client for operating system installation.
[0081] In an embodiment of the present invention, after receiving the configuration file, kernel initial image file, and diskless system kernel file transmitted from the TFTP server, the PXE client requiring operating system installation reads the configuration file required for operating system installation through the PXE boot file in the PXE client. Based on the read configuration file, it loads the received kernel initial image file to start the Linux kernel of the kernel initial image file. Based on the Linux kernel started in the PXE client requiring operating system installation, it mounts and executes the pre-created diskless kernel file, thereby loading the corresponding diskless operating system, so that the network card driver can be installed directly through the diskless operating system.
[0082] In this invention, before obtaining the diskless system kernel file in the TFTP server by sending a first acquisition request to the TFTP server, the method further includes: determining the kernel of the operating system to be installed; and constructing a diskless system kernel file that includes the same diskless operating system kernel as the operating system to be installed, based on the kernel of the operating system to be installed.
[0083] In an embodiment of the present invention, to ensure that the subsequent network card driver can be used by the PXE client requiring operating system installation after the operating system is installed, the present invention, when constructing the diskless system kernel file, first needs to determine the type of operating system to be installed by the PXE client, determine the corresponding kernel based on the type of operating system to be installed, and then construct a diskless system kernel file that includes the same kernel as the type of operating system to be installed. That is, before creating the diskless system kernel file, it is necessary to determine the kernel type of the diskless operating system in the diskless system kernel file, and this kernel type is the same as the kernel type corresponding to the type of operating system to be installed by the PXE client. After determining the kernel of the diskless operating system, a diskless system kernel file including the diskless operating system is constructed.
[0084] In this invention, the diskless system kernel file includes at least a shell program module, a make program module, a C language compiler, and linux-devel.
[0085] In embodiments of the present invention, to enable the diskless system kernel file to install the network card driver, the diskless system kernel file needs to include all the tools required for network card driver installation. Therefore, the pre-built diskless system kernel file in the present invention includes at least a shell program module, a make program module, a C language compiler, and linux-devel. The shell program module is an application that connects the user and the Linux kernel, allowing the user to use the Linux kernel more efficiently, securely, and at low cost; the make program module is used to compile executable programs; in Linux, devel stands for develop, referring to the development package of the corresponding software package; linux-devel is the development package of the corresponding software package, containing all the necessary files for developing programs using this development package, including at least header files and libraries, and sometimes development documentation or demo code.
[0086] A second aspect of the present invention provides a method for installing an operating system via PXE, applied to a TFTP server. The method includes: sending a diskless system kernel file to the PXE client according to a first acquisition request from the PXE client; the PXE client loading and executing the diskless system kernel file through a PXE boot file to construct a diskless operating system for the PXE client; the PXE client installing a network card driver through the diskless operating system; the PXE client sending an installation resource acquisition request to an HTTP server based on the network card driver; the PXE client obtaining installation resources from the HTTP server according to the installation resource acquisition request; and the PXE client executing the installation of the operating system according to the installation resources.
[0087] In an embodiment of the present invention, the TFTP server stores various files for PXE installation. The TFTP server receives a first acquisition request sent by a PXE client that needs to install an operating system. After receiving the first acquisition request, the TFTP server performs a validity judgment on the first acquisition request. If the validity judgment result indicates that the first acquisition request is a valid request, the TFTP server sends the pre-stored diskless system kernel file to the PXE client that needs to install an operating system.
[0088] In an embodiment of the present invention, after the PXE client that needs to install the operating system obtains the diskless system kernel file, the PXE boot file pxelinux.0 in the PXE client that needs to install the operating system guides the PXE client that needs to install the operating system to load and execute the diskless system kernel file obtained from the TFTP server.
[0089] In an embodiment of the present invention, the diskless system kernel file is loaded and executed to create and load the diskless operating system, namely RAMOS (Random Access Memory Operating System), in the PXE client that requires operating system installation. This RAMOS will be mainly used for subsequent network card driver installation.
[0090] In an embodiment of the present invention, after loading the diskless operating system in the PXE client requiring operating system installation, the network card driver in the PXE client requiring operating system installation is installed using the diskless operating system. After the network card driver installation is completed, the PXE client requiring operating system installation sends an installation resource retrieval request to the HTTP server based on the installed network card driver to obtain the corresponding operating system installation resources. Upon receiving the installation resource retrieval request, the HTTP server sends the stored installation resources to the PXE client requiring operating system installation. After receiving the installation resources, the PXE boot file guides the PXE client requiring operating system installation to install the operating system based on the received installation resources.
[0091] In this embodiment of the invention, the diskless kernel file (initrd-ramos.img) is transferred to the PXE client requiring operating system installation via a TFTP server. Since TFTP does not require a network card driver for data transfer, based on this characteristic, the PXE client requiring operating system installation in this invention first loads a diskless operating system, RAMOS (Random Access Memory Operating System), through the diskless kernel file. Then, under this diskless operating system, the network card driver required for subsequent data transfer with HTTP is installed. Finally, the network card connects to the HTTP server to obtain the installation resources transferred from the HTTP server to the PXE client requiring operating system installation, and then the operating system is installed based on these installation resources. This embodiment of the invention, for network cards without built-in drivers, eliminates the need for a pre-installed operating system before installing the operating system via PXE. Instead, it utilizes the fact that TFTP does not require a network card to achieve a complete PXE installation process in one step.
[0092] The embodiment of this invention expands the pre-installation kernel (i.e., initrd.img), which only provides a pre-installation environment during the PXE installation process, into a diskless system kernel file (i.e., initrd-ramos.img). This diskless system kernel file provides a basically complete RAMOS (Random Access Memory Operating System), thereby enabling the installation of network cards and other operations on the basis of RAMOS, thus improving the installation efficiency of the operating system.
[0093] This invention provides a method for installing an operating system via PXE. It obtains a pre-built diskless system kernel file from a TFTP server and loads and executes this kernel file using a PXE boot file, thereby loading a diskless operating system onto the PXE client. Once the PXE client has this diskless operating system, it installs a network card driver using it. After the network card driver installation is complete, it sends an installation resource request to an HTTP server. Upon obtaining the installation resources, it installs the operating system on the PXE client based on these resources. This invention allows for the loading of a network card driver and subsequent operating system installation even when the PXE client lacks both an operating system and a network card driver.
[0094] In this invention, obtaining the PXE boot file includes: the PXE client obtaining the IP address and PXE boot file address returned by the DHCP server by sending an IP address request to the DHCP server; and sending the PXE boot file to the PXE client according to the second acquisition request of the PXE client.
[0095] In an embodiment of the present invention, the PXE client that needs to install the operating system first sends an IP address request to the DHCP server. In response to the IP address request, the DHCP server automatically allocates an IP address from the IP address pool to the PXE client that needs to install the operating system, and sends the IP address of the TFTP server and the location of the PXE boot file pxelinux.0 to the PXE client that needs to install the operating system. Specifically, the allocated IP address, the IP address of the TFTP server, and the location of the PXE boot file pxelinux.0 are returned to the PXE client that needs to install the operating system.
[0096] In an embodiment of the present invention, after the PXE client requiring operating system installation receives the assigned IP address and the IP address of the TFTP server, as well as the location of the PXE boot file pxelinux.0, returned by the DHCP server, the TFTP server, upon receiving a second acquisition request from the PXE client requiring operating system installation, responds to the second acquisition request by determining the location information of the PXE boot file pxelinux.0 in the second acquisition request, and determines the legitimacy of the second acquisition request based on the location information of the PXE boot file pxelinux.0. After the TFTP server determines that the second acquisition request is legitimate, it returns the PXE boot file pxelinux.0 to the PXE client requiring operating system installation for guiding the PXE client to perform operating system installation.
[0097] In this invention, the PXE client loads and executes the diskless system kernel file through the PXE boot file to build a diskless operating system for the PXE client, including: sending a configuration file to the PXE client according to a third acquisition request from the PXE client; sending an initial kernel image file to the PXE client according to a fourth acquisition request from the PXE client; the PXE client reading the configuration file through the PXE boot file; the PXE client loading the initial kernel image file through the configuration file to start the Linux kernel; and the PXE client mounting and executing the diskless system kernel file based on the started Linux kernel to load the diskless operating system.
[0098] In an embodiment of the present invention, the TFTP server stores all relevant files, excluding installation resources, required for PXE installation. All these relevant files require the PXE client needing to install the operating system to send a corresponding retrieval request to the TFTP server. After receiving each corresponding retrieval request, the TFTP server sends the corresponding relevant file to the PXE client. Specifically, upon receiving a third retrieval request from the PXE client, the TFTP server sends a configuration file to the PXE client; upon receiving a fourth retrieval request from the PXE client, the TFTP server sends an initial kernel image to the PXE client; and upon receiving a first retrieval request from the PXE client, the TFTP server sends a diskless system kernel file to the PXE client.
[0099] In an embodiment of the present invention, after the TFTP server sends the configuration file, the initial kernel image file, and the diskless system kernel file to the PXE client requiring operating system installation, the PXE client performs subsequent installation operations based on the received configuration file, initial kernel image file, and diskless system kernel file. Specifically, the PXE boot file in the PXE client reading the configuration file required for operating system installation loads the received initial kernel image file to start the Linux kernel of the initial kernel image file. Based on the Linux kernel started in the PXE client, the pre-created diskless kernel file is mounted and executed, thereby loading the corresponding diskless operating system, allowing the network card driver to be installed directly through the diskless operating system.
[0100] In an embodiment of the present invention, Figure 2 Another flowchart illustrating a method for installing an operating system via PXE, provided as an embodiment of the present invention. Figure 2As shown, one embodiment of the method for installing an operating system via PXE provided by the present invention is as follows: First, the PXE client that needs to install the operating system sends an IP address request to the DHCP server. After receiving the IP address request, the DHCP server responds by automatically allocating an IP address from its IP address pool to the PXE client that needs to install the operating system, and informing the PXE client of the IP address of the TFTP server and the location of the PXE boot file pxelinux.0. Specifically, the allocated IP address, the IP address of the TFTP server, and the location of the PXE boot file pxelinux.0 are returned to the PXE client that needs to install the operating system. Then, the PXE client that needs to install the operating system sends a second retrieval request to the TFTP server to request the PXE boot file pxelinux.0 from the TFTP server, so that it can be used for subsequent booting of the operating system installation for the PXE client. After receiving the second retrieval request from the PXE client that needs to install the operating system, the TFTP server determines the legitimacy of the second retrieval request by checking the location of the PXE boot file pxelinux.0 in the request. Once the TFTP server confirms the legitimacy of the second retrieval request, it returns the PXE boot file pxelinux.0 to the PXE client that needs to install the operating system, which is used to guide the PXE client to install the operating system. The PXE client requiring operating system installation continues to send a third retrieval request to the TFTP server to obtain the configuration file pxelinux.cfg from the TFTP server. In response to the received third retrieval request, the TFTP server sends the configuration file pxelinux.cfg to the PXE client requiring operating system installation. The PXE client requiring operating system installation then sends a fourth retrieval request to the TFTP server to obtain the initial kernel image file vmlinuz from the TFTP server. In response to the received fourth retrieval request, the TFTP server sends the initial kernel image file vmlinuz to the PXE client requiring operating system installation. Finally, the PXE client requiring operating system installation sends a first retrieval request to the TFTP server to obtain the diskless system kernel file initrd-ramos.img from the TFTP server. In response to the received first retrieval request, the TFTP server sends the diskless system kernel file initrd-ramos.img to the PXE client requiring operating system installation.In an embodiment of the present invention, after receiving the configuration file pxelinux.cfg, the initial kernel image file vmlinuz, and the diskless system kernel file initrd-ramos.img transmitted from the TFTP server, the PXE client requiring operating system installation reads the configuration file pxelinux.cfg required for operating system installation through the PXE boot file pxelinux.0 in the PXE client. Based on the read configuration file pxelinux.cfg, it loads the received initial kernel image file vmlinuz to start the Linux kernel of the initial kernel image file vmlinuz. Based on the Linux kernel started in the PXE client requiring operating system installation, it mounts and executes the pre-created diskless kernel file, thereby loading the corresponding diskless operating system, so that the network card driver can be directly installed through the diskless operating system. The loaded diskless operating system then installs the network card driver. After completing the network card driver installation, the PXE client that needs to install the operating system sends an installation resource retrieval request to the HTTP server to obtain the corresponding installation resources for operating system installation. Upon receiving the request, the HTTP server responds by returning the corresponding installation resources to the PXE client. After receiving the installation resources, the PXE client then installs the operating system based on those resources.
[0101] A third aspect of the present invention provides a system for installing an operating system via PXE. Figure 3 This is a schematic diagram illustrating the installation of an operating system via PXE, provided as an embodiment of the present invention. Figure 3 As shown, the system 300 includes:
[0102] The diskless system kernel file acquisition module 301 is used to obtain the diskless system kernel file in the TFTP server by sending a first acquisition request to the TFTP server;
[0103] The diskless operating system loading module 302 is used to load and execute the diskless system kernel file through the PXE boot file to load the diskless operating system.
[0104] The network card driver installation module 303 is used to install the network card driver through the diskless operating system.
[0105] The installation resource acquisition request sending module is used to send an installation resource acquisition request to the HTTP server based on the network card driver.
[0106] The installation resource acquisition module 304 is used to obtain installation resources from the HTTP server according to the installation resource acquisition request;
[0107] Operating system installation module 305 is used to perform operating system installation based on the installation resources.
[0108] Optionally, obtaining the PXE boot file required by the diskless operating system loading module 302 includes: obtaining the IP address and PXE boot file address returned by the DHCP server by sending an IP address request to the DHCP server; and obtaining the PXE boot file in the TFTP server by sending a second acquisition request to the TFTP server.
[0109] Optionally, the diskless operating system loading module 302 includes:
[0110] The configuration file acquisition module is used to obtain the configuration file in the TFTP server by sending a third acquisition request to the TFTP server;
[0111] The kernel initial image file acquisition module is used to obtain the kernel initial image file in the TFTP server by sending a fourth acquisition request to the TFTP server;
[0112] The file reading module is used to read the configuration file through the PXE boot file;
[0113] The kernel boot module is used to load the initial kernel image file through the configuration file to start the Linux kernel;
[0114] The diskless operating system loading submodule is used to mount and execute the diskless system kernel file based on the booted Linux to load the diskless operating system.
[0115] Optionally, the system 300 further includes:
[0116] The kernel determination module is used to determine the kernel of the operating system to be installed.
[0117] The diskless system kernel file building module is used to build a diskless system kernel file that includes the same kernel as the diskless operating system to be installed, based on the kernel of the operating system to be installed.
[0118] This invention provides a system for installing an operating system via PXE. A diskless system kernel file acquisition module obtains a pre-built diskless system kernel file from a TFTP server. A diskless operating system loading module then loads and executes the diskless system kernel file via the PXE boot file, thereby loading the diskless operating system onto the PXE client. After the PXE client has this diskless operating system, it installs the network card driver using the diskless operating system in the network card driver installation module. After the network card driver installation is complete, the client sends an installation resource acquisition request to the HTTP server via the installation resource acquisition request sending module and obtains the installation resource. Then, the operating system installation module installs the operating system on the PXE client based on the obtained installation resource. This invention allows for the loading of the network card driver and subsequent operating system installation even when the PXE client has neither an operating system nor a network card driver.
[0119] In a fourth aspect of the present invention, an electronic device is also provided, the electronic device including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus;
[0120] Memory, used to store computer programs;
[0121] When a processor executes a program stored in memory, it implements the steps of a method for installing an operating system via PXE provided in the first aspect of the present invention.
[0122] In a fifth aspect of the present invention, a computer-readable storage medium is also provided, on which a computer program is stored, which, when executed by a processor, implements a method for installing an operating system via PXE as described in the first aspect of the present invention.
[0123] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0124] It should be noted that in this paper, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply otherwise.
[0125] There is no such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also...
[0126] Other elements not explicitly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, elements defined by the phrase "including a..."
[0127] The inclusion of an element does not preclude the presence of other identical elements in a process, method, article, or apparatus that includes the element.
[0128] The various embodiments in this specification are described in a related manner, and the various embodiments are the same.
[0129] Similar parts can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, for the system embodiments, since they are basically similar to the method embodiments, the description...
[0130] The description is relatively simple; for relevant details, please refer to the description in the method embodiment.
[0131] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.
Claims
1. A method for installing an operating system via PXE, characterized in that, Applied to PXE clients, the method includes: Determine the kernel of the operating system to be installed; based on the kernel of the operating system to be installed, construct a diskless system kernel file that includes the same diskless operating system kernel as the operating system to be installed; By sending a first retrieval request to the TFTP server, and when the TFTP server determines that the first retrieval request is valid, the diskless system kernel file in the TFTP server is obtained. The diskless system kernel file is obtained by extending the pre-installed kernel that provides a pre-installation environment. The diskless system kernel file includes at least a shell program module, a make program module, a C language compiler, and linux-devel. The diskless system kernel file is loaded and executed via a PXE boot file to load the diskless operating system. The PXE boot file is returned to the PXE client by the TFTP server after determining the validity of the second retrieval request based on the location information of the PXE boot file in the second retrieval request. The second retrieval request is sent by the PXE client to the TFTP server. The files required to load the diskless operating system include a configuration file and an initial kernel image file obtained from the TFTP server. The configuration file is used to load the initial kernel image file under the guidance of the PXE boot file to start the Linux kernel and load the diskless system kernel file. Install the network card driver using the diskless operating system; Based on the network card driver, a request to obtain installation resources is sent to the HTTP server; Based on the installation resource acquisition request, the installation resources are obtained from the HTTP server. The installation resources are obtained from the HTTP server, and all other related files are obtained through the TFTP server. Based on the installation resources, the PXE client that needs to install the operating system is guided by the PXE boot file, and the operating system is installed based on the received installation resources.
2. The method for installing an operating system via PXE according to claim 1, characterized in that, Obtaining the PXE boot file includes: By sending an IP address request to the DHCP server, the IP address and PXE boot file address returned by the DHCP server are obtained; The PXE boot file in the TFTP server is obtained by sending a second retrieval request to the TFTP server.
3. The method for installing an operating system via PXE according to claim 1, characterized in that, The process of loading and executing the diskless system kernel file via the PXE boot file to load the diskless operating system includes: The configuration file in the TFTP server is obtained by sending a third retrieval request to the TFTP server; The kernel initial image file in the TFTP server is obtained by sending a fourth retrieval request to the TFTP server; The configuration file is read through the PXE boot file; The initial kernel image file is loaded using the configuration file to start the Linux kernel; The booted Linux system mounts and executes the diskless system kernel file to load the diskless operating system.
4. A method for installing an operating system via PXE, characterized in that, Applied to a TFTP server, the method includes: Determine the kernel of the operating system to be installed; based on the kernel of the operating system to be installed, construct a diskless system kernel file that includes the same diskless operating system kernel as the operating system to be installed; Based on the first acquisition request from the PXE client, when the first acquisition request is determined to be valid, a diskless system kernel file is sent to the PXE client. The diskless system kernel file is obtained by extending the pre-installed kernel that provides the pre-installation environment. The diskless system kernel file includes at least a shell program module, a make program module, a C language compiler, and linux-devel. The PXE client loads and executes the diskless system kernel file through the PXE boot file to build a diskless operating system for the PXE client. The PXE boot file is returned to the PXE client by the TFTP server after determining the validity of the second retrieval request based on the location information of the PXE boot file in the second retrieval request. The second retrieval request is sent by the PXE client to the TFTP server. The files required to load the diskless operating system include a configuration file and an initial kernel image file obtained from the TFTP server. The configuration file is used to load the initial kernel image file under the guidance of the PXE boot file to start the Linux kernel and load the diskless system kernel file. The PXE client installs the network card driver through the diskless operating system. The PXE client sends an installation resource acquisition request to the HTTP server based on the network card driver. The PXE client obtains the installation resources from the HTTP server based on the installation resource acquisition request; The PXE client installs the operating system based on the received installation resources, guided by the PXE boot file.
5. A method for installing an operating system via PXE according to claim 4, characterized in that, Obtaining the PXE boot file includes: The PXE client obtains the IP address and PXE boot file address returned by the DHCP server by sending an IP address request to the DHCP server; Based on the second acquisition request from the PXE client, the PXE boot file is sent to the PXE client.
6. A method for installing an operating system via PXE according to claim 4, characterized in that, The PXE client loads and executes the diskless system kernel file through the PXE boot file to build the diskless operating system of the PXE client, including: Based on the third retrieval request from the PXE client, the configuration file is sent to the PXE client; Based on the fourth retrieval request from the PXE client, the kernel initial image file is sent to the PXE client; The PXE client reads the configuration file through the PXE boot file; The PXE client loads the initial kernel image file through the configuration file to start the Linux kernel; The PXE client mounts and executes the diskless system kernel file based on the booted Linux to load the diskless operating system.
7. A system for installing an operating system via PXE, characterized in that, The system includes: A module for determining the kernel of the operating system to be installed; a module for constructing a diskless system kernel file that includes the same diskless operating system kernel as the operating system to be installed, based on the kernel of the operating system to be installed. The diskless system kernel file acquisition module is used to obtain the diskless system kernel file in the TFTP server by sending a first acquisition request to the TFTP server, and when the TFTP server determines that the first acquisition request is valid, the diskless system kernel file is obtained by the pre-installed kernel extension that provides the pre-installation environment, and the diskless system kernel file includes at least a shell program module, a make program module, a C language compiler, and linux-devel; A diskless operating system loading module is used to load and execute the diskless system kernel file via a PXE boot file, thereby loading the diskless operating system. The PXE boot file is returned to the PXE client by the TFTP server after determining the validity of the second retrieval request based on the location information of the PXE boot file in the second retrieval request. The second retrieval request is sent by the PXE client to the TFTP server. The files required to load the diskless operating system include a configuration file and an initial kernel image file obtained from the TFTP server. The configuration file is used to load the initial kernel image file under the guidance of the PXE boot file, thereby starting the Linux kernel to load the diskless system kernel file. A network card driver installation module is used to install network card drivers through the diskless operating system. The installation resource acquisition request sending module is used to send an installation resource acquisition request to the HTTP server based on the network card driver. The installation resource acquisition module is used to obtain installation resources from the HTTP server according to the installation resource acquisition request; An operating system installation module is used to boot the PXE client that needs to install the operating system using the PXE boot file according to the installation resources, and to install the operating system based on the received installation resources.
8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of a method for installing an operating system via PXE as described in any one of claims 1-3.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements a method for installing an operating system via PXE as described in any one of claims 1-3.
Citation Information
Patent Citations
Starting method and device of an operating system, a storage medium and a client
CN109992311A