PXE unattended installation (automatic installation!)


Preface

Nowadays, there are more and more computers, and the installation has become troublesome. Today this article solves the installation problem! Multiple machines can be installed automatically.


One, placement

1. Network installation

Advantages of network installation
• Scale: assemble multiple hosts at the same time
• Automation: install systems and configure various services
• Remote realization: no need for physical installation media such as CDs or U disks

• What service components are needed?
-DHCP service, assign IP address, locate boot program
-TFTP service, provide boot program download
-HTTP service, provide yum installation source

2. Host configuration

1. Set ip 192.168.4.5
2. Configure yum source mount point to /dvd
3. Turn off firewall and selinux

2. Deploy the DHCP server

1. Principle

• Dynamic Host Configuration Protocol
- Dynamic Host Configuration Protocol , developed by the IETF (Internet Network Engineer Task Team) organization to simplify the management of host address allocation:

• Mainly allocate the following network access parameters
-IP address / subnet mask / broadcast address
-default gateway address, DNS server address

Principle: Broadcast, first come first served (only one DHCP in a network)
• Four sessions of DHCP address assignment
– DISCOVERY --> OFFER --> REQUEST -->ACK

• The basic concept of the server
-Lease period: the time period for the client to lease the IP address, in seconds
-Scope: the network segment of the IP address assigned to the client
-Address pool: the range of IP addresses used for dynamic allocation

2. Operation

1.装包dhcpd
2.修改配置文件/etc/dhcp/dhcpd.conf
subnet 192.168.4.0 netmask 255.255.255.0 {
    
    
  range 192.168.4.100 192.168.4.200;
  option domain-name-servers 192.168.4.5;
  option routers 192.168.4.254;
  default-lease-time 600;
  max-lease-time 7200;
  next-server 192.168.4.5;#指定下一个服务器地址
  filename "pxelinux.0";#指定网卡引导文件名称
}
3.重启dhcpd

Note: Read the configuration file for easy modification (no need to type by hand)
Insert picture description here

2. Deploy pxe

1. Principle

PXE network
• PXE, Pre-boot eXecution Environment
-pre-boot execution environment, running before the operating system
-can be used for remote installation

• Work mode
- PXE client integrated in the chip card in the start
- when the computer boots from the PXE client chip card into memory
to perform, get PXE server configuration, display the menu, the user choose
to download the program to the remote boot this Optional Machine running

• What the client should have
-the network card chip must support the PXE protocol
-the motherboard supports booting from the network card

1.装包tftp-server
2.部署pxelinux.0
# yum -y install syslinux-4.05-13.el7.x86_64
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ 
3.部署菜单文件
# mkdir /var/lib/tftpboot/pxelinux.cfg
# ls /var/lib/tftpboot/
# cp /dvd/isolinux/isolinux.cfg  /var/lib/tftpboot/pxelinux.cfg/default
4.部署图形模块(vesamenu.c32)与背景图片(splash.png)
# cp /dvd/isolinux/vesamenu.c32 /dvd/isolinux/splash.png  /var/lib/tftpboot/
5.部署启动内核(vmlinuz)与驱动程序(initrd.img)
# cp /dvd/isolinux/vmlinuz /dvd/isolinux/initrd.img /var/lib/tftpboot/
6.全部文件
# ls /var/lib/tftpboot/
initrd.img  pxelinux.cfg  vesamenu.c32
pxelinux.0  splash.png    vmlinuz
7.修改菜单文件
# vim /var/lib/tftpboot/pxelinux.cfg/default
1 default vesamenu.c32    #默认加载图形模块
2 timeout 600             #默认读秒时间 1/10
10 menu background splash.png       #背景图片
11 menu title NSD1905 PXE Server !  #标题显示
61 label linux
62 menu label Install CentOS 7.5   #菜单显示的内容  
63 menu  default                  #读秒结束后默认选择
64 kernel vmlinuz                  #加载启动内核
65 append initrd=initrd.img        #加载驱动程序

Restart the dhcpd service and tftp service

[root@svr7 ~]# systemctl restart tftp
[root@svr7 ~]# systemctl status tftp

[root@svr7 ~]# systemctl restart dhcpd
[root@svr7 ~]# systemctl status dhcpd

Three. Deploy http

1. Principle

Principle: Provide yum installation source

1.装包 httpd
2.
[root@svr7 ~]# mkdir /var/www/html/centos
[root@svr7 ~]# mount /dev/cdrom  /var/www/html/centos
mount: /dev/sr0 写保护,将以只读方式挂载
[root@svr7 ~]# systemctl restart httpd
[root@svr7 ~]# firefox 192.168.4.5/centos #验证是否成功

Fourth, deploy unattended installation, generate answer file

1.装包
system-config-kickstart 
2.配置yum源
[root@svr7 ~]# vim /etc/yum.repos.d/dvd.repo 
[development]
name=CentOS7.5
baseurl=ftp://192.168.4.5/centos
enabled=1
gpgcheck=0
3.开启
system-config-kickstart #点击 "软件包选择(Package Selection)" 查看是否可以进行选择
4.图形界面操作 (如下图)

Insert picture description here
Insert picture description here

Insert picture description here
Insert picture description here
Insert picture description here

Insert picture description here

Insert picture description here

Insert picture description here

Save the file to root
Insert picture description here

[root@svr7 ~]# cp /root/ks.cfg /var/www/html/
[root@svr7 ~]# ls /var/www/html/
centos  ks.cfg
修改菜单文件指定应答文件的位置:
[root@svr7 ~]# vim /var/lib/tftpboot/pxelinux.cfg/default 
label linux
menu label  Install CentOS 7.5
menu default
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.4.7/ks.cfg

Five, summary

1. New machine verification

Insert picture description here

2. All steps

1.dhcp—>IP address next-server filename
2.tftp—>pxelinux.0
3.pxelinux.0—>Menu file default
4.default—>Graphics module background image kernel driver ks.cfg
5.ks.cfg— > …Partition package selection
–url=“http://192.168.4.5/centos”


to sum up

This article mainly introduces the unattended installation of pxe, hope it will be helpful to everyone!

Guess you like

Origin blog.csdn.net/weixin_46791581/article/details/108705555