link 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.

  1. 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
  2. Verify that the KVM module has loaded. You should see either kvm_intel or kvm_amd
    lsmod | grep kvm
  3. Reboot to ensure all services are started automatically and the necessary policies are applied.
  4. Start virt-manager by either going to Applications -> System Tools -> Virtual Machine Manager or running
  5. 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
  6. 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
  7. 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
  8. 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
  9. 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
    • /etc/sysconfig/network-scripts/ifcfg-br0 (static IP)
    • /etc/sysconfig/network-scripts/ifcfg-br0 (DHCP)
    • Disable NetworkManager and enable the network service
      chkconfig NetworkManager off
      service NetworkManager stop
      chkconfig --level 345 network on
      service network start
  10. 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.


There are no comments

Post a comment