- In WSL2 run: ``` sudo apt update sudo apt install qemu qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils cpu-checker \ network-manager iptables-persistent linux-headers-generic \ qemu uml-utilities virt-manager git \ wget libguestfs-tools p7zip-full make dmg2img tesseract-ocr \ tesseract-ocr-eng genisoimage vim net-tools screen firewalld libncurses-dev -y 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 - To enable systemd: ``` sudo nano /etc/wsl.conf ``` In the file `/etc/wsl.conf` add these lines: ``` [boot] systemd=true ``` - Enable nested virtualization. Create [.wslcongfig](https://learn.microsoft.com/en-us/windows/wsl/wsl-config#wslconfig). - 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 ``` - Install [Nvidia CUDA WSL drivers](https://docs.nvidia.com/cuda/wsl-user-guide/index.html) - If xfce4 is giving error run: ``` export DISPLAY=$(awk '/nameserver / {print $2; exit}' /etc/resolv.conf 2>/dev/null):0 export LIBGL_ALWAYS_INDIRECT=1 ``` - Unregister wsl `Pengwin`: ``` wsl --unregister WLinux ``` - Link Linux headers to WSL: ``` #!/bin/bash set -e WSL2_VERSION=$(uname -r) echo "WSL2_VERSION = $WSL2_VERSION" WSL2_LINK="/lib/modules/$WSL2_VERSION" if [ -L "${WSL2_LINK}" ]; then if [ -e "${WSL2_LINK}" ]; then echo "Good link" exit 0 else echo "Broken link" rm "${WSL2_LINK}" fi elif [ -e "${WSL2_LINK}" ]; then echo "Not a link" exit 1 else echo "Missing" fi shopt -s nullglob for filename in /lib/modules/*; do echo "$filename" if [ -z "$HEADERS_DIR" ]; then HEADERS_DIR="$filename" else echo "HEADERS_DIR already set to $HEADERS_DIR, fail" exit 1 fi done if [ -n "$HEADERS_DIR" ]; then echo "Create symbolic link $WSL2_LINK => $HEADERS_DIR" ln -s "$HEADERS_DIR" "$WSL2_LINK" fi ``` - [Install X410 (version3)](https://x410.dev/cookbook/wsl/using-x410-with-wsl2/). Start and configure. Run this in WSL2: ``` export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0 ``` - Enable [Web Console](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_virtualization/managing-virtual-machines-in-the-web-console_configuring-and-managing-virtualization#setting-up-the-rhel-web-console-to-manage-vms_managing-virtual-machines-in-the-web-console) - [How to use the Microsoft Linux kernel v6 on Windows Subsystem for Linux version 2 (WSL2)](https://learn.microsoft.com/en-us/community/content/wsl-user-msft-kernel-v6) ``` git clone https://github.com/microsoft/WSL2-Linux-Kernel --depth=1 cd WSL2-Linux-Kernel git checkout `uname -r` cat /proc/config.gz | gunzip > .config make prepare modules_prepare make menuconfig make modules make modules_install ```