Kvm: Difference between revisions

From Halfface
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:
  yum install -y qemu kvm SDL bridge-utils tunctl
  yum install -y qemu kvm SDL bridge-utils tunctl


==Prepare vitual environment and create bridge with eth0==
==install virtual machine.==
virt-install --connect qemu:///system --name Fedora_16 --ram 2048 --vcpus=1 -f /ssd/libvirt/Fedora_16.qcow2 -s 30 -c /install/system/linux/fedora/16/Fedora-16-x86_64-netinst.iso --vnc --noautoconsole --hvm


load modules.
==connect to virtual machine.==
  modprobe kvm-intel
  virt-viewer Fedora_16
modprobe tun


Create bridge.
tunctl -t tap0
ip addr flush eth0
ifconfig eth0 0.0.0.0 promisc
ifconfig tap0 0.0.0.0 promisc
brctl addbr br0
ifconfig br0 hw ether 62-f0-dc-95-c4-c9
brctl addif br0 eth0
brctl addif br0 tap0
dhclient br0
Create bridge wlan0
tunctl -t tap0
ip addr flush wlan0
ifconfig wlan0 0.0.0.0 promisc
ifconfig tap0 0.0.0.0 promisc
brctl addbr br0
ifconfig br0 hw ether 00:13:E8:B8:8B:65
brctl addif br0 wlan0
brctl addif br0 tap0
dhclient br0
==Prepare vitual environment and create bridge with wlan0==
sudo sysctl net.ipv4.ip_forward=1
modprobe kvm-intel
modprobe tun
Create bridge.
tunctl -t tap0
ip addr flush wlan0
ifconfig wlan0 0.0.0.0 promisc
ifconfig tap0 0.0.0.0 promisc
brctl addbr br0
ifconfig br0 hw ether 62:f0:dc:95:c4:c9
brctl addif br0 wlan0
brctl addif br0 tap0
dhclient br0
Load modules.
sudo modprobe kvm-intel
sudo modprobe tun
Paravirtulazied network interface.
qemu-system-x86_64 -hda windowsxp.img -net nic,model=virtio
Start install
sudo qemu-kvm -no-acpi -hda /storage/kvm/windows-xp.img -boot d -cdrom /storage/install/system/winxp/xpsp2/winxpsp2.iso
Start virtual machine.
qemu-kvm -no-acpi -hda /storage/kvm/windows-xp.img -boot c -net nic -net tap,ifname=tap0,script=no
==Some startscript==
#!/bin/sh
PATH=$PATH:/usr/sbin:/sbin
sudo brctl addbr br0
sudo ifconfig wlan0 0.0.0.0
sudo brctl addif br0 wlan0
sudo ifconfig br0 10.111.222.8 netmask 255.255.255.0 up
sudo route add -net 10.111.222.0 netmask 255.255.255.0 br0
sudo route add default gw 10.111.222.1 br0
sudo tunctl -b
sudo ifconfig tap0 up
sudo brctl addif br0 tap0
qemu-kvm ~/win2k.img -m 512 -net nic -net tap,ifname=tap0,script=no
qemu-kvm -hda winxp.vmd -m 512 -net nic -net tap,ifname=tap0,script=no
Ip forwarding.
sudo sysctl net.ipv4.ip_forward=1
==error checking==
Create virtual bridge.
sudo brctl addbr br0
Are interfaces connected.
sudo brctl show
Create tun interface.
sudo tunctl
Activate interfaces.
sudo ifconfig tap0 up
sudo ifconfig br0 up
Add interfaces to bridge.
sudo brctl addif br0 eth0
sudo brctl addif br0 wlan0
sudo brctl addif br0 tap0
[[Category:Applications]]
[[Category:Applications]]
[[Category:Unix]]
[[Category:Unix]]
[[Category:Virtualization]]
[[Category:Virtualization]]

Revision as of 05:58, 15 May 2012

prepare environment

Is environment prepared for viritutalization.

egrep '(vmx|svm)' /proc/cpuinfo

vmx - (intel) svm - (amd)

Create disk image.

qemu-img create -f qcow2 f8_1_x86_64.img 10G

Install software.

yum install -y qemu kvm SDL bridge-utils tunctl

install virtual machine.

virt-install --connect qemu:///system --name Fedora_16 --ram 2048 --vcpus=1 -f /ssd/libvirt/Fedora_16.qcow2 -s 30 -c /install/system/linux/fedora/16/Fedora-16-x86_64-netinst.iso --vnc --noautoconsole --hvm

connect to virtual machine.

virt-viewer Fedora_16