kickstarts是一种无人值守的安装方式之一
工作原理:在安装过程中记录人工干预填写的各种参数,并生成一个名为ks.cfg的文件
主机开启dhcp服务:systemctl start dhcpd
1.安装system-config-kickstart服务并下载http服务: yum install system-config-kickstart httpd -y
2.设置硬盘分盘信息完成后生成ks.cfg :system-config-kickstart
运行 system-config-kickstart命令 开启kickstart,就会弹出一个图形化页面,这个功能就是手动安装虚拟机的所有的步骤,现在只是将其所有的步骤生成了ks.cfg文件;
ks.cfg文件的安装位置;
ksvalidator ks.cfg 检测ks.cfg是否出错
133 systemctl start httpd
134 systemctl enable httpd
135 sysstemctl stop firewalld
136 systemctl stop firewalld
137 systemctl mask firewalld
138 cp ks.cfg /var/www/html
vim /var/www/html/ks.cfg
添加服务组
添加服务组
%packages
@base
%end
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
Install OS instead of upgrade
install
Keyboard layouts
keyboard ‘us’
Root password
rootpw --iscrypted 1 1 1YxseMBJ7$ODFuO/930dLFlBHZVYB40/
Use network installation
url --url=“http://172.25.254.70/westos”
System language
lang en_US
Firewall configuration
firewall --disabled
System authorization information
auth --useshadow --passalgo=sha512
Use text mode install
graphical
firstboot --disable
SELinux configuration
selinux --disabled
Network information
network --bootproto=dhcp --device=eth0
Reboot after installation
reboot
System timezone
timezone Africa/Abidjan
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=200
part swap --fstype=“swap” --size=500
part / --fstype=“xfs” --grow --size=1
%packages
@base
%end
在后面几行添加
添加服务组
%packages
@base
%end
设置shell的指向文件
vim /mnt/test.sh
test -z “$1”&&{
echo “Erro:Please input VMNAME following scritps!!”
exit
}
virt-install
–name $1
–location http://172.25.254.70/westos \ yum源的路径
–memory 1024
–vcpus 1
–disk /var/lib/libvirt/images/$1.qcow2,size=6,bus=virtio
–network source=br0,model=virtio \ ##以上都是硬件信息的设置
–extra-args “ks=http://172.25.254.70/ks.cfg” ##该为硬盘信息的安装
sh /mnt/test.sh quan(虚拟机名称)