从阿里云自动安装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 md5auth --useshadow --enablemd5# Install OS instead of upgradeinstall# boot from MBR (default)bootloader --location=mbr#clear MBRzerombr# delete all partition (default do not delete or use '--none')clearpart --all --initlabel# use text mode instead of graph modetext# enable iptables, allow ssh, separated by ',' if add other portsfirewall --enabled --port=22:tcp# install yum resource URLurl --url=http://mirrors.aliyun.com/centos/7/os/x86_64/# disable the settings menu when first bootfirstboot --disablekeyboard uslang en_UStimezone --isUtc Asia/Shanghai# network settings, including DNS, hostname, disable ipv6network --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 serverlogging --level=info# reboot after installation (default), may use 'poweroff' to shutdown systemreboot# set root password, use '--iscrypted' to use crypt passwordrootpw 123456# disable selinuxselinux --disable# do not configure X Windowsskipx# partition, vda is the first disk of system, size is counted by MBpart /boot --fstype="ext4" --ondisk=vda --size=512# use '--recommended' to let system decide the size of swap partitionpart swap --fstype="swap" --ondisk=vda --recommendedpart / --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 repositoriesrepo --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@basemantelnetntpdate#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