I’m starting to work on replacing my CentOS 6 KVM server with a new CentOS 7 server. As much as I dislike CentOS 7, I’m trying to give it an honest try and make an honest attempt at learning. Working in the IT profession requires you to constantly adapt to change and learn new tech stacks. The problem I have is in CentOS 6 it was so easy to install KVM and set up a VM. CentOS 7 has been issue after issue. The most recent being the “Could Not Access KVM Kernel Module: Permission Denied” error.
I started with a bare installation of CentOS version 7.4.1708. I reinstalled the OS several times before I was able to finally find the cause of the problem. Apparently in CentOS 7, when you install libvirt, it doesn’t grant the correct permissions on /dev/kvm. I checked my CentOS 6 machines running KVM and what do you know, they’re all set correctly. Go figure.
By default, the /dev/kvm is owned by root:root with permissions 600.
[root@kvmserver ~]# ll /dev/kvm crw------- 1 root root 10, 232 Nov 1 08:44 /dev/kvm
Changing the owner to root:kvm and permissions to 660 will resolve the problem.
[root@kvmserver ~]# chown root:kvm /dev/kvm [root@kvmserver ~]# chmod 660 /dev/kvm [root@kvmserver ~]# ll /dev/kvm crw-rw---- 1 root kvm 10, 232 Nov 1 08:44 /dev/kvm
Don’t forget to restart the libvirt service and remember, this is done with systemctl rather than the service command. Doh.
[root@kvmserver ~]# systemctl restart libvirtd.service