本方案规划如下:
两台服务器实现无人值守安装
192.168.254.153 安装DHCP服务、TFTP服务
192.168.254.154 安装nfs服务
安装环境:VMware Workstation
虚拟机的网络连接都是nat模式
环境配置好后,创建好相应配置的虚拟机,不要给虚拟机配置使用镜像,直接开机就好了,注意创建虚拟机时的操作系统版本,选其他 Linux 5.x 内核64位即可。
关闭selinux和防火墙
yum -y install dhcp
cp dhcpd.conf dhcpd.conf.bak
vim /etc/dhcp/dhcpd.conf
subnet 192.168.254.0 netmask 255.255.255.0 { #指定了分配的网段
range 192.168.254.160 192.168.254.199; #真实给到客户端的具体地址范围
option domain-name-servers 192.168.254.153; #dns服务器就是自己
option routers 192.168.254.2; #给到用户的网关
default-lease-time 600; #默认的等待时长
max-lease-time 7200; #最大的等待时长
next-server 192.168.254.153; #这里指定tftp的服务器地址
filename "pxelinux.0"; #Linux启动文件名
}
systemctl start dhcpd
systemctl enable dhcpd
yum -y install tftp-server
vim /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
}
yum -y install syslinux
cp -a /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
mount /dev/cdrom /media/
cp /media/isolinux/* /media/isolinux/initrd.img /var/lib/tftpboot/
mkdir -p /var/lib/tftpboot/pxelinux.cfg
cp /media/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
chmod 644 /var/lib/tftpboot/pxelinux.cfg/default
vim /var/lib/tftpboot/pxelinux.cfg/default
default vesamenu.c32
timeout 600
display boot.msg
# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title openEuler 22.03-LTS
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13
# Border Area
menu color border * #00000000 #00000000 none
# Selected item
menu color sel 0 #ffffffff #00000000 none
# Title bar
menu color title 0 #ff7ba3d0 #00000000 none
# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none
# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none
# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none
# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none
# Help text
menu color help 0 #ffffffff #00000000 none
# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none
# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none
# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none
# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.
menu tabmsg Press Tab for full configuration options on menu items.
menu separator # insert an empty line
menu separator # insert an empty line
label linux
menu label ^Install openEuler 22.03-LTS
kernel vmlinuz
menu default
append initrd=initrd.img ks=nfs:192.168.254.154:/ks/ks.cfg
timeout 60
label check
menu label Test this ^media & install openEuler 22.03-LTS
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=openEuler-22.03-LTS-x86_64 rd.live.check quiet
menu separator # insert an empty line
# utilities submenu
menu begin ^Troubleshooting
menu title Troubleshooting
label vesa
menu indent count 5
menu label Install openEuler 22.03-LTS in ^basic graphics mode
text help
Try this option out if you're having trouble installing
openEuler 22.03-LTS.
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=openEuler-22.03-LTS-x86_64 nomodeset quiet
label rescue
menu indent count 5
menu label ^Rescue a openEuler system
text help
If the system will not boot, this lets you access files
and edit config files to try to get it booting again.
endtext
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=openEuler-22.03-LTS-x86_64 rescue quiet
label memtest
menu label Run a ^memory test
text help
If your system is having issues, a problem with your
system's memory may be the cause. Use this utility to
see if the memory is working correctly.
endtext
kernel memtest
menu separator # insert an empty line
label local
menu label Boot from ^local drive
localboot 0xffff
menu separator # insert an empty line
menu separator # insert an empty line
label returntomain
menu label Return to ^main menu
menu exit
menu end
systemctl start tftp
systemctl enable tftp
yum -y install nfs-utils
vim /etc/exports
/ks 192.168.254.0/24(rw,sync)
/media 192.168.254.0/24(rw,sync)
mkdir /ks
在centos7.6里面,制作本地yum源,上传centos7.6镜像
cd /etc
mv yum.repos.d yum.repos.d.bak
mkdir yum.repos.d
cd yum.repos.d
vim dvd.repo
[development]
name=Centos7.6
baseurl=file:///mnt
enabled=1
gpgcheck=0
mount centos7.6镜像 /mnt
yum clean all && yum makecache
yum -y install system-config-kickstart
下载完成之后,执行system-config-kickstart 启动界面 配置ks.cfg文件
4.system-config-kickstart配置界面:
以下为我自己做时的配置,仅供参考,可按需修改
基本配置(默认语言、键盘、时区、密码、安装后重启)
安装方法(全新安装,nfs安装方式)
安装新引导装载程序选项
分区信息
网络配置(网卡名称根据实际情况修改)
显示配置
安装后脚本
保存
然后将此文件拷贝导192.168.254.154的/ks下
vim /ks/ks.cfg (具体为以下配置,装openEuler22.03的话,不同地方最好是修改为下面的配置)
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
#Install openEuler 22.03-LTS
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$BsZ1wjBv$SOxIpTsL5isR8.Ch..lz80
# System language
lang en_US
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Use NFS installation media
nfs --server=192.168.254.154 --dir=/media #nfs地址,镜像源目录
# Firewall configuration
firewall --disabled
# Network information
network --bootproto=dhcp --device=eth0 #此处可以修改网卡名称
# Reboot after installation
reboot
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=2048 #此处可以修改各目录的挂载大小
part swap --fstype="xfs" --size=4096
part / --fstype="xfs" --grow --size=31680
%packages
@base
%end
修改一下ks.cfg文件的权限
chmod 0777 /ks/ks.cfg
然后在同局域网下启动要安装系统的服务器
将客户机设置成网络启动,开机即可。
如上内容有参考其他文章,如有侵权请联系我删除。