Install the system in the PXE environment (DHCP + tftp + HTTP + kickstart)

Source: Internet
Author: User

Simply put, this is a process of automatically installing the system through the Pex Nic. The entire startup process can be understood as follows: the computer starts from the Pex Nic device and obtains the IP address provided by the DHCP server after four mutual broadcasts between the NIC and DHCP service, in addition, the DHCP server will tell the network adapter the location of the TFTP service, so that the PXE network adapter can obtain the "pxelinux.0" Startup file, and then the file can be used to read some corresponding configuration files in the TFTP server, so that the computer can enter the system installation interface, and here we want to install through automated methods, so we need the Kickstart file, and in order to obtain the source, here I use the HTTP service for settings.

Next we can divide the PXE configuration process into five parts:

1. Configure the DHCP service

2. Configure the TFTP Server

3. Provide PXE Working Environment

4. Provide installation sources based on HTTP Services

5. Provide the Kickstart file, that is, the KS. cfg file.

Next we will use centos6.5 as an example.

The local IP address is 172.16.106.1


1. Configure the DHCP service

First, install the DHCP package.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/42/C6/wKiom1PYxvfglxAvAAAa_p2vbzA623.jpg "Title =" qq 40730182004.jpg "alt =" wkiom1pyxvfglxavaa_p2vbza623.jpg "/>

After installation, you can check which files are generated (not all files are listed here)

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/42/C7/wKiom1PYx2ei4LcsAAHT7vbjsBQ710.jpg "Title =" qq 2020205.jpg "alt =" wkiom1pyx2ei4lcsaaht7vbjsbq710.jpg "/>

Here,/etc/DHCP/DHCPD. conf is our configuration file.

You can refer to a configuration model in the configuration file.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/42/C9/wKioL1PYyRuweTQtAAAj889hfUA113.jpg "Title =" qq 40730182432.jpg "alt =" wkiol1pyyruwetqtaaaj889hfua113.jpg "/>

Refer to this to configure what we need

Below are some of my configurations;

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/42/CA/wKioL1PYyo3AYep7AAHuOuZiBJk240.jpg "Title =" qq 40730183040.jpg "alt =" wkiol1pyyo3ayep7aahuouzibjk240.jpg "/>

The configuration of subnet, the network segment and the mask, the address segment that can be provided as a DHCP server, and the option routers gateway, and next-server points to the following TFTP server, and filename points to the Startup file on the server.

In this way, the DHCP service is configured. to confirm whether the syntax format in the configuration file is correct, run the following command to test.

#service dhcpd configtest

After everything is normal, we can start the DHCP service.

#service dhcpd start


2. Configure the TFTP Server

Because TFTP depends on Xinetd, we recommend that you install the TFTP client at the same time (to facilitate debugging of the TFTP server)

#yum install xinetd #yum install tftp-server tftp            

Enable TFTP after pressing

# chkconfig tftp on

Of course, you have to restart xinetd to make it take effect. If yes, check whether port 69 of TFTP is enabled.

# Service xinetd restart # SS-unl | grep: 69 check whether port 69 is enabled


3. Provide PXE Working Environment

First, we need to install syslinux, which has the boot file we want to use, similar to the grub function.

You can check whether this item is installed first:

# rpm -q| grep syslinux

If not, install:

# yum install syslinux

After installation, we need to put the generated pxelinux.0 file under the path of our TFTP server, and some related files must be copied together. Here, we copy the kernel and other files together.

Note: I mounted the image disc of centos to/Media/CDROM.

# Cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot/# cp/Media/CDROM/images/pxeboot/{vmlinuz, initrd. IMG}/var/lib/tftpboot/kernel and root file system # cp/Media/CDROM/isolinux/{splash.jpg, vesamenu. c32, boot. MSG}/var/lib/tftpboot installation interface GUI and background image # mkdir/var/lib/tftpboot/pxelinux. CFG/# cp/Media/CDROM/isolinux. CFG/var/lib/tftpboot/pxelinux. CFG/Default Configuration File

With these files, the PXE Nic can enter the installation interface.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/42/DE/wKioL1PY3q-TR3JqAABio5DGH_Y994.jpg "Title =" qq 40730195623.jpg "alt =" wKioL1PY3q-TR3JqAABio5DGH_Y994.jpg "/>


4. Provide installation sources based on HTTP Services

To configure the source when installing the system, I use the HTTP Service to use the local machine as an HTTP server.

First, install the http package:

You can also check whether the HTTP service has been installed.

# Run rpm-Q httpd to check whether httpd is installed # Yum-y install httpd

Here, we only need to mount the local image disk and bind it to the default path of the HTTP service, to facilitate future operations, we do not directly mount the disk to/var/www/html/path, but to its subdirectory, because the disk is read-only and cannot be modified, once it is mounted to/var/www/html/, the content here cannot be modified. If it is placed in its subdirectory, the server can be more flexible.

# Mkdir/var/www/html/centos6 create a subdirectory named centos6 first # Mount -- bind/Media/CDROM/var/www/html/centos6/bind the disk to this subdirectory

In this way, an HTTP environment has been installed.


5. Provide the KS. cfg file

Here we first introduce the Kickstart file format, generally after the system is created will produce a anaconda-ks.cfg file in the Administrator's home directory/root, you can use it as your ks file template.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/42/E2/wKioL1PY5EWjp58JAAKe-KDHJE0356.jpg "style =" float: none; "Title =" my hot 41.jpg "alt =" wKioL1PY5EWjp58JAAKe-KDHJE0356.jpg "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/42/E2/wKioL1PY5EXD6eOoAAII_b-0ItE222.jpg "style =" float: none; "Title =" voice 302021.jpg "alt =" wKioL1PY5EXD6eOoAAII_b-0ItE222.jpg "/>

This file can be divided into three sections:

1. Command segment

2. Package segment: % packages

Pack_name is the name of a package.

@ Group package group name

-Pack_name: a package that is not installed, but is also installed if it is dependent.

3. Script segment

% Pre: Pre-installation script

% Post: script after installation


The Ks file can also be installed on a graphical interface. First, we need to install the Kickstart package:

# Configure Yum install system-config-kickstart after installation # system-config-kickstart

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/42/E5/wKiom1PY6F7xGcEfAAKxKMlZN_8697.jpg "Title =" qq 40730204226.jpg "alt =" yellow "/> enter this graphical interface, configure some of your needs.

After the configuration is complete, click the file option in the upper left corner, and then click Save. When you save the file, there will be interactions and you will be asked where to save the file and the file name, it is generally stored as/var/www/html/KS directly. cfg

In this way, a PXE installation environment is OK.

However, you must specify the location of the KS file during installation, as shown in figure

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/42/E7/wKioL1PY7AfySKOvAABM3LSzb4A533.jpg "Title =" qq 40730205332.jpg "alt =" wkiol1py7afy%aabm3lszb4a533.jpg "/>

If you want to be more automated, you can also directly write the KS path into the configuration file, that is, the/var/lib/tftproot/pxelinux. cfg/default file.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/42/E8/wKiom1PY7ATg7SsdAAFGMmuY_3s198.jpg "Title =" qq 40730205806.jpg "alt =" wkiom1py7atg7ssdaafgmmuy_3s198.jpg "/>

You can add Ks = http: // 172.16.106.1/KS. cfg to the last line of the label you want to use.


If everything works, our PXE environment will be successful. Okay, so we are here today!


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.