Monday, October 31, 2011

Virtualization Using Open Source Tools (qemu-kvm)

Today I am going to talk about creating virtual machines using qemu-kvm. I'll be using Scientific Linux (a.k.a. Enterprise Linux much like Red Had and Centos) for this. A very good guide is available for Fedora at fedora wiki.

Optional: Install yumex. It is a good package manager for yum. Much better than the default stuff shipped with standard distro. It is better for guys who like to do gui based installation.

Step 1: Install following packages:
yum install qemu-kvm python-virtinst virt-manager virt-viewer libvirt

Step 2: Start the libvertd service
service libvirtd start

Step 3:
Launch "Virtual Machine Manager" from the menu bar or just run virt-install --prompt for an interactive CLI virtual machine creation. A one line install is also possible. Read man virt-install carefully before attempting this.
Example:
virt-install --connect qemu:///system -n fed15-kvm -r 768 --vcpus=2 -f fed15-kvm -s 12 -c ../iso_files/fed15_64.iso --vnc --noautoconsole --os-type linux --os-variant fedora14 --accelerate --network=bridge:virbr0 --hvm

You are done! You can launch the machine using "Virtual Machine Manager" or by using virsh --connect qemu:///system start fed15-kvm where fed15-kvm is the name of my VM, though using command will start it in background.

Have fun and do comment if I have missed on something or you have any tips and tricks.