kvm permission denied on Android Studio emulator

felipe.rce picture felipe.rce · Oct 5, 2018 · Viewed 11.2k times · Source

When I try to run an AVD, I get this erros:

/dev/kvm device permission denied

Yeah, I know, I don't have the permission to access /dev/kvm, I know that I can "solve" it by changing the /dev/kvm permission to my user, and set my user to kvm group, it is working but when I restart my user session, the /dev/kvm permission return to root user and root group, and I need to set the permission to my group again and again...

How to set this permission and prevent that when I reboot my computer my permission are not changed anymore?

SO: Ubuntu 18.04.01

Answer

Andrei Vinogradov picture Andrei Vinogradov · Oct 12, 2018

This command should help you:

sudo setfacl -m u:$USER:rwx /dev/kvm

Using it you will grant to current user rwx permissions to /dev/kvm. Or just replace $USER to any user you need.

As mentioned in setfacl manpages "This utility sets Access Control Lists (ACLs) of files and directories." It's a little bit different from chmod and chown. Using it you can grant required permissions to specific user. It's a bit more powerful tool and much more fine-grained. If you want to dive deeper, read about Access Control Lists. For example, in ubuntu docs: https://help.ubuntu.com/community/FilePermissionsACLs