WSL: Incorrect permissions on `/dev/kvm`
Windows Build Number
Microsoft Windows [Version 10.0.22000.51]
WSL Version
- WSL 2
- WSL 1
Kernel Version
5.10.16
Distro Version
Ubuntu 20.04
Other Software
KVM
Repro Steps
Incorrect permissions on /dev/kvm is preventing startup of Android emulator although the user is a member of the required group.
$ emulator -avd api29
emulator: Android emulator version 30.6.5.0 (build_id 7324830) (CL:N/A)
ProbeKVM: This user doesn't have permissions to use KVM (/dev/kvm).
The KVM line in /etc/group is: [kvm:x:108:davisj]
If the current user has KVM permissions,
the KVM line in /etc/group should end with ":" followed by your username.
If we see LINE_NOT_FOUND, the kvm group may need to be created along with permissions:
sudo groupadd -r kvm
# Then ensure /lib/udev/rules.d/50-udev-default.rules contains something like:
# KERNEL=="kvm", GROUP="kvm", MODE="0660"
# and then run:
sudo gpasswd -a $USER kvm
If we see kvm:... but no username at the end, running the following command may allow KVM access:
sudo gpasswd -a $USER kvm
You may need to log out and back in for changes to take effect.
handleCpuAcceleration: feature check for hvf
emulator: ERROR: x86 emulation currently requires hardware acceleration!
CPU acceleration status: This user doesn't have permissions to use KVM (/dev/kvm).
The KVM line in /etc/group is: [kvm:x:108:davisj]
If the current user has KVM permissions,
the KVM line in /etc/group should end with ":" followed by your username.
If we see LINE_NOT_FOUND, the
More info on configuring VM acceleration on Linux:
https://developer.android.com/studio/run/emulator-acceleration#vm-linux
General information on acceleration: https://developer.android.com/studio/run/emulator-acceleration.
Permissions on /dev/kvm is currently (incorrect group and permissions):
$ ls -l /dev/kvm
crw------- 1 root root 10, 232 Jul 5 13:27 /dev/kvm
This should ideally be:
crw-rw---- 1 root kvm 10, 232 Jul 5 13:27 /dev/kvm
Manually changing it helps boot up the emulator. However, the settings are reverted on restart.
sudo chgrp kvm /dev/kvm
sudo chmod g+rw /dev/kvm
Looks like the correct permissions are part of udev defaults but this is not getting applied on WSL: https://github.com/microsoft/WSL/issues/4193#issuecomment-646991317 (#4193)
KERNEL=="kvm", GROUP="kvm", MODE="0660", OPTIONS+="static_node=kvm"
This is causing issues with React Native development on WSL where the manual step is required on every boot. #6929
The issue is reproducible on Windows 10 21H1 builds as well.
Expected Behavior
Permissions on /dev/kvm should be as follows:
crw-rw---- 1 root kvm 10, 232 Jul 5 13:27 /dev/kvm
Actual Behavior
Current permissions on /dev/kvm:
crw------- 1 root root 10, 232 Jul 5 13:27 /dev/kvm
Diagnostic Logs
No response
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 15
For anyone who comes across this, I wanted to add that this works if you change
lvmtokvm, which I assume was a typo.That’s expected, WSL2 doesn’t have udev.
You can use wsl.conf to change those permissions at boot time with something like this though:
This issue seem to be fixed in WSL from Windows Store if systemd is enabled.
So, you have to enabled systemd in wsl.conf file.
If you still see the incorrect permissions error add your user to the
kvmgroup and restart WSL.