1.关闭防火墙
systemctl disable --now firewalld
setenforce 0
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sudo yum clean all
sudo yum makecache
2.安装http tftp dhcp服务
yum -y install httpd
yum -y install tftp-server
yum -y install dhcp
yum -y install xinetd
systemctl enable httpd tftp dhcp xinetd
3.创建tftp配置文件(此文件不存在 需手动创建)
vi /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
4.配置dhcp服务
vi /etc/dhcp/dhcpd.conf
ddns-update-style none;
filename "bootx64.efi";
next-server 10.0.17.100;
subnet 10.0.17.0 netmask 255.255.255.0 {
range 10.0.17.200 10.0.17.230;
option routers 10.0.17.2;
option domain-name-servers 114.114.114.114;
}
5.配置http服务
vi /etc/httpd/conf.d/welcome.conf
只留
<Directory /usr/share/httpd/noindex>
AllowOverride None
Require all granted
</Directory>
cp centos.iso/var/www/html/ubuntu.iso
mkdir /var/www/html/ubuntu
mount centos.iso /var/www/html/ubuntu
6.拷贝所需要的启动文件到/var/lib/tftpboot/
cp /var/www/html/centos/EFI/boot/grubx64.efi /var/lib/tftpboot/grubx64.efi
cp /var/www/html/centos/casper/initrd /var/lib/tftpboot/initrd
cp /var/www/html/centos/casper/vmlinuz /var/lib/tftpboot/vmlinuz
yum install grub2-efi-x64
yum install shim-x64
yum install grub2-efi-x64-modules
grub2-mkstandalone -d /usr/lib/grub/x86_64-efi/ -O x86_64-efi --modules="tftp net efinet linux part_gpt efifwsetup" -o /var/lib/tftpboot/bootx64.efi
chmod 777 /var/lib/tftpboot
7.编辑引导配置文件
vi /var/lib/tftpboot/grub.cfg
function load_video {
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod all_video
}
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2
set timeout=5
menuentry 'Install Centos 7' --class fedora --class gnu-linux --class gnu --class os {
set gfxpayload=keep
linuxefi (tftp)/vmlinuz ip=dhcp url=http://10.0.17.100/ubuntu-23.10-live-server-amd64.iso ks=http://10.0.17.100/ks.cfg
initrdefi (tftp)/initrd
}
8.Kickstart
yum install system-config-kickstart
vim /etc/yum.repo.d/development.repo
[development]
name=development
baseurl=file:///var/www/html/centos
gpgcheck=0
ks.cfg
#platform=86, AMD64, or Intel EM64T
#version=DEVEL
# System authorization information
auth --useshadow --passalgo=sha512
# Install OS instead of upgrade
install
# Use graphical install
graphical
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto=dhcp --device=ens33 --activate
network --hostname=localhost.localdomain
# Reboot after installation
reboot
# Use network installation
url --url="http://10.0.17.100/centos"
# Root password
rootpw --plaintext root
# SELinux configuration
selinux --enforcing
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai
user --name=noz --password=$6$R3b.LTR/NkobA1Sv$quYMCv3b6czowr6o6y9Yz53yg/DR9PSQxlUMJCD.GnbMewAPeFePAzL7pQQ4HEW.LdGjJw4OUnPCVWjg12UKV/ --iscrypted --gecos="noz"
# X Window System configuration information
xconfig --startxonboot
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part /boot/efi --fstype="efi" --ondisk=sda --size=200 --fsoptions="umask=0077,shortname=winnt"
part /boot --fstype="xfs" --ondisk=sda --size=1024
part pv.304 --fstype="lvmpv" --ondisk=sda --size=19254
volgroup centos --pesize=4096 pv.304
logvol swap --fstype="swap" --size=2047 --name=swap --vgname=centos
logvol / --fstype="xfs" --grow --maxsize=51200 --size=1024 --name=root --vgname=centos
%post
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
cat > /etc/yum.repos.d/CentOS-Base.repo << EOF
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
EOF
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/C* /etc/yum.repos.d/bak
cat> /etc/yum.repos.d/local.repo << EOF
[local]
name=Local Repository
baseurl=http://10.0.17.100/centos
enabled=1
gpgcheck=0
EOF
sudo yum clean all
sudo yum makecache
reboot
%end
%packages
@base
@core
@development
chrony
%end
%addon com_redhat_kdump --disable --reserve-mb='auto'
%end