使用 kickstart 半自动化安装CentOS系统
制作ks.cfg应答文件
system-config-kickstart #centos7利用命令图型界面生成ks文件
#功能由 system-config-kickstart 包提供
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
image.png
生成配置文件格式
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$2DigeYTY$dr6c8S9qYgkLpzHxECF2a1
# System language
lang en_US
# System authorization information
auth --useshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use text mode install
text
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Firewall configuration
firewall --disabled
# Network information
network --bootproto=dhcp --device=eh0
# 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="ext4" --size=1024
part swap --fstype="swap" --size=2048
part / --fstype="ext4" --size=102400
part /data --fstype="ext4" --size=51200
依照~/anaconda-ks.cfg文件修改ks.cfg
ignoredisk --only-use=sda #此行必须指定
zerombr
text #系统安装为命令行模式
reboot #安装完成后重启
clearpart --all --initlabel #清除原有卷标
selinux --disabled #禁用SELinux
firewall --disabled #禁用firewalld
url --url=http://10.0.0.7/centos/os/8/ #系统安装文件路径
keyboard --vckeymap=us --xlayouts='us'
lang en_US.UTF-8
bootloader --append="net.ifnames=0" --location=mbr --boot-drive=sda #此行必须指定
network --bootproto=dhcp --device=eth0 --ipv6=auto --activate
network --hostname=centos8.magedu.org
rootpw --iscrypted
$6$j9YhzDUnQVnxaAk8$qv7rkMcPAEbV5yvwsP666DXWYadd3jYjkA9fpxAo9qYotjGGBUclCGoP1TRv
gHBpqgc5n0RypMsPTQnVDcpO01
firstboot --enable
skipx
services --disabled="chronyd"
timezone Asia/Shanghai --isUtc --nontp
user --name=wang --
password=6oUfb/02CWfLb5l8f$sgEZeR7c7DpqfpmFDH6huSmDbW1XQNR4qKl2EPns.gOXqlnAIgv9p
TogtFVaDtEpMOC.SWXKYqxfVtd9MCwxb1 --iscrypted --gecos="wang"
#autopart --type=lvm #自动创建成逻辑卷
#part / --fstype xfs --size 1 --grow --ondisk sda 可以实现根自动使用所有剩余空间
#创建分区及文件系统
part / --fstype="xfs" --ondisk=sda --size=102400
part /data --fstype="xfs" --ondisk=sda --size=51200
part swap --fstype="swap" --ondisk=sda --size=2048
part /boot --fstype="ext4" --ondisk=sda --size=1024
%packages #系统安装时,设置安装包
@^minimal-environment
kexec-tools
vim
curl
wget
tree
%end
%addon com_redhat_kdump --enable --reserve-mb='auto'
%end
%anaconda #anaconda文件,这里设置的是用户创建规则
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end
%post #安装后脚本,这里是建立普通用户centos8,密码123456
useradd centos8
echo 123456 | passwd --stdin centos8 &> /dev/null
%end
image.png
mkdir –pv /data/myiso
mount /dev/sr0 /mnt #将系统安装iso挂到/mnt下
cp -r /mnt/isolinux/ /data/myiso/
tree /data/myiso/
/data/myiso/
└── isolinux
├── boot.cat
├── boot.msg
├── grub.conf
├── initrd.img
├── isolinux.bin
├── isolinux.cfg
├── ldlinux.c32
├── libcom32.c32
├── libutil.c32
├── memtest
├── splash.png
├── TRANS.TBL
├── vesamenu.c32
└── vmlinuz
vim /data/myiso/isolinux/isolinux.cfg
#方法1:应答方件放在ISO文件里
label linux menu
label ^Auto Install CentOS Linux 8
kernel vmlinuz initrd=initrd.img text ks=cdrom:/myks.cfg
#方法2:应答方件放在http服务器上
label linux menu
label ^Auto Install CentOS Linux 8
kernel vmlinuz append initrd=initrd.img quiet
ks=http://10.0.0.8/ksdir/centos8.cfg
label rescue menu
label ^Rescue a CentOS Linux system
kernel vmlinuz
append initrd=initrd.img
inst.repo=http://10.0.0.7/centos/os/8/ rescue quiet label
local menu default menu label Boot from ^local drive
localboot 0xffff
cp /root/myks.cfg /data/myiso/
yum -y install mkisofs
mkisofs -R -J -T -v --no-emul-boot --boot-load-size 4 --bootinfo-table -V "CentOS 8.0 x86_64 boot" -b isolinux/isolinux.bin -c isolinux/boot.cat -o /root/boot.iso /data/myiso/ #制作iso文件
实现pxe安装双系统centos6、centos7
准备工作
先创建ks.cfg 应答文件
需要开启 DHCP服务 TFTP服务 syslinux服务
配置dhcp
yum -y install dhcp #centos6、7
dnf -y install dhcp-server #centos8
vim /etc/dhcp/dhcpd.cfg #配置dhcp服务
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.26 10.0.0.30;
option routers 10.0.0.2;
next-server 10.0.0.7; # 指定tftp服务器
filename "pxelinux.0"; #指定pxe文件,固定文件名
option domain-name-servers 180.76.76.76,223.5.5.5;
}
systemctl enable --now dhcp
配置tftp
yum/dnf -y install tftp-server
systemctl enable --now tftp #启动tftp
创建pxe文件
cp /usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/tftpboot/
# 8需要从iso镜像中复制 /isolinux/{ldlinux.c32,libcom32.c32,libutil.c32}
#到/var/lib/tftpboot/
vim /var/lib/tftpboot/pxelinux.cfg/default #编辑pxe菜单
#default 文件格式,参考isolinux.cfg 修改
default menu.c32
timeout 600
menu title Install CentOS Linux
label linux7
menu label Auto Install CentOS Linux ^7
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=http://10.0.0.7/ksdir/7ks.cfg
label linux6
menu label Auto Install CentOS Linux ^6
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ks=http://10.0.0.7/ksdir/6ks.cfg
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
image.png