Ubuntu Server 12.10 之 KVM 安装和创建虚拟机
虚拟化技术甚嚣尘上, KVM是Linux内核级别的虚拟技术. 本文把如何在Ubuntu Server12.10上搭建虚拟机作一个总结. 过程繁复, 但是严格按本文执行, 一定可以创造出自己的虚拟机来. HOST机的安装(Ubuntu Server 12.10)过程请参考我前面的文章。
1 安装好Ubuntu Server 12.10 amd64 HOST机之后, 在HOST上运行下面的命令升级系统:
# echo 'Acquire::http::Proxy "http://10.112.18.178:3142";' > /etc/apt/apt/conf
其中:
http://10.112.18.178:3142 是你的cache server的IP和端口. 如何你没有这个cache server, 则忽略上一句.
# apt-get update
# apt-get upgrade
# apt-get install Python-vm-builder
我朋友非常喜欢emacs, 所以他强烈建议我加上下面这句:
# apt-get install emacs
2 修补python的bug
# wget -O ./vmpatch.py.diff https://launchpadlibrarian.net/120169451/usr_share_pyshared_VMBuilder_plugins_ubuntu_dapper.py.diff
# cp /usr/share/pyshared/VMBuilder/plugins/ubuntu/dapper.py dapper.py.bk
# patch /usr/share/pyshared/VMBuilder/plugins/ubuntu/dapper.py ./vmpatch.py.diff
3 配置HOST机器网络
按下面的内容更改你的网络配置文件:
/etc/network/interfaces
注意要把下面的IP地址改为适合你的网络的:
address 10.112.18.161
network 10.112.18.0
netmask 255.255.255.0
broadcast 10.112.18.255
gateway 10.112.18.254
/etc/network/interfaces
- # This file describes the network interfaces available on your system
- # and how to activate them. For more information, see interfaces(5).
- # The loopback network interface
- auto lo
- iface lo inet loopback
- # The primary network interface
- auto eth0
- iface eth0 inet manual
- auto br0
- iface br0 inet static
- address 10.112.18.161
- network 10.112.18.0
- netmask 255.255.255.0
- broadcast 10.112.18.255
- gateway 10.112.18.254
- dns-nameservers 8.8.8.8 8.8.4.4
- bridge_ports eth0
- bridge_fd 9
- bridge_hello 2
- bridge_maxage 12
重启网络服务:
# service networking restart
或
# /etc/init.d/networking restart