PXE Function: Guide Installation
Kickstart function: Write the process of installing the system into ks.cfg file to realize unattended automatic installation
TFTP: PXE Client downloads pxelinux.0 file (first downloaded), vmlinuz, initrd.img from server side
DHCP: Get the IP address during PXE boot. DHCP is used twice, the first time when TFTP is used to transfer files, the second time when HTTP is used to transfer files.
HTTP: Used to download ks.cfg and mirror files
Dead work:
1. Close the firewall (this is more violent==, I suggest writing iptables)
2. Close selinux
3. Prepare the system image file and mount it
4. Server planning:
TFTP / DHCP / HTTP IP: 10.1.1.69
That is, all services are located on the same server (if more servers need to be installed, pay attention to the dismantling of these services, in order to reduce the pressure of network transmission, especially for remote IDC installation, VPN simply can not bear the speed)
1. Install HTTP service and put relevant files into httpd root directory
1.1 Installation of Web Services
#yum install httpd -y
Note: If there are http services such as Nginx, they can be used directly, but the main related files must be placed in the root directory of Nginx.
1.2 Mount the mirror file in the root directory of the httpd service
#mount -o loop xxx.iso /var/www/html/iso
#Sometimes there are many versions, you can change the directory name to name the version.
#mv /var/www/html/iso /var/www/html/centos6.6
1.3 Generate ks.cfg file and place it in / var/www/html / directory
Specific generation is not explained here, in fact, it is to use kicstart tool to simulate the steps of a system installation.==
The generated files are as follows.
cat /var/www/html/ks.cfg
# Kickstart file automatically generated by anaconda.
#mody 20140311
#version=DEVEL
install
#cdrom
url --url http://10.1.1.69/centos6.6
lang en_US.UTF-8
keyboard us
rootpw --iscrypted $6$Ldc0ppq9soXeP34h$/2Z9DVOUPzEh4gcFMPkd/gf3.Is6rlKfgBht0oQs5tjHN8DL.hp18gftjoNzGZ6SQ69hJYw7zkX24ryMXll0E/
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda,sdb,sdc
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
#clearpart --none
clearpart --all --initlabel --drives=sda
zerombr
part / --fstype=ext4 --size=70000 --ondisk=sda
part swap --size=20480 --ondisk=sda
part /usr/local --fstype ext4 --size=1 --grow --ondisk=sda
reboot
#repo --name="CentOS" --baseurl=cdrom:sr0 --cost=100
%packages
@additional-devel
@base
@chinese-support
@compat-libraries
@console-internet
@core
@debugging
@development
@directory-client
@hardware-monitoring
@large-systems
@legacy-unix
@network-file-system-client
@performance
@perl-runtime
@server-platform
@server-platform-devel
@server-policy
@system-management
@system-admin-tools
@workstation-policy
libgcrypt-devel
libXinerama-devel
xorg-x11-proto-devel
startup-notification-devel
libgnomeui-devel
libbonobo-devel
libXau-devel
libXrandr-devel
popt-devel
libxslt-devel
libglade2-devel
gnutls-devel
mtools
pax
oddjob
sgpio
device-mapper-persistent-data
systemtap-client
jpackage-utils
samba-winbind
certmonger
pam_krb5
krb5-workstation
tcp_wrappers
perl-DBD-SQLite
ipmitool
OpenIPMI
screen
tree
lsscsi
%end
Note: / var/www/html/directory file permissions should be 755, otherwise it can not be downloaded, there will be the following error:
[root@minion ~]# wget http://10.1.1.69/yantao
--2017-02-21 05:09:24-- http://10.1.1.69 /yantao
Connecting to 10.1.1.69 :80... failed: Connection refused.
You can download it only after you modify the permissions.
II. Installation and Configuration of TFTP Services
2.1 Installation and Configuration
#yum install tftp-server -y
#vim /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot/ -c
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
#mkdir /tftpboot/
#/etc/init.d/xinetd restart
#netstat -anutp | grep ":69"
udp 0 0 0.0.0.0:69 0.0.0.0:* 3551/xinetd
At this time, TFTP has been installed, in order to verify whether TFTP is installed successfully, the following tests can be done:
Server (10.1.1.69)
#touch /tftpboot/testfile
Client (10.1.1.101)
#yum install tftp -y
#tftp 10.1.1.69
tftp>get yantao
tftp>
The get file returns to normal, indicating that the server-side TFTP has been successfully configured.
Note: When I get /tftpboot/yantao, I always prompt "Error code 1: File not found" error because I use full path, which is not needed here, and / tftpboot itself is the root directory.
2.2 Put the files needed during PXE boot into the root directory of TFTP and configure default files
PXE boot required files: pxelinux.0, initrd.img, vmlinuz, boot.msg. In addition, isolinux.cfg corresponds to default file, as follows:
(1) Copy pxelinux.0 into / tftpboot
#cp /usr/share/syslinux/pxelinux.0 /tftpboot
Note: Some machines do not have syslinux / this directory, so there is no pxelinux.0 file. The solution is to install the syslinux tool:
#yum install syslinux -y
(2) Mount the image and copy the relevant files into the / tftpboot directory
#cp /var/www/html/centos6.6/images/pxeboot/{initrd.img,vmlinuz} /tftpboot/
#cp /var/www/html/centos6.6/isolinux/*.msg /tftpboot
#mkdir /tftpboot/pxelinux.cfg
#cp /var/www/html/centos6.6/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
Configuration default file
#cat /tftpboot/pxelinux.cfg/default
default ks
prompt 1
timeout 600
display /tftpboot/boot.msg
menu title Welcome to CentOS 6.6!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000
label linux
kernel vmlinuz
append initrd=initrd.img
label text
kernel vmlinuz
label ks
kernel vmlinuz
append initrd=initrd.img ks=http://10.1.1.69/ks.cfg ksdevice=em1
label yantao
kernel vmlinuz
append ks=http://10.1.1.69:80/ks.cfg ksdevice=em1 ip=10.1.1.3 netmask=255.255.255.0 initrd=initrd.img
label memtest86
kernel memtest
append -
Note:
- label name. This file begins with default ks, which means that PXE defaults to use the configuration under KS label; but sometimes we need to enter label manually, so the label name after default can be arbitrarily written a non-existent one, which adds a layer of security measures to avoid the tragedy of restarting other servers when an IDC is installed.
- ** ks.cfg path. ** ks.cfg is located under the root directory of the HTTP service, such as the file path here: / var/www/html/ks.cfg. The default file is represented as follows:
ks=http://10.1.1.69/ks.cfg
- You can configure IP address, subnet mask and so on in default file. This IP will remain after the system is installed. As follows:
ip=10.1.1.3 netmask=255.255.255.0
Then the overall structure of the final / tftp directory is as follows:
[root@localhost tftpboot]# pwd
/tftpboot
[root@localhost tftpboot]# tree
.
├── boot.msg
├── initrd.img
├── pxelinux.0
├── pxelinux.cfg
│ └── default
└── vmlinuz
Installation and configuration of DHCP services
3.1 installation
#yum -y install dhcp
3.2 DHCP Profile: / etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
ddns-update-style interim;
allow booting;
allow bootp;
next-server 10.1.1.69;
filename "pxelinux.0";
ignore client-updates;
set vendorclass = option vendor-class-identifier;
option pxe-system-type code 93 = unsigned integer 16;
subnet 10.1.1.0 netmask 255.255.255.0 {
option routers 10.1.1.69;
option subnet-mask 255.255.255.0;
range dynamic-bootp 10.1.1.1 10.1.1.254;
default-lease-time 21600;
max-lease-time 43200;
}
# group for Cobbler DHCP tag: default
group {
}
Focus: filename "pxelinux.0"; this statement is required, which means that the PXE boot function is turned on in DHCP.
Now you can install it automatically. Set boot to PXE boot directly when installing.