Network-based automated installation system (CENTOS6.5+DHCP+TFTP+PXE) on Linux

Source: Internet
Author: User
Tags file transfer protocol

Network-based automated installation system (CENTOS6.5+DHCP+TFTP+PXE) on Linux

First, preface

Installation system is commonly used in the way that CD-ROM installation, U disk installation, but this manual installation method is very inefficient, and the probability of error is large.
Now the NIC speed is also basic 1000M, so the network installation is more simple, the administrator from the repetitive, cumbersome installation operation freed.
Of course, this is only a local area network of experimental configuration, production environment will have a more professional solution, but this principle is the same.

Second, the principle

The protocols and techniques used in this experiment are:
Dhcp:dynamic host config Protocol Dynamic Host Configuration Protocol
tftp:trivial file Transfer Protocol Small Files Transfer Protocol
Pxe:preboot Execution Environment Remote boot technology

Tell us about the dhcp,tftp,pxe relationship and the start-up process in this network installation, this experiment is DHCP and TFTP is on the same server.
The detailed process is as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/ED/wKiom1WLuc6RRXpJAAEddHK7DPQ556.jpg "style=" float: none; "title=" pxe.jpg "alt=" Wkiom1wluc6rrxpjaaeddhk7dpq556.jpg "/>




1. Target client sends DHCP requests to the DHCP server
First, the client side of the network card must support PXE, and the client's BIOS set to the network boot as the first order, and then PXE Bootrom will send a broadcast request discover in the UDP protocol, the network to the DHCP server request IP address and other information.

2. DHCP receives the broadcast and sends a broadcast packet in response to the client an offer, meaning I can give you IP information

3. After the client receives a DHCP offer, it continues to send a broadcast packet, initiating a request to the DHCP service

4. After the DHCP server receives the request, it verifies that it is from a legitimate PXE client and, after validation, responds to the client by providing: IP address, pxelinux boot program location (TFTP), and the location of the configuration file

5. The client requests the download of the boot file to the TFTP server, which includes:
pxelinux.0, Vmlinuz, initrd.img, Pxelinux.cfg/default, pxelinux.cfg/list

6. After the TFTP server receives the request, start TFTP and start the transfer of the boot file
After the server receives the client's request, there will be more information between the client and the server to determine the startup parameters. Bootrom The files (pxelinux.0, pxelinux.cfg/default) that are necessary to launch the Setup program from the boot server by the TFTP communication protocol. When the default file download is complete, the system downloads and reads the pxelinux.cfg/list file, the operator needs to install the system listed in list to select, launch the corresponding Linux system and install the program's boot kernel.


Third, the experimental ideas

1. Prerequisites:
The client machine must support PXE boot
Client machine, dhcp,tftp must be within the same LAN
The system to be installed requires support for Pxeboot

2. Programme data:

Pre-installed system:
CentOS6.6

DHCP server (TFTP server) information:
ip:192.168.100.200
os:centos6.6

Client machine Information:
Mac:00:0c:29:c1:3a:ab
ip:192.168.100.222 (can be reserved in DHCP configuration)


Iv. concrete steps of the experiment

1. Configuration of the DHCP service

1) Install the DHCO server package:

#yum-y Install DHCP

2) Edit the DHCP configuration file:
A. You can view the sample configuration file by Rpm-ql DHCP, which makes it easier to edit:

#rpm-ql DHCP

Find a sample here/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample
#复制dhcpd. Confg.sample to/etc/dhcp/dhcpd.conf

#cp/usr/share/doc/dhcp-4.1.1/dhcpd.conf

B. Edit dhcpd.conf

#vim/etc/dhcp/dhcpd.conf

Option Domain-name "richie.com";
Option Domain-name-servers 8.8.8.8;

Default-lease-time 86400;
Max-lease-time 100000;

Log-facility Local7;
Subnet 192.168.100.0 netmask 255.255.255.0 {
Range 192.168.100.201 192.168.100.222;
#option routers 192.168.100.200;
Next-server 192.168.100.200; # The IP of the TFTP server (here is the IP of this machine)
FileName "pxelinux.0";
}


Note the next-server and filename parameters, which specify the location of the TFTP server and the name of the startup file, respectively.

C. Start the DHCP service
Before starting, you should detect if there is an error in the configuration file, you can use the following command:

#service DHCPD configtest

If prompted

#Syntax: OK

That's fine. Continue to start the DHCP service

#service dhcpd Restart

2. TFTP server Configuration
1) Installing the TFTP service pack

#yum-y Install Tftp-server

#TFTP的配置文件位于/etc/xinetd.d/tftp

2) Start the TFTP service
Since TFTP is a transient daemon, relies on xinetd to listen, so start tftp, you must restart XINETD for the configuration to take effect

#启动tftp两种方式:
A. Modifying the TFTP configuration file Disable=no

#vim/etc/xinetd.d/tftp #disable =no

B. Using the Chkconfig command

#chkconfig TFTP on

Note that either of the two options can be implemented, but you must restart xinetd with the following command:

#service xinetd Restart

To see if UDP 69 ports are listening

# SS-UNL | grep:69

3) Prepare the startup file
A. Preparing to start the image file pxelinux.0
To get this file, you need to install the Syslinux package, and then copy the pxelinux.0 to the/var/lib/tftpboot directory

#yum-y Install Syslinux#cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot

B. Provide boot kernel and other files
Create the Pxelinux.cfg directory in the/var/lib/tftpboot directory at the same time
Mount the system CD, assuming the location is/media/cdrom/

# cp/media/cdrom/images/pxeboot/{vmlinuz,initrd.img}/var/lib/tftpboot/# cp/media/cdrom/isolinux/{splash.jpg, VESAMENU.C32,BOOT.MSG}/var/lib/tftpboot# mkdir/var/lib/tftpboot/pxelinux.cfg/# cp/media/cdrom/isolinux/ Isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default


3. Provide the installation source
Here we provide based on HTTP, mount the CentOS installation CD image
A. Installing the HTTP service

# yum-y Install httpd
# mkdir-pv/var/www/html/centos/6/x84_64

With/6/X86_64 This structure, it is convenient to use the variable to refer to this address later

# Mount--bind/media/cdrom/var/www/html/centos/6/x84_64

--bind can bind two mount addresses

Then we can use the ks.cfg to specify the installation source as http://192.168.100.200/centos/6/x86_64


4. Provide ks.cfg

There is no detailed provision on how to configure Ks.cfg, this is the kickstart script. You can use the System-config-kickstart tool to create

OK, basic OK, the drawings to appreciate, start the success of the appearance of it ~ ~

This TFTP message is going to flash through, so let's get to the bottom of the process.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/ED/wKiom1WLufaRt-NLAAHvJu-ibvI667.jpg "style=" float: none; "title=" pxe1.jpg "alt=" Wkiom1wlufart-nlaahvju-ibvi667.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/EA/wKioL1WLu7LhyVL_AAIKX3axAAM916.jpg "style=" float: none; "title=" pxe2.jpg "alt=" Wkiol1wlu7lhyvl_aaikx3axaam916.jpg "/>



In this menu state, press ESC to enter the boot command line, you can continue to type boot option to specify the KS script ah, configure IP information and many other content, the specific option can refer to Redhat's Installation Guide document is very detailed.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/ED/wKiom1WLugaS6lU1AAA7AuoBZIM126.jpg "title=" Pxe3.jpg "alt=" Wkiom1wlugas6lu1aaa7auobzim126.jpg "/>


This experiment is here, thank you for your attention!


This article from "Richier" blog, reproduced please contact the author!

Network-based automated installation system (CENTOS6.5+DHCP+TFTP+PXE) on Linux

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.