CentOS7 Unattended Service Environment Construction (PXE + DHCP + TFTP + Kickstart + FTP)

One, build unattended server installation software ( PXE + DHCP + TFTP + Kickstart + FTP ) IP: 192.168.2.10

System version: CentOS Linux release 7.4.1708 (Core) 

Second, configure the local yum source and install the required software:

[root@xuegod-server yum.repos.d]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected and will be mounted read-only
[root@xuegod-server yum.repos.d]# vim-server.repo

[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///mnt/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

[root@xuegod-server yum.repos.d]# yum clean all

[root@xuegod-server yum.repos.d]# yum makecache

[root@xuegod-server yum.repos.d]# yum -y install vsftpd

[root@xuegod-server yum.repos.d]# systemctl start vsftpd
[root@xuegod-server yum.repos.d]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.

 [root@xuegod-server yum.repos.d]# yum -y install tftp tftp-server xinetd

Third, modify the configuration file

[root@xuegod-server yum.repos.d]# vim /etc/xinetd.d/tftp

# default: off
# description: The tftp server serves files using the trivial file transfer \
# protocol. The tftp protocol is often used to boot diskless \
# workstations, download configuration files to network-aware printers, \
# and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot     #修改
disable = no           #修改
per_source = 11
cps = 100 2
flags = IPv4
}


[root@xuegod-server yum.repos.d]# systemctl start xinetd.service
[root@xuegod-server yum.repos.d]# lsof -i :69
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
xinetd 47262 root 5u IPv4 94469 0t0 UDP *:tftp

Install dhcp, modify the configuration file and start the service

[root@xuegod-server yum.repos.d]# yum -y install dhcp

[root@xuegod-server yum.repos.d]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

[root@xuegod-server yum.repos.d]# > /etc/dhcp/dhcpd.conf #Empty the configuration file
[root@xuegod-server yum.repos.d]# vi /etc/dhcp/dhcpd.conf #Add the following

subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.100 192.168.2.200;
option domain-name-servers 192.168.2.1;
option domain-name "internal.example.org";
option routers 192.168.2.1;
option broadcast-address 192.168.2.255;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.2.10;    
filename "pxelinux.0";

}

 Fourth, configure the relevant files required to use PXE boot

[root@xuegod-server yum.repos.d]# Packages]# yum -y install system-config-kickstart  syslinux

Fifth, prepare the files that need to be shared by tftp

[root@xuegod-server yum.repos.d]# mkdir /tftpboot
[root@xuegod-server yum.repos.d]# mkdir /tftpboot/pxelinux.cfg
[root@xuegod-server yum.repos.d]# cp /usr/share/syslinux/pxelinux.0 /tftpboot/
[root@xuegod-server yum.repos.d]# cp /media/images/pxeboot/initrd.img /tftpboot/
[root@xuegod-server yum.repos.d]# cp /media/images/pxeboot/vmlinuz /tftpboot/
[root@xuegod-server yum.repos.d]# cp /media/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
[root@xuegod-server yum.repos.d]# chmod 644 /tftpboot/pxelinux.cfg/default

Sixth, modify the default, specify the method of installing the operating system and the path of the ks.cfg file (modify the first line and the 64th line and the others will not be changed)

1 default linux #Change the first line to this

64 append initrd=initrd.img inst.repo=ftp://192.168.2.10/pub inst.ks=ftp://192.168.2.10/ks.cfg #64 line is modified like this

Seven, configure the unattended package

[root@xuegod-server yum.repos.d]# pwd
/etc/yum.repos.d
[root@xuegod-server yum.repos.d]# vim server.repo

[development]       

name=my-centos7-dvd

baseurl = file: /// var/ftp/pub

enabled=1

gpgcheck=0

 [root@xuegod-server yum.repos.d]# yum makecache #Generate local yum cache

Eight, start the system-config-kickstart through xstart to pop up the interface, and set the parameters that need to be configured in the later unattended installation.

####################The last two options are not configured, ###################### #######

Nine, start the service,

[root@xuegod-server ~]# cd
[root@xuegod-server ~]# pwd
/root
[root@xuegod-server ~]# cp ks.cfg /var/ftp/
[root@xuegod-server ~]# systemctl restart vsftpd

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324939767&siteId=291194637