BIOS开启VT
安装ubuntu系统
安装kvm相关的软件,并设置桥接网卡
(1) # apt-get install qemu-kvm libvirt-bin virtinst bridge-utils cpu-checker
# $ sudo apt-get install virt-manager qemu
(2) # kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
(3) # cp /etc/network/interfaces /etc/network/interfaces.bakup
(4) # vi /etc/network/interfaces
auto br0
iface br0 inet static
address 10.18.44.26
netmask 255.255.255.192
broadcast 10.18.44.63
dns-nameservers 10.0.80.11 10.0.80.1
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
auto eth0
iface eth0 inet static
(5) 如果有都个网卡,可以做多个桥接口
auto br1
iface br1 inet static
address 208.43.222.51
netmask 255.255.255.248
broadcast 208.43.222.55
gateway 208.43.222.49
bridge_ports eth1
auto eth1
iface eth1 inet static
直接使用brctl命令配置
$ sudo brctl addbr br0
$ sudo ip addr show
$ sudo brctl addif br0 eth0
使用命令查看virsh所支持的操作系统类型: osinfo-query os
创建虚拟机磁盘: qemu-img create -f qcow2 windows7test.img 20G
创建虚拟机:
$ sudo virt-install \
--virt-type=kvm \
--name centos7 \
--ram 2048 \
--vcpus=2 \
--os-variant=rhel7 \
--hvm \
--cdrom=/var/lib/libvirt/boot/CentOS-7-x86_64-DVD-1511.iso \
--network=bridge=br0,model=virtio \
--network=bridge=br1,model=virtio \
--graphics vnc \
--disk path=/var/lib/libvirt/images/centos7.qcow2,size=40,bus=virtio,format=qcow2
$ sudo virsh dumpxml centos7 | grep vnc
<graphics type='vnc' port='5901' autoport='yes' listen='127.0.0.1'>
$ sudo virsh vncdisplay centos7
本文转自ting2junshui51CTO博客,原文链接:http://blog.51cto.com/ting2junshui/1919957 ,如需转载请自行联系原作者