Install KVM on CentOS 6 Workstation← Back

These steps are based on this blog post except since I was installing on my workstation with a GUI there were a few extra steps necessary to enable bridged networking.
- Install the packages. There will be a lot of dependencies so it will take a bit of time to install.
yum groupinstall -y "Virtualization*" yum install -y dejavu-lgc-sans-fonts
- Verify that the KVM module has loaded. You should see either kvm_intel or kvm_amd
lsmod | grep kvm
- Reboot to ensure all services are started automatically and the necessary policies are applied.
- Start virt-manager by either going to Applications -> System Tools -> Virtual Machine Manager or running
virt-manager
- If you get an error similar to the following you need to reboot and enable Virtualisation in BIOS. VT-x on Intel CPUs or AMD-V on AMD CPUs.
Error polling connection 'qemu:///system': internal error Cannot find suitable emulator for x86_64
- I store my VMs on a large NTFS drive (a relic of my old Windows 7 workstation) so I had to install NTFS support and enable the SELinux policy allowing KVM to access an NTFS mount. You will require the RepoForge (RPMForge) repo to be installed for the package
yum --enablerepo=rpmforge install -y fuse-ntfs-3g setsebool -P virt_use_fusefs on mkdir /mnt/ntfs mount /dev/sdb1 /mnt/ntfs
- Edit /etc/fstab and mount the partition on boot. N.B: umask=0000 means any user who can login to the system has full read/write access to the NTFS mount. On my workstation that's perfectly acceptable, but if you don't wish this to be the case you should read the documentation
/dev/sdb1 /mnt/ntfs ntfs-3g rw,umask=0000,defaults 0 0
- If you plan to store your VM images in a location other than /var/lib/libvert/images you will need to install an additional SELinux package. Supposing you planned to store you images under /vmstore
yum install -y policycoreutils-python semanage fcontext -a -t virt_image_t "/vmstore(/.*)?" restorecon -R /vmstore
- Configure a network bridge so that your VMs are accessible from your network. Since installing CentOS 6 from the LiveDVD ISO installs X (kinda handy for a workstation), up to now you have most likely been using the NetworkManager service to handle your network interfaces. Bridging requires a switch to the network service and manual configuration of your network interfaces. If you used the Minimal ISO you will already be using network so you just need to modify your interface config files similar to below. This example assumes you will bridge eth0. You will obviously also need to specify your own IPs and DNS servers. Capitalisation in the TYPE= lines is important
- /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 TYPE=Ethernet ONBOOT=yes BRIDGE=br0
- /etc/sysconfig/network-scripts/ifcfg-br0 (static IP)
DEVICE=br0 TYPE=Bridge ONBOOT=yes BOOTPROTO=static DNS1=10.1.1.254 DNS2=10.1.1.253 DOMAIN=test.local IPADDR=10.1.1.2 NETMASK=255.255.255.0 GATEWAY=10.1.1.254
- /etc/sysconfig/network-scripts/ifcfg-br0 (DHCP)
DEVICE=br0 TYPE=Bridge ONBOOT=yes BOOTPROTO=dhcp
- Disable NetworkManager and enable the network service
chkconfig NetworkManager off service NetworkManager stop chkconfig --level 345 network on service network start
- /etc/sysconfig/network-scripts/ifcfg-eth0
- You are now ready to create your first VM. I like to reboot at this point to make sure my network interfaces are enabled automatically on boot as expected.
Comments
There are no comments