Linux 全自动安装脚本安装虚拟机

作用:批量安装虚拟机

[root@localhost Desktopl]# yum install -y system-config-kickstart.noarch 	
[root@localhost Desktopl]# yum install -y httpd
[root@localhost Desktopl]# systemctl start httpd
[root@localhost Desktopl]# systemctl stop firewalld
[root@localhost Desktopl]# systemctl disable firewalld
[root@localhost Desktopl]# system-config-kickstart

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

[root@localhost ~]# cd /var/www/html/
[root@localhost html]# vim ks.cfg  # 完善安装脚本 
50 %packages 
51 @base 
52 lftp 
53 %end

在这里插入图片描述

[root@localhost html]# ksvalidator ks.cfg   # 检测语法正确性,但是不能检测设定的合理性

测试

[root@foundation78 ~]# cd /mnt
[root@foundation78 mnt]# vim vm_install.sh   # 这是7.2版本虚拟机的自动安装脚本
1 #!/bin/bash  
2 virt-install \  
3 --name $1 \  
4 --ram 1000 \  
5 --vcpus 1 \  
6 --disk /var/lib/libvirt/images/$1.qcow2,size=8,bus=virtio \  
7 --network source=br0,model=virtio \  
8 --location http://172.25.254.78/rhel7.2 \  
9 --extra-args "ks=http://172.25.254.138/ks.cfg"   &> /dev/null &

在这里插入图片描述

[root@foundation78 mnt]# sh vm_install.sh lala	  # 执行脚本

在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/wzt888_/article/details/83580872