linux中自动安装的脚本

(在真机44中)

cd  /mnt

vim  create_vm.sh

#!/bin/bash

virt-install \

--name $1 \

-- ram 1024 \

--cpus 1 \

--disk  /var/lib/libvirt/images/$1.qcow2,size=9,bus=virtio \

-- network bridge=br0,model=virtio \

--location http://172.25.254.44/rhel7.2  &

 

/mnt/create-vm.sh xxx    ##创建虚拟机  (半自动创建)

 

 

 

 

 

(在真机44)cd /mnt

1.yum install system-config-kickstart  httpd -y

2.systm-config-kickstart

 

 

cd  /var/www/html

ls(会显示有ks.cfg)

vim ks.cfg内容如下:+

%packages

@base

lftp

%end

 

%post

cat >>/etc/yum.repos.d/yum.repo <<EOF

[rhel7.2]

name=rhel7.2

baseurl=http://172.25.254.44/rhel7.2

gpgcheck=0

EOF

%end

ksvalidator ks.cfg

systemctl start httpd

systemctl disable firewalld

systemctl stop firewalld

systemctl enable httpd

(在真机44中)

cd /mnt

vim create_vm.sh

#!/bin/bash

virt-install \

--name $1 \

-- ram 1024 \

--cpus 1 \

--disk  /var/lib/libvirt/images/$1.qcow2,size=9,bus=virtio \

-- network bridge=br0,model=virtio \

--location http://172.25.254.44/rhel7.2

--extra-args  ks=http://172.25.254.144/ks.cfg &

/mnt/create_vm.sh   xxx    ##自动完全创建虚拟机

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值