Linux 自动创建安装虚拟机

虚拟机创建好后不会自动安装,现在通过脚本自动安装虚拟机
系统会将虚拟机安装的所有问题的放在anaconda-kickstart (例如虚拟机分区,划分的时区,语言等)

实验:创建虚拟机时自动安装虚拟机
(1)实验前提:yum原一配置好。即在浏览器中可以访问

[root@localhost ~]# df
Filesystem            1K-blocks     Used Available Use% Mounted on
/dev/mapper/rhel-root 200319420 49531080 150788340  25% /
devtmpfs                1872424        0   1872424   0% /dev
tmpfs                   1890108       32   1890076   1% /dev/shm
tmpfs                   1890108     9280   1880828   1% /run
tmpfs                   1890108        0   1890108   0% /sys/fs/cgroup
/dev/loop0              3704296  3704296         0 100% /var/www/html/rhel7.3
/dev/loop1              3762278  3762278         0 100% /var/www/html/rhel6.5
/dev/loop2              3947824  3947824         0 100% /var/www/html/rhel7.2
/dev/sda9               1038336   190800    847536  19% /boot
tmpfs                    378024       40    377984   1% /run/user/0

在这里插入图片描述

(2)下载kickstart

[root@localhost ~]# yum install system-config-kickstart -y

(3)打开阿帕奇及关闭防火墙

[root@localhost ~]# systemctl enable httpd
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# 

(3)执行软件设置安装时所选的内容

[root@localhost ~]# system-config-kickstart  ##进入图形配置界面
/usr/share/system-config-kickstart/kickstartGui.py:104: GtkWarning: GtkSpinButton: setting an adjustment with non-zero page size is deprecated
  xml = gtk.glade.XML ("/usr/share/system-config-kickstart/system-config-kickstart.glade", domain="system-config-kickstart")
Loaded plugins: langpacks, product-id

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

设置磁盘分区
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

图形选择完后会生成ks.cfg文件,将文件保存在/var/www/html中

[[root@localhost ~]# cd /var/www/html/
[root@localhost html]# ls
ks.cfg  rhel6  rhel6.5  rhel7.2  rhel7.3
[root@localhost html]# 

设置完后需要在浏览器进行检验
在这里插入图片描述

打开 ks.cfg 文件添加安装虚拟你的时需要下载的软件(因为刚才在图形界面时下载软件存在bug)只能手动写入

[root@localhost html]# vim ks.cfg 

在这里插入图片描述

检测脚本:ksvalidator
ksvalidator 检测只能检测语法是否正确,但不检测脚本的合理性。

[root@localhost html]# ksvalidator ks.cfg 
[root@localhost html]# 

新建虚拟机

(1)新建虚拟机脚本文件

在这里插入图片描述

执行脚本

在这里插入图片描述

在这里插入图片描述

(2)图形安装

virt-manager进入虚拟机设置界面,右键点击选new,重新建立一个虚拟机(http)
选择network install
填写URL
创建虚拟机
创建后自动安装

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值