i) CONFIGURE WINDOWS
- First, update Windows to the latest version.
- Then Install 2022-11 Cumulative Update Preview for Windows 10 22H2 for x64-based Systems (KB5020030)
- Check that your OS build is at least 19045.2311. If the second part after the period is < 2311, then you have not installed the preview and nothing will work properly. This step is crucial to get WSLg working properly.
https://support.microsoft.com/en-gb/topic/november-15-2022-kb5020030-os-builds-19042-2311-19043-2311-19044-2311-and-19045-2311-preview-237a9048-f853-4e29-a3a2-62efdbea95e2
- Go to control panel->programs->turn windows features on or off. Make sure Virtual Machine Platform is checked on.
- Go to your BIOS. Make sure virtualization is enabled in BIOS (on AMD it is called SVM)
ii) CONFIGURE UBUNTU ON WSL
[boot]
systemd=true
- Create the file /etc/pam.d/system/systemd-user
# This file is part of systemd.
#
# Used by systemd --user instances.
@include common-account
session required pam_loginuid.so
session required pam_limits.so
@include common-session-noninteractive
session optional pam_systemd.so
ubuntu-desktop tries to install acpi-support. This will literally brick your distro to an unrecoverable state, yielding a catastrophic error when you attempt to run WSL. Do not forget to add the "-" sign to tell apt to ignore this dependency otherwise you'll have to delete the distro and reinstall.
sudo systemctl stop gdm.service
Failure to prevent gdm running will cause all sorts of errors when you try to run a gnome-shell.
sudo systemctl disable gdm.service
Add the following to the system startup - it needs to be executed with elevated privileges. I enabled systemd's rc-local compatibility service and then added them to /etc/rc.local. Just be sure to chmod 700 /etc/rc.local
mount -o rw,remount /tmp/.X11-unix/
chmod +t /tmp/.X11-unix
chmod o+rw /dev/dri/renderD128
/usr/libexec/at-spi-bus-launcher --launch-immediately &
XDG_SESSION_TYPE=x11 gnome-session --disable-acceleration-check --session=ubuntu --systemd-service > /dev/null 2>&1
- Now run gnome-shell with the following command. Adapt the resolution to your preference.
MUTTER_DEBUG_DUMMY_MODE_SPECS=2400x1300 gnome-shell --nested --no-x11 2> /dev/null &
Screenshot
--disable-acceleration-check
argument from the XDG_SESSION_TYPE variable, the performance was smoother. Furthermore, the entire value of the XDG_SESSION_TYPE had to be enclosed in single quotes like so:XDG_SESSION_TYPE='x11 gnome-session --disable-acceleration-check --session=ubuntu --systemd-service > /dev/null 2>&1'
as otherwise the output redirection would happen during the login script, not the start of the session. – Martin Rüegg Feb 27 '23 at 13:30