# cat /var/lib/tftpboot/pxelinux.cfg/default
# default CentOS6_PXE # 默认启动'default CentOS6_PXE'标记的内核
default vesamenu.c32 # 菜单选项
timeout 100 # 单位是1/10s
# prompt 1 # 为 '0' 时则不提示'boot: ',将会直接启动 'default' 参数中指定的内容
display boot.msg # 启动时显示
# menu background splash.jpg # 菜单背景等
menu title Welcome to CentOS 6.4!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000
label CentOS6_PXE
menu label ^PXE Install CentOS KVM
kernel /CentOS6/vmlinuz
append ks=ftp://192.168.80.131/ks.cfg initrd=/CentOS6/initrd.img
label rescue
menu label ^Rescue installed system
kernel /CentOS6/vmlinuz
append initrd=/CentOS6/initrd.img rescue
# cat /var/ftp/ks.cfg
# System authorization information
auth --useshadow --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --disabled
skipx
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Installation logging level
logging --level=info
# Use network installation
url --url=ftp://192.168.80.131/centos
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$duSkJ1$1P5qGnqUGn3S1MTTFiPJY.
# SELinux configuration
selinux --disabled
# System timezone
timezone Asia/Shanghai
# Install OS instead of upgrade
install
# Disk partitioning information
part /boot --asprimary --bytes-per-inode=4096 --fstype="ext3" --size=100
part / --bytes-per-inode=4096 --fstype="ext3" --size=5000
part swap --bytes-per-inode=4096 --fstype="swap" --size=512
%packages --nobase
@core
@Development tools
acpid # 如果不安装acpid服务,virsh shutdown virtual_name 命令会失效
vim
wget
lsof
%end
Address to listen on for VNC/Spice connections. Default is typically 127.0.0.1
(localhost only), but some hypervisors allow changing this globally
(for example, the qemu driver default can be changed in /etc/libvirt/qemu.conf).
Use 0.0.0.0 to allow access from other machines. This is use by ’vnc’ and ’spice.
virsh # list # 显示运行或者暂停的Guest
Id Name State
----------------------------------------------------
28 centos6_1 running
virsh # list --all # 显示所有的Guest,包括状态为shut off的
Id Name State
----------------------------------------------------
28 centos6_1 running
- centos shut off
virsh # console centos6_1 # console方式连接Guest
Connected to domain centos6_1
Escape character is ^] # 使用Ctrl+]即可退出
CentOS release 6.4 (Final)
Kernel 2.6.32-358.el6.x86_64 on an x86_64
localhost.localdomain login:
virsh # start centos # 开启某个Guest
Domain centos started
virsh # list
Id Name State
----------------------------------------------------
28 centos6_1 running
32 centos running
virsh # shutdown centos
# 关闭某个Guest,这里一定要注意,如果Guest没有安装运行acpid服务,
# 则此方式失效,可以kill强制关闭,或者console/ssh连接执行关闭
Domain centos is being shutdown
virsh # list
Id Name State
----------------------------------------------------
28 centos6_1 running
virsh # suspend centos6_1 # 挂起主机
Domain centos6_1 suspended
virsh # list
Id Name State
----------------------------------------------------
28 centos6_1 paused
virsh # resume centos6_1 # 把主机从挂起状态切换至运行状态
Domain centos6_1 resumed
virsh # list
Id Name State
----------------------------------------------------
28 centos6_1 running
virsh #
virt-clone 克隆Guest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# virt-clone --connect=qemu:///system --original=centos6_1 \
--name=centos6_2 -f /var/lib/libvirt/images/centos6_2.img
ERROR Domain with devices to clone must be paused or shutoff.
# virsh suspend centos6_1
Domain centos6_1 suspended
# virsh list
Id Name State
----------------------------------------------------
28 centos6_1 paused
# virt-clone --connect=qemu:///system --original=centos6_1 \
--name=centos6_2 -f /var/lib/libvirt/images/centos6_2.img
Allocating 'centos6_2.img' 1% [- ] 9.0 MB/s | 112 MB 18:44 ETA