- In WSL2 run:
sudo apt update
sudo apt install qemu qemu-kvm bridge-utils cpu-checker
sudo apt install virt-manager
sudo addgroup kvm
sudo usermod -a -G kvm ${USER}
- 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
.wslconfigfile
[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
Thanks!