Kickstart自動化安裝系統及定制安裝
[root@fitme ~]# cat /etc/redhat-release
- > ## CentOS Linux release 7.2.1511 (Core)
[root@fitme ~]# getenforce
Disabled
[root@fitme ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
2.安裝dhcp服務,編輯配置文件,並啟動
[root@fitme ~]# yum -y install dhcp
[root@fitme ~]# cat >>/etc/dhcp/dhcpd.conf<<EOF
subnet 172.16.1.0 netmask 255.255.255.0 {
range 172.16.1.101 172.16.1.199;
option subnet-mask 255.255.255.0;
default-lease-time 21600;
max-lease-time 43200;
next-server 172.16.1.100;filename "/pxelinux.0";
}
EOF
[root@fitme ~]# systemctl start dhcpd
dhcpd6.service dhcpd.service
[root@fitme ~]# systemctl status dhcpd
● dhcpd.service - DHCPv4 Server Daemon
Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2018-03-12 20:01:42 CST; 7s ago
udp 0 0 0.0.0.0:67 0.0.0.0:* 2501/dhcpd
3.安裝tftp服務,並啟動
[root@fitme ~]# yum -y install tftp-server
[root@fitme ~]# systemctl start tftp.socket
[root@fitme ~]# netstat -tulnp
udp6 0 0 :::69 :::* 1/systemd
4.安裝syslinux,復制pxelinux.0 到tftp根目錄
[root@fitme ~]# yum -y install syslinux
[root@fitme ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@fitme ~]# ls /var/lib/tftpboot/
pxelinux.0
[root@fitme ~]# mkdir -p /var/www/html/CentOS7
[root@fitme ~]# mount /dev/cdrom /var/www/html/CentOS7/ //掛載鏡像文件到http站點目錄
mount: /dev/sr0 is write-protected, mounting read-only
[root@fitme ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sr0 4.1G 4.1G 0 100% /var/www/html/CentOS7
[root@fitme ~]# cp -a /var/www/html/CentOS7/isolinux/* /var/lib/tftpboot/
[root@fitme ~]# mkdir -p /var/lib/tftpboot/pxelinux.cfg //默認找pxelinux.cfg目錄下的文件,不要更改,固定目錄
[root@fitme ~]# cp /var/www/html/CentOS7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@fitme ~]# tailf /var/log/messages
Mar 12 22:57:15 fitme dhcpd: DHCPACK on 172.16.1.101 to 00:0c:29:e9:99:40 via eth1
Mar 12 22:57:15 fitme in.tftpd[2898]: tftp: client does not accept options
Mar 12 22:57:15 fitme in.tftpd[2899]: Client ::ffff:172.16.1.101 finished /pxelinux.0
Mar 12 22:57:15 fitme in.tftpd[2910]: Client ::ffff:172.16.1.101 finished /pxelinux.cfg/default
Mar 12 22:57:15 fitme in.tftpd[2911]: Client ::ffff:172.16.1.101 finished /boot.msg
Mar 12 22:57:15 fitme in.tftpd[2913]: Client ::ffff:172.16.1.101 finished /vesamenu.c32
Mar 12 22:57:15 fitme in.tftpd[2914]: Client ::ffff:172.16.1.101 finished /pxelinux.cfg/default
Mar 12 22:57:15 fitme in.tftpd[2915]: Client ::ffff:172.16.1.101 finished /splash.png
5.安裝http服務,並啟動,修改default文件,安裝源為http源
[root@fitme ~]# yum -y install httpd
[root@fitme ~]# systemctl start httpd.service
[root@fitme ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
63 kernel vmlinuz
64 # append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207
\x20x86_64 quiet //註釋默認路徑
65 append initrd=initrd.img inst.repo=http://172.16.1.100/CentOS7/ //更改為tftp目錄
66
67
68 label check
=============================================
加密密碼生成:
python -c ‘import crypt; print(crypt.crypt("密碼"))‘
=============================================
6.編寫ks自動應答文件
vi /var/www/html/ks_config/CentOS7-ks.cfg
7.編寫修改啟動文件
vi /var/lib/tftpboot/pxelinux.cfg/default
default ks
prompt 0
label ks
kernel vmlinuz
append initrd=initrd.img ks=http://172.16.1.100/ks_config/CentOS7-ks.cfg net.ifnames=0 biosde
vname=0 ksdevice=eth1
8.開啟電源,自動安裝系統
kickstart配置多客戶端定制安裝系統
1.獲取客戶端MAC地址
2.修改ks文件wei定制文件,按需定制,本例定制ip及hostname
network --bootproto=static --device=eth0 --gateway=10.0.0.254 --ip=10.0.0.8 --nameserver=223.5
.5.5 --netmask=255.255.255.0 --activate
network --bootproto=static --device=eth1 --ip=172.16.1.8 --netmask=255.255.255.0 --activate
network --hostname=web02
說明:ks文件部分語句
3.cd /var/lib/tftpboot/pxelinux.cfg
cp cp default ./01-00-50-56-3e-b6-1c
vim 01-00-50-56-3e-b6-1c
default ks
prompt 0
label ks
kernel vmlinuz
append initrd=initrd.img ks=http://172.16.1.100/ks_config/CentOS7.1-ks.cfg net.ifnames=0 bios
devname=0 ksdevice=eth1
說明:更改ks文件為定制ks文件
以mac地址命名查找,mac應為小寫
kickstart完成為考試要求,推薦cobbler定制安裝
Kickstart自動化安裝系統及定制安裝