KVM Virtualization On Ubuntu Host
################install KVM and vm builder utils#######################
sudo apt-get install kvm kvm-pxe libvirt-bin ubuntu-vm-builder bridge-utils
################install uml utilities##################################
sudo apt-get install uml-utilities
################Test kvm installation##################################
virsh -c qemu:///system list
################/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
#virtual interface
auto br0
iface br0 inet static
address 172.16.2.230
network 172.16.2.0
netmask 255.255.255.0
broadcast 172.16.2.255
gateway 172.16.2.252
bridge_ports eth0
bridge_stp off
bridge_fd 9
bridge_hello 2
bridge_maxwait 12
##############To create virbr0 DHCP####################################
sudo vim /etc/libvirt/qemu/networks/default.xml
#change this to
<network>
<name>default</name>
<bridge name="virbr%d" />
<forward/>
<ip address="192.168.122.1" netmask="255.255.255.0">
<dhcp>
<range start="192.168.122.2" end="192.168.122.254" />
</dhcp>
</ip>
</network>
#this
<network>
<name>default</name>
<bridge name="virbr%d" />
<forward/>
<ip address="10.0.1.1" netmask="255.0.0.0">
<dhcp>
<range start="10.0.1.10" end="10.0.1.100" />
</dhcp>
</ip>
</network>
##############Restart virtual network##################################
sudo virsh net-list
sudo virsh net-destroy default
sudo virsh net-stop default
##############Command to create a new image file#######################
sudo qemu-img create -f qcow win2k3-64.img 10G
##############Command to boot from the disk############################
sudo qemu-system-x86_64 -m 512 -hda win2k3-64.img -cdrom /dev/dvd -boot d -vnc :1
##############Script to generate random MAC address####################
#! /usr/bin/python
# macgen.py script generates a MAC address for Xen guests
#
import random
mac = [ 0x00, 0x16, 0x3e,
random.randint(0x00, 0x7f),
random.randint(0x00, 0xff),
random.randint(0x00, 0xff) ]
print ':'.join(map(lambda x: "%02x" % x, mac))
##############Command to launch the image##############################
sudo qemu-system-x86_64 -hda vms/tstproxy/win2003-64.qcow -m 1024 -net nic,macaddr=00:16:3e:03:d9:5f -net tap -nographic -localtime &
sudo qemu-system-x86_64 -hda vms/tstapp01/win2003-64.qcow -m 2048 -net nic,macaddr=00:16:3e:33:0e:8a -net tap -nographic -localtime &
sudo qemu-system-x86_64 -hda vms/tstapp02/win2003-64.qcow -m 2048 -net nic,macaddr=00:16:3e:3e:7e:14 -net tap -nographic -localtime &
##############Command to check the available memory####################
free -m
free -m -l -s 2
##############Command to list running KVM/QEMU processes###############
ps -A | grep qemu
Tuesday, December 8, 2009
KVM Setup
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment