ArticleDirectory
Configure PXE + kickstart unattended installation in centos (howto install centos through PXE + kickstart)
Environment: centos 5.1 minimum installation.
Theory
Source: http://coolerfeng.blog.51cto.com/133059/48801
What is PXE?
PXE (pre-boot execution environment) is a protocol designed by Intel that enables computers to start over the network. The Protocol is divided into two ends: client and server. The PXE client is in the ROM of the NIC. When the computer boots, the BIOS transfers the PXE client to the memory for execution and displays the command menu. After the user selects the client, the PXE client downloads the operating system on the remote end to the local computer for running.
To successfully run the PXE protocol, you must solve the following two problems:
1. Since it is transmitted over the network, who will configure the IP address of the computer when it is started;
2. protocols used to download the Linux kernel and root file system
The first problem can be solved through the DHCP server. The DHCP server assigns an IP address to the PXE client. The DHCP server is a protocol used to dynamically allocate IP addresses to the DHCP client, however, because the IP address is assigned to the PXE client, you need to add a specific PXE configuration When configuring the DHCP server.
As for the second problem, TFTP client already exists in the ROM where the PXE client is located. PXE client uses the TFTP client to download the required files to the TFTP server through the TFTP protocol.
In this way, the conditions for running the PXE protocol are met. Let's take a look at the working process of the PXE protocol.
Work Process
In, PXE client is a computer that requires Linux installation. TFTP server and DHCP server run on another Linux server. The bootstrap file, configuration file, Linux kernel, and linux root file system are all stored in the root directory of the TFTP server on Linux server.
The PXE client requires three binary files: Bootstrap, Linux kernel, and linux root file system. The bootstrap file is executable.ProgramIt provides you with a simple control interface and downloads the appropriate Linux kernel and linux root file system based on your selection.
Practice
To implement an unattended installation of PXE + KickStart, we know from the above theoretical explanation that at least DHCP and TFTP services are required for guidance. To install the network, we need the NFS, HTTP, or FTP service. Here, we select NFS. To work on TFTP, We need to install xinetd. Add the syslinux to be installed to generate the bootstrap file. The software packages we want to install are as follows:
- DHCP
- TFTP-Server
- Xinetd
- Syslinux
- Nfs-utils
DCHP
Install DHCP:
Yum install-y DHCP
After the installation is complete, copy the DHCP. conf. sample file to/etc.
CP/usr/share/doc/dhcp-3.0.5/DHCP. conf-Sample/etc/DHCP. conf
Edit/etc/DHCP. conf.
Find:
Ignore client-updates;
Add it later:
Next-server 192.168.0.1;
Filename "pxelinux.0 ";
Find:
Option Nis-domain "domain.org ";
Option domain-name "domain.org ";
Option domain-name-server 192.168.1.1;
Annotate it
Configure your Nic and change its IP address to 192.168.0.1
Edit/etc/sysconfig/network-scripts/ifcfg-eth0
Find:
Bootproto = DHCP
Changed:
Bootproto = static
Add the following two rows:
Ipaddr = 192.168.0.1
Netmask = 255.255.255.0
Restart the network and start DHCP
/Etc/init. d/network restart
/Etc/INI. d/DHCPD start
TFTP-Server
Install the TFTP-Server Service (the relationship between the TFTP-server and the xinetd can be found by yourself ):
Yum install-y xinetd TFTP-Server
Configure TFTP-Server
Edit/etc/xinetd. d/TFTP
Find:
Disable = Yes
Change it
Disable = No
Start TFTP-Server
/Etc/init. d/xinetd start
Pxelinux.0
Pxelinux.0 is used when configuring DHCP. In fact, it is the bootstrap mentioned above. In centos, it is generated by syslinux. If syslinux is installed, a pxelinux.0 file is generated. You only need to copy it to/tftpboot.
Yum install-y syslinux
CP/usr/lib/syslinux/pxelinux.0/tftpboot/
Start File
Find the centos 5.1 DVD installation disk or ISO image (I will use the image here) and mount it to/MNT.
Mount-o loop/root/CentOS-5.1-i386-bin-DVD.iso/mnt
Copy the Kernel File vmlinuz and the root file system initrd. IMG to/tftpboot.
CP/mnt/images/pxeboot/vmlinuz/mnt/images/pxeboot/initrd. img/tftpboot
Create/tftpboot/pxelinux. cfg directory
Mkdir/tftpboot/pxelinux. cfg
Create/tftpboot/pxelinux. cfg/default file
Touch/tftpboot/pxelinux. cfg/Default
The file content is as follows:
Default Linux
Prompt 0
Label Linux
Kernel vmlinuz
Append Ks = NFS: 192.168.0.1:/netinstall/KS. cfg initrd = initrd. img
Configure NFS network installation
Copy the entire installation CD to/netinstall
Mkdir/netinstall
CP-r/mnt/*/netinstall
Install the NFS service and release/netinstall
Yum install-y nfs-utils
/Etc/init. d/Portmap start
/Etc/init. d/nfs start
Exportfs *:/netinstall
About the KS. cfg file
Configuration of this file is very troublesome, because there are too many parameters, interested, please refer to the official centos documentation: http://www.centos.org/docs/5/html/installation_guide-en-us/s1-kickstart2-options.html.
If you are not interested, you can keep working with me on the simplest ks. cfg.
Copy the KS file installed on the local machine to/netinstall and rename it ks. cfg
CP/root/anaconda-ks.cfg/netinstall/KS. cfg
Chmod A + R/netinstall/KS. cfg
Then, make a small modification,
Find the install on the first line and change it to text
The second line of CDROM is changed
NFS -- Server = 192.168.0.1 -- dir =/netinstall/
Find,
Clearpart -- Linux -- drives = SDA
Changed:
Clearpart -- all -- drives = SDA -- initlabel
And add a row on it:
Autopart
OK. Now, all the configurations are complete. Finally, you can directly test the firewall by disabling it.
Of course, there is a premise that centos 5.1 should recognize your Nic. Otherwise, the installation will prompt that you cannot find the KS file and fail.