Yesterday i was re installing android studio due to a drive corruption on my new pc. At the end screen i saw a message that my computer supports vm accleration and i should configure that for better performance. Linux-based systems support VM acceleration (hardware virtualization) through the KVM software package. So in this post i will share my KVM installation experience.
I followed this post of android developers but it showed some packages were missing and errors occured.
If you are sure your device is capable then no need to read this section. For those who wondering how they know if their device is capable or not can continue.
To use VM acceleration on Linux, your computer must also meet these requirements:
- Intel processors: Support for Virtualization Technology (VT-x), Intel EM64T (Intel 64) features, and Execute Disable (XD) Bit functionality enabled.
- AMD processors: Support for AMD Virtualization (AMD-V).
Check CPU for HW Virtualization Support
egrep -c '(vmx|svm)' /proc/cpuinfo sudo apt-get install cpu-checker kvm-ok
The output should look like below snippet:
$ egrep -c '(vmx|svm)' /proc/cpuinfo 12 $ sudo apt-get install cpu-checker $ kvm-ok INFO: /dev/kvm exists KVM acceleration can be used
Here the android developers blog was a little bit outdated. There instructions were for ubuntu version lower then 18.10 in which some of the packages were removed & renamed.
For 18.10 or later:
sudo apt-get install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
For 10.04 or later:
sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder bridge-utils
For 9.10 or earlier:
sudo aptitude install kvm libvirt-bin ubuntu-vm-builder bridge-utils
What are these packages for ?
- libvirt-bin provides libvirtd which you need to administer qemu and kvm instances using libvirt
- qemu-kvm (kvm in Karmic and earlier) is the backend
- ubuntu-vm-builder powerful command line tool for building virtual machines
- bridge-utils provides a bridge from your network to the virtual machines
For GUI i installed
virt-manager using below command. Which looks like the screenshot attached below.
sudo apt install virt-manager
Add Users to KVM Groups
Note: For 9.10 and later but not for 18.10 and 14.04 LTS instead of
sudo adduser `id -un` kvm sudo adduser `id -un` libvirt
To verify the installation use below commands (should output as shown):
$ virsh list --all Id Name State -------------------- $
Now if you open
virt-manager you should see an error. To fix this i changed my device’s group to
kvm/libvirt (note that i am using Ubuntu 19.04, use
libvirtd as i mentioned the case above).
sudo chown root:libvirt /dev/kvm
Restart Kernel Modules
You can also signout or reboot but i prefered to restart modules:
rmmod kvm modprobe -a kvm
Now the installation is complete and you should be able to open virt-manager (if installed) without any errors.
Thanks for reading the post ! See you in future posts …