[root@zhu /]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled ##将这个配置改成disabled,来关闭核心防护
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@zhu /]# systemctl stop firewalld.service 关闭防火墙
[root@zhu /]# mount /dev/cdrom /mnt ##挂载光盘镜像
[root@zhu /]# vi /etc/fstab ##进入存放的是系统中的文件系统信息来配置永久挂载,使用"shift+G"跳转最后一行,"o"在下一行插入
# /etc/fstab
# Created by anaconda on Mon Aug 3 13:49:00 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=f797ffdf-39ae-4002-8ad1-df149d3734ae /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/sr0 /mnt iso9660 defaults 0 0 ##光盘镜像永久挂载
~
iso9660是一个CDROM的文件系统,可以允许你在设备上读取CDROM中的文件。
[root@zhu ~]# cd /etc/yum.repos.d/ ##进入yum配置目录
[root@zhu yum.repos.d]# mkdir backup ##配置备份目录(防止自行配置的yum源产生问题,可以用备份文件来自救)
[root@zhu yum.repos.d]# mv C* backup ##移动所有的文件到备份目录下
[root@zhu yum.repos.d]# cp backup/CentOS-Base.repo local.repo ##导出配置文件
[root@zhu yum.repos.d]# ll
总用量 4
drwxr-xr-x. 2 root root 187 8月 3 14:50 backup
-rw-r--r--. 1 root root 1664 8月 3 14:50 local.repo
[root@KCG yum.repos.d]# vi local.repo
[centos]
name=CentOS
baseurl=file:///mnt ##这个文件源就是你挂载的镜像文件
gpgcheck=0
enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
[root@zhu yum.repos.d]# yum clean all
已加载插件:fastestmirror, langpacks
正在清理软件源: base centos extras updates
Cleaning up list of fastest mirrors
[root@zhu yum.repos.d]# yum makecache
已加载插件:fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.njupt.edu.cn
* extras: mirrors.njupt.edu.cn
* updates: mirrors.njupt.edu.cn
base | 3.6 kB 00:00:00
centos | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/14): base/7/x86_64/filelists_db | 7.1 MB 00:00:04
......(加载过程省略)
元数据缓存已建立
[root@zhu /]# yum list ##列出所有可用的安装包
[root@zhu ~]# mkdir -p /var/ftp/centos7
[root@zhu ~]# mount /dev/cdrom /mnt
[root@zhu ~]# cp -rf /mnt/* /var/ftp/centos7
[root@zhu ~]# yum -y install vsftpd
[root@zhu ~]# systemctl start vsftpd
[root@zhu ~]# systemctl enable vsftpd
[root@zhu ~]# yum -y install tftp-server
[root@zhu ~]# vi /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 /var/lib/tftpboot
disable = no ##把“yes”改成“no”
per_source = 11
cps = 100 2
flags = IPv4
} ##将disable = yes改成no
[root@zhu ~]# systemctl start tftp
[root@zhu ~]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
[root@zhu ~]# cd /mnt/images/pxeboot/
[root@zhu pxeboot]# ll
总用量 57838
-rw-r--r-- 1 root root 52584760 11月 26 2018 initrd.img
-r--r--r-- 1 root root 441 11月 26 2018 TRANS.TBL
-rwxr-xr-x 1 root root 6639904 11月 9 2018 vmlinuz
[root@zhu pxeboot]# cp imginitrd.img vmlinuz /var/lib/tftpboot/ ##复制vmlinuz和initrd.imginitrd.img到
[root@zhu pxeboot]# yum -y install syslinux
[root@zhu syslinux]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@zhu /]# yum -y install dhcp
[root@zhu /]# vi /etc/dhcp/dhcpd.conf
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
subnet 20.0.0.0 netmask 255.255.255.0 {
option routers 20.0.0.20;
option subnet-mask 255.255.255.0;
option domain-name "bdqn.com";
option domain-name-servers 8.8.8.8;
default-lease-time 21600;
max-lease-time 43200;
range 20.0.0.100 20.0.0.200;1
next-server 20.0.0.20; ##指定的TFTP服务器的地址
filename "pxelinux.0"; ##指定PXE引导程序的文件名
}#
[root@zhu /]# systemctl restart dhcpd ##重启dhcp
[root@zhu /]# systemctl enable dhcpd ##开机启动dhcp
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.
[root@zhu /]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@zhu /]# vi /var/lib/tftpboot/pxelinux.cfg/default
default auto
prompt 1
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://20.0.0.20/centos7 ks=ftp://20.0.0.20/ks.cfg ##设置镜像地址设置无人值守配置
[root@zhu ~]# yum -y install system-config-kickstart ##安装Kickstart工具
基本配置:
默认语言:简体中文
键盘:U.S. English
时区:Asia/shanghai
安装方法:
安装方法:勾选√:执行全新安装
安装方法:勾选√:FTP:20.0.0.20
目录:centos7
安装类型:
勾选√:安装新引导装载程序
分区信息:根据自己的需求配置分区信息
网络配置:添加网络设备:
网络设备:ens33(默认网卡)
网络类型:DHCP
防火墙配置:SELinux(Linux核心防护):禁用
安全级别:禁用防火墙 ##根据自身的需求进行配置
预安装脚本: ##配置yum源包
勾选√:使用解释程序:/bin/bash
rm -rf /etc/yum.repos.d/*
echo -e '[base]
name=CentOS7.6
baseurl=ftp://20.0.0.20/centos7
enabled=1
gpgcheck=0
最后保存配置:文件-保存。保存在/root目录下,/root/ks.cfg
[root@zhu ~]# cp /root/ks.cfg /var/ftp/ks.cfg
[root@zhu ~]# vi /var/ftp/ks.cfg
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --plaintext Abc123
# Use network installation
url --url="ftp://20.0.0.20/centos"
# System language
lang zh_CN
.......省略
##插入安装包格式
%packages
@^minimal ##最小化安装包
%end
该过程无需我们进行任何配置,会自动开始最小化安装。