Difference between revisions of "KVM: Installation and operation"
Jump to navigation
Jump to search
(Created page with "===== Check CPU supports KVM ===== <syntaxhighlight> egrep '(vmx|svm)' --color=always /proc/cpuinfo </syntaxhighlight> ===== Install KVM ===== <syntaxhighlight> # on RHEL 5 yum install virt-viewer virt-manag...") |
|||
| Line 1: | Line 1: | ||
| − | + | == Check CPU supports KVM == | |
<syntaxhighlight> | <syntaxhighlight> | ||
egrep '(vmx|svm)' --color=always /proc/cpuinfo | egrep '(vmx|svm)' --color=always /proc/cpuinfo | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | + | == Install KVM == | |
<syntaxhighlight> | <syntaxhighlight> | ||
# on RHEL 5 | # on RHEL 5 | ||
| Line 16: | Line 16: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | + | == Install the modules == | |
<syntaxhighlight> | <syntaxhighlight> | ||
modprobe kvm-intel | modprobe kvm-intel | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | + | == Start libvirtd == | |
<syntaxhighlight> | <syntaxhighlight> | ||
/etc/init.d/libvirtd restart | /etc/init.d/libvirtd restart | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | + | == Load up virtual manager == | |
<syntaxhighlight> | <syntaxhighlight> | ||
virt-manager | virt-manager | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | + | == Setup Bridged Networking == | |
By Default KVM uses NAT (hosts can see outside world but world cannot see the hosts). To setup bridged networking: | By Default KVM uses NAT (hosts can see outside world but world cannot see the hosts). To setup bridged networking: | ||
| Line 72: | Line 72: | ||
vnet0 | vnet0 | ||
| − | + | == Create the image file == | |
In RHEL6, use virt-install: (dont use any files in /root) | In RHEL6, use virt-install: (dont use any files in /root) | ||
<syntaxhighlight> | <syntaxhighlight> | ||
| Line 106: | Line 106: | ||
* Change CDs using '''virt-manger''' -> Open Guest -> Show Virtual Hardware -> CDROM | * Change CDs using '''virt-manger''' -> Open Guest -> Show Virtual Hardware -> CDROM | ||
| − | + | == Start qemu == | |
<syntaxhighlight> | <syntaxhighlight> | ||
/usr/libexec/qemu-kvm -hda vig_xp.img -cdrom vig_xp.iso -m 512 -boot d | /usr/libexec/qemu-kvm -hda vig_xp.img -cdrom vig_xp.iso -m 512 -boot d | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 13:38, 7 November 2012
Check CPU supports KVM
egrep '(vmx|svm)' --color=always /proc/cpuinfoInstall KVM
# on RHEL 5
yum install virt-viewer virt-manager
yum install kvm kvm-qemu-img
OR
yum groupinstall KVM
# on RHEL 6
yum groupinstall Virtualisation 'Virtualization Client' 'Virtualization Platform' 'Virtualization Tools'Install the modules
modprobe kvm-intelStart libvirtd
/etc/init.d/libvirtd restartLoad up virtual manager
virt-managerSetup Bridged Networking
By Default KVM uses NAT (hosts can see outside world but world cannot see the hosts). To setup bridged networking:
- Disable NetworkManager
# chkconfig NetworkManager off # chkconfig network on # service NetworkManager stop # service network start
- Edit the file: /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0" ONBOOT="yes" BRIDGE=br0
- Create the bridge script/file: /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0 TYPE=Bridge IPADDR=172.28.10.58 NETMASK=255.255.0.0 NETWORK=172.28.0.0 DNS1=172.28.1.3 ONBOOT=yes DELAY=0
- Configure iptables to allow traffic be forwarded across the bridge
# iptables -I FORWARD -m physdev --physdev-is-bridged -j ACCEPT # service iptables save # service iptables restart
- Reload libvirtd
# service libvirtd reload
- Verify it's working fine:
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.0025902efb56 no eth0
vnet2
virbr0 8000.525400098976 yes virbr0-nic
vnet0
Create the image file
In RHEL6, use virt-install: (dont use any files in /root)
[root@kvm kvms]$ virt-install \
--name=guest1-sl6-64 \
--disk path=/vm/guest1-rhel6-64,size=10,sparse=false \
--vnc \
--vcpus=2 \
--ram=2048 \
--cdrom=/vm/SL-61-x86_64-2011-07-27-Everything-DVD1.iso \
--network bridge=br0 \
--os-type=linux \
--os-variant=rhel6
Starting install...
Creating storage file guest1-rhel6-64 8% [==- ] 17 MB/s | 873 MB 09:13 ETANotes from RHEL5 on creating a qcow filesystem (virt-install runs this under the covers)
dd if=/dev/zero of=/home/viglen/vm_winxp.img bs=1024k count=12000
OR
qemu-img create -f qcow windows.img 12GCreating files in /root resulted in the following error:
Starting install...
ERROR internal error process exited while connecting to monitor: char device redirected to /dev/pts/1
qemu: could not open disk image /root/scratch/SL-61-x86_64-2011-07-27-Everything-DVD1.iso: Permission denied- Change CDs using virt-manger -> Open Guest -> Show Virtual Hardware -> CDROM
Start qemu
/usr/libexec/qemu-kvm -hda vig_xp.img -cdrom vig_xp.iso -m 512 -boot d