Use TFTP,DHCP to build a batch installation Linux system server with PXE
System environment
Lab Environment: VMware Workstation 10
System platform: CentOS release 6.4 (minimized installation)
Network mode: NAT mode (IP address of shared host)
Firewall is shutting down service iptables stop
Selinux=disabled
The System-config-kickstart tool is required to generate the Ks.cfg file, and this tool relies on X windows, so we need to install X Windows and desktop and restart the system, as follows:
# yum groupinstall "X Window System"# yum groupinstall Desktop# reboot
Configuring HTTP Installation Methods
The installation of the system can choose HTTP, FTP, NFS, we are here to introduce the installation of HTTP, the other two ways to install, we can self-Baidu.
4.1 Installing and Configuring HTTP
Turn on the service and set the boot up
# /etc/init.d/httpd start# chkconfig --level 35 httpd on
Mount the ISO file to/mnt/cdrom.
Copy the entire contents of the disc to the root directory of HTTP/var/www/html/
# cp -r /mnt/cdrom/ /var/www/html/
The HTTP section is set up.
Configuring TFTP
Installing Tftp-server
# yum install tftp-server –y
Enable TFTP service
# vi /etc/xinetd.d/tftp
Set Disable to No
Start the TFTP service
Because the TFTP service is mounted under the hyper-process xinetd, the TFTP service is started by starting xinetd.
# /etc/init.d/xinetd restart
Set Boot xinetd
# chkconfig xinetd on
Configuring PXE-enabled boot programs
Copy the pxelinux.0 file to the/var/lib/tftpboot/folder
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
Copy the/image/pxeboot/initrd.img and vmlinux in the ISO image to the/var/lib/tftpboot/folder
# cp /var/www/html/cdrom/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/
Copy the/isolinux/*.msg to/var/lib/tftpboot/folder in the ISO image
# cp /var/www/html/cdrom/isolinux/*.msg /var/lib/tftpboot/
Create a new pxelinux.cfg directory in/var/lib/tftpboot/
# mkdir /var/lib/tftpboot/pxelinux.cfg
Copy the isolinux.cfg from the/isolinux directory in the ISO image to the Pxelinux.cfg directory, and change the file name to be called the default
# cp /var/www/html/cdrom/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
Modify the default file
# vi /var/lib/tftpboot/pxelinux.cfg/default
Configure DHCP
Installing the DHCP service
# yum -y install dhcp
Copy the configuration template file into the DHCP configuration directory
# cp -f /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
Modify the/etc/dhcp/dhcpd.conf configuration file with the following content:
Copy Code
Ddns-update-style Interim; Ignore client-updates;
FileName "pxelinux.0"; #pxelinux startup file location;
Next-server 192.168.111.130; The IP address of the #TFTP Server;
Subnet 192.168.111.0 netmask 255.255.255.0
{Range DYNAMIC-BOOTP 192.168.111.100 192.168.111.200;
Default-lease-time 21600;
Max-lease-time 43200; }
Copy Code
Start the DHCP service
# /etc/init.d/dhcpd start
Generate Ks.cfg File
Installing Kickstart
# yum install system-config-kickstar
Configuring Kickstart in a desktop environment
Start the X Windows environment
# startx
Configure Kickstart
# system-config-kickstart
A. Set language, keyboard, time zone, root password, reboot after installation.
B. Set the installation method, this article describes the installation of HTTP mode, so select the HTTP
C. Installing the MBR
D. Setting Up partitions
E. Overview of partitions
F. Configuring the Network
G. Authentication configuration
H. SELinux and firewall configuration
I. Graphical Environment configuration
J. Package Installation Options
K. Preview
L. Generate the Ks.cfg file, save it in the/var/www/html/folder
Test installation
The automatic installation system is complete, the following starts a new machine to test, network connection mode select NAT mode.
New virtual machine, select Custom (Advanced)
Select "Install operating system later"
Select the client operating system type
Name a virtual machine
Set the memory for this virtual machine
Set the network type
Select I/O Controller type
Select disk Type
Select disk
Specify the size of the disk, in the Ks.cfg file, we define a/size of 8gb,swap partition for the 1gb,/home partition to 2GB, so the disk size here must be at least 12GB.
Also, be sure to tick "allocate all disk space now", or you will be prompted for no disk space when you install it later.
Specify disk files
Virtual Machine Overview
The disk is being created and the process is slow and the virtual machine needs to produce a 20GB file.
Start the virtual machine, select start from the network card, and the DHCP server is assigning an IP address to the client.
Start Download Vmlinuz and initrd.img
Installation process ...
Installation process ...
Installation process ...
After the installation is complete, the login screen is displayed after rebooting.
Log in to the system to see that the disk partition is the same as the one we set in the Ks.cfg file.
Pxe+kickstart unattended installation of operating system environment.
Pxe+kickstart Unattended installation of CentOS