I. Introduction
1.1 What is PXE
PXE (pre-boot execution environment, pre-start execution environment) is the latest technology developed by Intel, working in the Network Mode of Client/Server, the workstation can download images from remote servers over the network and start the operating system over the network. During the startup process, the terminal requires the server to allocate an IP address and use TFTP (Trivial File Transfer Protocol) or the mtftp (Multicast Trivial File Transfer Protocol) protocol downloads a startup package to the local memory for execution. The startup package completes the basic software settings of the terminal, in this way, the operating system of the terminal that is pre-installed on the server is guided.
Strictly speaking, PXE is not an installation method, but a boot method. A prerequisite for PXE installation is that the computer to be installed must contain a NIC supported by PXE, that is, a PXE client must be included in the NIC. The PXE protocol enables the computer to start over the network. This Protocol is divided into client and server, while PXE client is in the ROM of the NIC. During computer boot, the BIOS transfers the PXE client to the memory for execution, and then the PXE client downloads the files stored in the remote end to the local computer for running through the network. To run the PXE protocol, you must set the DHCP server and TFTP server. The DHCP server assigns an IP address to the PXE client (the host on which the system is to be installed). Because the IP address is assigned to the PXE client, you need to add relevant PXE settings when configuring the DHCP server. In addition, TFTP client already exists in the PXE client Rom, so it can download the required files to the TFTP server through the TFTP protocol.
PXE process:
1. the PXE client starts from its PXE Nic and requests an IP address from the DHCP server in the network;
2. the DHCP server returns the IP address assigned to the client and the location of the PXE file (this file is usually placed on a TFTP server );
3. the PXE client requests the pxelinux.0 file from the TFTP server in the network;
4. the PXE client executes this file after obtaining the pxelinux.0 file;
5. Based on the execution result of pxelinux.0, load the kernel and file system through the TFTP server;
6. Go to the installation screen and select one of the HTTP, FTP, and NFS installation methods;
For detailed workflow, see the figure below:
1.2 What is kickstart
Kickstart is an unattended installation method. It works by recording typical parameters that require manual intervention during installation and generating a file named KS. cfg. If a parameter is required during the installation process (not limited to the machine that generates the Kickstart Installation File), the installer first searches for the file generated by KickStart. If a proper parameter is found, the parameter is used. If no proper parameter is found, manual intervention is required by the installer. Therefore, if the Kickstart file contains all the parameters that may occur during the installation process, the installer can only tell the installer where to obtain Ks. cfg file. After the installation is complete, the installation program restarts the system according to the settings in KS. cfg and ends the installation.
PXE + kickstart the complete process of unattended operating system installation is as follows:
Ii. System Environment
Lab environment:VMware Workstation 10
System Platform:Centos release 6.4 (minimal installation)
Network Mode:Nat mode (IP address of the shared host)
DHCP/tftp ip: 192.168.111.130
HTTP/FTP/nfs IP: 192.168.111.130
Firewall disabled/iptables: Firewall is not running.
SELinux = disabled
Iii. Preparations
The System-config-kickstart tool is required to generate the KS. cfg file, which depends on X Windows. Therefore, we need to install X Windows and desktop and restart the system as follows:
# Yum groupinstall "X Window System"
# Yum groupinstall Desktop
# Reboot
Iv. Configure the HTTP Installation Method
You can select HTTP, FTP, and NFS as the system installation method. Here we will introduce how to install HTTP. For other two installation methods, you can use Baidu.
4.1 install and configure HTTP
# Yum install httpd-y
# Rpm-Qa | grep httpd
Enable service and set startup
#/Etc/init. d/httpd start
# Chkconfig -- level 35 httpd on
4.2 load an ISO Image
Attach an ISO image to a VM.
Mount the ISO file to/mnt/CDROM.
4.3 copy all content of the CD to the HTTP root directory/var/www/html/
# Cp-R/mnt/CDROM // var/www/html/
HTTP is configured.
5. Configure TFTP
5.1 install TFTP-Server
# Yum install TFTP-server-y
5.2 enable the TFTP service
# 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 }
Set disable to no
5.3 Start the TFTP service
Because the TFTP service is mounted to the super process Xinetd, you can start the TFTP service by starting xinetd.
#/Etc/init. d/xinetd restart
Set start xinetd
# Chkconfig xinetd on
6. Configure boot programs that support PXE
6.1 copy the pxelinux.0 file to the/var/lib/tftpboot/folder.
# Cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot/
Note:Syslinux is a powerful boot loader and compatible with various media. More specifically, syslinux is a small Linux operating system designed to simplify the first Linux installation and create boot disks for repair or other special purposes.
6.2 copy/image/pxeboot/initrd. IMG and vmlinux from the ISO image to the/var/lib/tftpboot/folder.
# Cp/var/www/html/CDROM/images/pxeboot/{initrd. IMG, vmlinuz}/var/lib/tftpboot/
6.3 copy/isolinux/*. MSG from the ISO image to the/var/lib/tftpboot/folder.
# Cp/var/www/html/CDROM/isolinux/*. MSG/var/lib/tftpboot/
6.4 create a new pxelinux. cfg directory in/var/lib/tftpboot /.
# Mkdir/var/lib/tftpboot/pxelinux. cfg
6.5 copy isolinux. cfg from the/isolinux directory in the ISO image to the pxelinux. cfg directory, and change the file name to default
# Cp/var/www/html/CDROM/isolinux. cfg/var/lib/tftpboot/pxelinux. cfg/Default
6.6 modify the default file
# Vi/var/lib/tftpboot/pxelinux. cfg/Default
Default KS # by default, the start kernel prompt 1 marked in 'label ks' is started. # The 'boot: 'prompt is displayed. If it is set to '0', no prompt is displayed. The content specified in the 'default' parameter is directly started. Timeout 6 # Time-out period before user input, measured in 1/10 seconds. Display boot. MSG # displays the content of a file. Pay attention to the file path. The default value is in the/var/lib/tftpboot/directory. You can also locate the path + file name similar to '/install/boot. MSG. F1 boot. MSG # The file displayed after pressing a key such as 'f1. F2 options. MSG F3 general. MSG F4 Param. MSG F5 rescue. MSG label Linux # 'label' specifies the keyword you enter at the 'boot: 'prompt, for example, boot: Linux [enter], this will start the kernel and initrd marked under 'label Linux. IMG file. The kernel vmlinuz # Kernel Parameter specifies the kernel to be started. Append initrd = initrd. IMG # append specifies the parameters appended to the kernel, which can be used in grub to append to the kernel. Label text kernel vmlinuz append initrd = initrd. IMG text label KS kernel vmlinuz append Ks = http: // 192.168.111.130/KS. CFG initrd = initrd. IMG # Tell the system where to obtain Ks. cfg file label local localboot 1 label memtest86 kernel memtest append-
VII. Configure DHCP
7.1 install the DHCP service
# Yum-y install DHCP
7.2 copy the 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 configuration file/etc/DHCP/DHCPD. conf as follows:
Ddns-Update-style interim; ignore client-updates; FILENAME "pxelinux.0"; # position of the pxelinux Startup File; next-server 192.168.111.130; # IP address of the TFTP server; subnet 192.168.111.0 netmask 255.255.255.0 {Option routers 192.168.111.130; Option subnet-mask 255.255.255.0; range dynamic-BOOTP 192.168.111.100 192.168.111.200; default-lease-time 21600; max-lease-time 43200 ;}
7.4 start the DHCP service
#/Etc/init. d/DHCPD start
8. Generate the KS. cfg file
8.1 install kickstart
# Yum install system-config-kickstart
8.2 configure kickstart In the desktop environment
Start X Windows
# Startx
Configure kickstart
# System-config-kickstart
A. Set language, keyboard, time zone, root password, and restart after installation.
B. Set the installation method. This article describes how to install HTTP.
C. Install MBR
D. Set partitions.
E. Partition Overview
F. Configure the network
G. Authentication Configuration
H. SELinux and firewall configuration
I. graphical environment Configuration
J. package installation Selection
K. Preview
L. Generate the KS. cfg file and save it in the/var/www/html/folder.
You can open the/var/www/html/KS. cfg file to view and modify the file.
Platform = x86, amd64, or Intel em64t # version = devel # firewall configuration firewall -- disabled # Install OS instead of upgrade install # Use network installation URL -- url = http: // 192.168.111.130/CDROM/# This option tells the installer to find the installation medium in the CDROM folder under the HTTP root directory of the server 192.168.111.130 # Root Password rootpw -- iscrypted $1 $ vsvtp. /e $ 6pvmnfjd. shq2lgfjjyfa1 # system authorization information auth -- useshadow -- enablemd5 # use graphical install graphical firstboot -- disable # system keyboard us # System Language Lang en_us # SELinux configuration SELinux -- disabled # installation logging level logging -- level = info # reboot after installation reboot # system 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 zerombr # 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% packages @ base % end
Note:Key -- Skip if it is a red hat system, this option can skip the process of entering the serial number; if it is a centos series, it can not be retained;
Reboot: This option must exist or be set in the text. Otherwise, kickstart displays a message and waits for the user to press any key to reboot;
The clearpart -- all -- initlabel command must be added. Otherwise, the system will ask the user to manually select whether to clear all the data. This requires human intervention, leading to automated process failure;
IX. test and install
After the automatic installation system is configured, start a new machine for testing and select Nat for network connection mode.
Create a VM and select Custom (advanced)
Select "Install the operating system later"
Select the client operating system type
Name a virtual machine
Set the memory of this virtual machine
Set network type
Select the I/O controller type
Select Disk Type
Select Disk
Disk size, KS. in the cfg file, the/size is 8 GB, the swap partition is 1 GB, And the/home partition is 2 GB. Therefore, the disk size here must be at least 12 GB.
In addition, you must check "allocate all disk space now". Otherwise, no disk space will be displayed during subsequent installation.
Disk File
Virtual Machine Overview
Creating a disk is slow. The VM needs to generate a 20 GB file.
Start the VM and select start from the NIC. the DHCP server is allocating an IP address to the client.
Start downloading vmlinuz and initrd. img
Installation process...
Installation process...
Installation process...
After the installation is complete, the logon page is displayed.
Log on to the system and check the disk partition as we set in the KS. cfg file.
The operating system environment for unattended installation of PXE + kickstart is complete.
References
- Fuqin wine: http://yuhongchun.blog.51cto.com/1604432/1100567
David camp
- For technical exchange, add the QQ group:
System O & M Technology: 296513821
- For business cooperation, contact the author QQ: 562866602
- My ID: mchina_tang
- Write to me: [email protected]
- My address: Suzhou, Jiangsu Province
We always believe that sharing is a virtue |We believe, great people share knowledge...