kvm 从阿里云自动安装centos7

从阿里云自动安装centos7

virt-install --hvm --ram 2048 --vcpus=1 --network=bridge:virbr0 --name=cxauth --disk /opt/kvm/cxauth.img,size=130,bus=virtio,cache=none,io='threads' --accelerate --nographics --location=http://mirrors.aliyun.com/centos/7/os/x86_64/ --extra-args="ks=http://login.j.niit.edu.cn/in.ks console=tty0 console=ttyS0,115200"

ks安装自动文件

#ue shadow file encrypted by md5
auth  --useshadow  --enablemd5
# Install OS instead of upgrade
install
# boot from MBR (default)
bootloader --location=mbr
#clear MBR
zerombr
# delete all partition (default do not delete or use '--none')
clearpart --all --initlabel
# use text mode instead of graph mode
text
# enable iptables, allow ssh, separated by ',' if add other ports
firewall --enabled --port=22:tcp
# install yum resource URL
url --url=http://mirrors.aliyun.com/centos/7/os/x86_64/
# disable the settings menu when first boot
firstboot --disable
keyboard us
lang en_US
timezone --isUtc Asia/Shanghai
# network settings, including DNS, hostname, disable ipv6
network --device eth0 --bootproto static --ip 210.28.96.40 --netmask 255.255.255.0 --gateway 210.28.96.1 --nameserver 223.5.5.5 --hostname lib.cxauth --noipv6
# syslog level, use '--host' and '--port' to define remote rsyslog server
logging --level=info
# reboot after installation (default), may use 'poweroff' to shutdown system
reboot
# set root password, use '--iscrypted' to use crypt password
rootpw 123456
# disable selinux
selinux --disable
# do not configure X Windows
skipx
# partition, vda is the first disk of system, size is counted by MB
part /boot --fstype="ext4" --ondisk=vda --size=512
# use '--recommended' to let system decide the size of swap partition
part swap --fstype="swap" --ondisk=vda --recommended
part / --bytes-per-inode=4096 --fstype="ext4" --ondisk=vda --grow --size=1
# use '--grow --size=1' to use all the disk size left
#part /var --fstype="ext4" --ondisk=vda --grow --size=1
# add additional repositories
repo --name="extra" --baseurl=http://mirrors.aliyun.com/centos/7.0.1406/extras/x86_64/
# install packages needed, default will install @core and @base, use '--nobase' to do not install @base
%packages
@core
@base
man
telnet
ntpdate
#nagios-plugins
#nagios-plugins-all
#nrpe
#gcc
#make
##net-snmp
#net-snmp-utils
#watchdog
# shell to run after installation, configure DNS, yum repository, chkconfig,
%post
(
#echo 'snmpd:192.168.' >> /etc/hosts.allow
# log timestamp in command history
#logout after 3600s if no action
# enable the fuction of watchdog
#echo "modprobe softdog" >> /etc/sysconfig/watchdog
#sed -i '/min-memory/{s/#//}' /etc/watchdog.conf
#sed -i '/watchdog-device/{s/#//}' /etc/watchdog.conf
#sed -i '/admin/{s/#//}' /etc/watchdog.conf
#sed -i '/interval/{s/#//}' /etc/watchdog.conf
#sed -i '/logtick/{s/#//}'/etc/watchdog.conf
#sed -i '/pidfile/{s/#//}' /etc/watchdog.conf
#chkconfig watchdog on
# configure nagios client
#sed -i '/server_address/{s/#//g;s/127.0.0.1/'192.168.x.x'/g}' /etc/nagios/nrpe.cfg
#sed -i '/allowed_hosts/{s/127.0.0.1/&,192.168.x.x /}' /etc/nagios/nrpe.cfg
#chkconfig nrpe on
) 1>/root/install.log 2>&1


你可能感兴趣的:(kvm 从阿里云自动安装centos7)