Skip to content

Instantly share code, notes, and snippets.

@startergo
Last active October 25, 2025 19:50
Show Gist options
  • Select an option

  • Save startergo/4428c78ace77d229357b4a205f38a57a to your computer and use it in GitHub Desktop.

Select an option

Save startergo/4428c78ace77d229357b4a205f38a57a to your computer and use it in GitHub Desktop.
KVM on WSL2 Windows 11
  • In WSL2 run:
sudo apt update
sudo apt install qemu qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils cpu-checker network-manager
sudo apt install virt-manager
sudo addgroup kvm
sudo adduser `id -un` libvirt
sudo adduser `id -un` kvm
newgrp libvirt

https://medium.com/codemonday/setup-virt-manager-qemu-libvert-and-kvm-on-ubuntu-20-04-fa448bdecde3

  • Change the default group of /dev/kvm:
sudo nano /etc/wsl.conf

In the file /etc/wsl.conf add these lines:

[boot]
command = /bin/bash -c 'chown -v root:kvm /dev/kvm && chmod 660 /dev/kvm'
  • Enable nested virtualization. Create .wslcongfig.

  • Add this section to the .wslconfig file

[wsl2]
nestedVirtualization=true
  • Restart WSL:
wsl.exe --shutdown
  • Got an error:
Setting up udev (252.22-1~deb12u1) ...
addgroup: The group `kvm' already exists and is not a system group. Exiting.
dpkg: error processing package udev (--configure):
 installed udev package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mdevctl:
 mdevctl depends on udev; however:
  Package udev is not configured yet.
  • It can be fixed with:
 sudo mv /var/lib/dpkg/info/udev.postinst /var/lib/dpkg/info/udev.postinst.backup
  • If you get:
/sbin/ldconfig.real: /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link
  • Then, in WSL the primary fix seems to be to delete libcuda.so and libcuda.so.1 from C:\Windows\System32\lxss\lib as an Administrator in Windows (not from WSL):
cd C:\Windows\System32\lxss\lib && del libcuda.so && del libcuda.so.1 && mklink libcuda.so libcuda.so.1.1 && mklink libcuda.so.1 libcuda.so.1.1
export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0
export LIBGL_ALWAYS_INDIRECT=1
@NikoSoft12
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment