CentOS 6.4 PXE+Kickstart unattended installation operating system

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

One, introduction

1.1 what is the PXE

PXE(Pre-boot Execution Environment, Pre boot execution environment) is a new technology developed by Intel company, The network model in Client/Server, Support the workstation download images from a remote server through network, And thus support to start operating system through network, During startup, Terminal server IP address allocation, Then TFTP (trivial file transfer protocol) or MTFTP (multicast trivial file transfer protocol) to download a software startup protocol packets to the machine memory to be executed, From the start the software terminal basic software settings, Leading terminal operating system pre installed on the server.

Strictly speaking, PXE is not an installation, but a boot mode. A necessary condition for the PXE is installed on the computer you want to set must contain a PXE card (NIC), namely the card must have the PXE Client. The PXE protocol can make the computer through the network boot. This agreement is divided into Client and Server terminal, and the PXE Client in the network card in ROM. When the computer boot time, BIOS PXE Client into memory for execution, and then by the PXE Client will be placed at the distal end of the files are downloaded to the local running through network. Running the PXE protocol need to set the DHCP server and TFTP server. The DHCP server will give PXE Client (will install the system host) assign an IP address, the PXE Client is to assign IP addresses, so the need to increase the corresponding PXE settings in the configuration of DHCP server. In addition, in the PXE Client ROM, TFTP Client already exists, then it can be accessed through the TFTP protocol to the TFTP Server download the necessary files.

The process of PXE:

1 PXE Client boot from the PXE card of their own, from IP to the DHCP network server,

2 DHCP server returns are distributed to the clients IP and PXE file (the file position is placed on a TFTP server) ,

3 PXE Client to obtain the TFTP network server pxelinux.0 file,

4 PXE Client pxelinux.0 file of the file,

5 according to the results in the execution of the pxelinux.0, through the TFTP server to load the kernel and file system ,

6 enter the installation screen, at this time can be installed by selecting the HTTP, one of FTP, NFS,

The detailed work process, please refer to the diagram below:


1.2 what is the Kickstart

Kickstart is an unattended installation. Its working principle is to record the typical need manual intervention in various parameters in the process of installation, and generate a file named ks.cfg. If in the process of installation (not limited to generate the Kickstart installation files machine) appear to fill in the parameters, the installation program will first to find the files generated by Kickstart, if found suitable parameters, the parameters are found; if the appropriate parameters is not found, then need to install the manual intervention. So, if the Kickstart file contains all needed may appear during the installation of the complete parameter, so the installer can only tell the installer for ks.cfg files from where, then go to busy with their own things. Installed, the installer will restart the system according to the settings in ks.cfg, and finish the installation.

PXE+Kickstart unattended installation operating system integrity of the process are as follows:


Two, the system environment

The experimental environment: VMware Workstation 10

System platform: CentOS release 6.4 (minimum installation)

Network model: NAT mode (sharing host IP address)



The firewall has been closed/iptables: Firewall is not running.


Three, prepare to work

Generate the ks.cfg file to system-config-kickstart tool, but this tool is dependent on the X Windows, so we need to install the X Windows and Desktop and restart the system, the operation is as follows:

# yum groupinstall "X Window System"

# yum groupinstall Desktop

# reboot

Four, the configuration of HTTP installation

Installation system can choose HTTP, FTP, NFS, we introduce the HTTP setup, the other two ways of installation, you can Baidu.

4.1 installation and configuration of HTTP

# yum install httpd –y

# rpm -qa|grep httpd


Open the service and set the boot

# /etc/init.d/httpd start

# chkconfig --level 35 httpd on

4.2 to load the ISO image

Set the load the ISO image in the virtual machine.


ISO file will be hard to/mnt/cdrom.


The root directory /var/www/html/ 4.3 copy the entire contents of the disc to the HTTP.

# cp -r /mnt/cdrom//var/www/html/

HTTP set.

Five, the configuration of TFTP

Installing tftp-server 5.1

# yum install tftp-server –y

5.2 TFTP enabled services

# vi /etc/xinetd.d/tftp

service tftp 
        socket_type             = dgram 
        protocol                = udp 
        wait                    = yes 
        user                    = root 
        server                  = /usr/sbin/in.tftpd 
        server_args             = -s /var/lib/tftpboot 
        disable                 = no 
        per_source              = 11 
        cps                     = 100 2 
        flags                   = IPv4 

Setting disable to no

5.3 start the TFTP service

Because the TFTP service is mounted in the super process under xinetd, so by starting the xinetd to start the TFTP service.

# /etc/init.d/xinetd restart


Set boot xinetd

# chkconfig xinetd on

Six, configured to support PXE startup procedure

6.1 copy the pxelinux.0 file to the /var/lib/tftpboot/ folder

# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

Explain: Syslinux is the boot loader a powerful, but also compatible with the various media. More precisely: SYSLINUX is a small Linux operating system, its purpose is to simplify the installation of Linux first time, boot disk and the establishment of maintenance or other special purposes.

6.2 copies of /image/pxeboot/initrd.img and vmlinux to the /var/lib/tftpboot/ folder in the ISO image

# cp /var/www/html/cdrom/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/

6.3 copies of ISO image in /isolinux/*.msg to the /var/lib/tftpboot/ folder

# cp /var/www/html/cdrom/isolinux/*.msg /var/lib/tftpboot/

6.4 in the /var/lib/tftpboot/ in a new directory pxelinux.cfg

# mkdir /var/lib/tftpboot/pxelinux.cfg

6.5 the ISO image in the /isolinux directory of the isolinux.cfg copied to the pxelinux.cfg directory, and change the file name for the default

# cp /var/www/html/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

6.6 to modify the default file

# vi /var/lib/tftpboot/pxelinux.cfg/default

default ks     #Default is 'label ks' The markup in the boot kernel
prompt 1          #Display 'boot: ' Prompt. For the '0' When do not suggest, will be launched directly 'default' Parameters specified in the content. 
timeout 6      #In the user input before timeout, unit 1/10 seconds. 
display boot.msg  #Display a file's contents, pay attention to the path of the file. The default is the/var/lib/tftpboot/ Directory. Can also refer to a position similar to '/install/boot.msg'So, path+File name. 
F1 boot.msg     #Press 'F1' This button displays the file. 
F2 options.msg 
F3 general.msg 
F4 param.msg 
F5 rescue.msg 
label linux       #'label' The specified in your 'boot:' Prompt input keyword, such as boot: linux[ENTER], this will start'label linux' The next markerKernel andThe initrd.img file. 
  kernel vmlinuz  #The kernel parameter specifies the start the kernel. 
  append initrd=initrd.img #Append specifies additional to the kernel parameters, can be used in grub append to kernel parameters, here also can use. 
label text 
  kernel vmlinuz 
  append initrd=initrd.img text 
label ks 
  kernel vmlinuz 
  append ks= initrd=initrd.img    #Tell the system, get ks.cfg file where 
label local 
  localboot 1 
label memtest86 
  kernel memtest 
  append -

Seven, the configuration of DHCP

7.1 install the DHCP service

# yum -y install dhcp

7.2 replicate configuration template file to the DHCP configuration directory

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

7.3 modify the /etc/dhcp/dhcpd.conf configuration file, as follows:

ddns-update-style interim; 
ignore client-updates; 
filename "pxelinux.0";   #Pxelinux startup file location;
next-server;  #TFTP ServerIP address;

subnet netmask {

        option routers        ; 
        option subnet-mask    ;

        range dynamic-bootp; 
        default-lease-time 21600; 
        max-lease-time 43200;

7.4 start the DHCP service

# /etc/init.d/dhcpd start


Eight, to generate the ks.cfg file

Installing Kickstart 8.1

# yum install system-config-kickstart

8.2 in the desktop environment configuration Kickstart

Start the X Windows environment

# startx

The configuration of Kickstart

# system-config-kickstart

A. language settings, keyboard, time zone, Root password, after installation restart.


B. setup installation, this paper introduces the HTTP installation, the choice of HTTP

The installation of C. MBR


D. partitions


The E. partition.


The F. network configuration


G. authentication configuration


H. SELinux and firewall configuration


I. graphics environment configuration


J. software package installation options


K. Preview


The L. generated ks.cfg file, save it in the /var/www/html/ folder


We can open the /var/www/html/ks.cfg file to view and modify.

platform=x86, AMD64, or Intel EM64T 
# Firewall configuration 
firewall --disabled 
# Install OS instead of upgrade 
# Use network installation 
url --url=   #This option tells the installation: to server HTTP root directory under the CDROM folder for the installation media
# Root password 
rootpw --iscrypted $1$vsvtP./e$6PVMNfJd.shq2LgFJjYfA1 
# System authorization information 
auth  --useshadow  --enablemd5 
# Use graphical install 
firstboot --disable 
# System keyboard 
keyboard us 
# System language 
lang en_US 
# SELinux configuration 
selinux --disabled 
# Installation logging level 
logging --level=info 
# Reboot after installation 
# System timezone 
timezone  --isUtc Asia/Shanghai 
# Network information 
network  --bootproto=dhcp --device=eth0 --onboot=on 
# System bootloader configuration 
key --skip 
bootloader --append="rhgb quiet" --location=mbr --driveorder=sda 
# Clear the Master Boot Record 
# Partition clearing information 
clearpart --all --initlabel 
# Disk partitioning information 
part / --fstype="ext4" --size=8192 
part swap --fstype="swap" --size=1024 
part /home --fstype="ext4" --size=2048



Explain: Key --skip if it is a red hat, this option can skip the input sequence number; if it is CentOS series, can not keep this item,

Reboot this option must exist, must also be set in, or kickstart to display a message, and wait for the user to press any key to reboot,

Clearpart --all --initlabel this command must be added, otherwise the system will allow the user to manually select clear all data, this human intervention is needed, resulting in the automation process failed,

Nine, the test installation

Automatic installation of the system is configured, below to start a new machine for testing, the network connection mode selection in NAT mode.


The new virtual machine, select custom (Advanced)


Select "install later operating system"


Select a guest operating system type


Virtual machine name


Set up the virtual machine's memory


Set the network type


Select the I/O controller type


Select a disk type


Select the disk


The specified disk size, the ks.cfg file, we define / size is 8GB, the swap partition is 1GB, /home partition is 2GB, so the disk size should be at least 12GB.

Also, be sure to check the "immediately allocate all disk space", or at a later time when installed will prompt no disk space.


The specified disk file


The virtual machine.


Creating a disk, the process will be very slow, the virtual machine needs to generate a 20GB file.


Virtual machine start, select from the NIC boot, the DHCP server is to the client IP address allocation.


To download the vmlinuz and initrd.img


The installation process...


The installation process...


The installation process...


Installed, restart, display the login interface


Log on to the system view, the disk partition and we set in the ks.cfg file.


PXE+Kickstart unattended installation operating system environment.

Reference material

David Camp

    Share system maintenance technology: 296513821

We always believe, sharing is a virtue | We Believe, Great People Share Knowledge...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Elijah at August 16, 2014 - 5:10 AM