Skip to content

Instantly share code, notes, and snippets.

@tdcosta100
Last active January 25, 2026 03:37
Show Gist options
  • Select an option

  • Save tdcosta100/e28636c216515ca88d1f2e7a2e188912 to your computer and use it in GitHub Desktop.

Select an option

Save tdcosta100/e28636c216515ca88d1f2e7a2e188912 to your computer and use it in GitHub Desktop.
A tutorial to use GUI in WSL2/WSLg replacing original Xorg by Xwayland, allowing WSL to work like native Linux, including login screen

Full desktop shell in WSL2 using WSLg (XWayland)

Note

If you want to use Wayland in WSLg in a simpler setup, you can try the WSLg (Wayland) tutorial.

In this tutorial, we will setup GUI in WSL2. No additional software outside WSL (like VcXsrv or GWSL) is required. You will find this tutorial very similar to the one that replaces Xorg with Xvnc. Indeed, it's pretty much the same tutorial, with some few changes.

The key component we need to install is the desktop metapackage you want (GNOME, KDE, Xfce, Budgie, etc), and after that, replace the default Xorg by a script that calls Xwayland instead.

For this setup, I will use Ubuntu 24.04, and install GNOME Desktop. Unfortunately older versions of Ubuntu lack some fundamental things, so we cannot reproduce it in older versions (at least not fully). Since the key components aren't bound to Ubuntu or GNOME, you can use your favorite distro and GUI. Check the Sample screenshots section for examples.

So let's go. First, we need a working WSL2 installation.

Warning

WSLg may not work as expected, since Wayland sockets are disabled for everyone, and not every app can handle this. But if you want to use Wayland apps natively, you can use the command export XDG_RUNTIME_DIR=$HOME/runtime-dir and then start your WSLg app.

Before going to real business, let's make sure we are updated.

sudo apt update
sudo apt upgrade

You also need to make sure /etc/wsl.conf have the following lines:

[boot]
systemd=true

If not, create/edit this file, add these lines and restart WSL (for example, using wsl.exe --shutdown, then reopening the distro terminal).

Now we are ready to go.

Installing components

Installing GUI

  1. First you select your favorite desktop environment metapackage. Here is a list of the most common metapackages:

    DistroDesktop EnvironmentMetapackage
    UbuntuBudgieubuntu-budgie-desktop (currently very buggy, I don't recommend using it)
    GNOMEubuntu-desktop
    KDEkubuntu-desktop
    Kylinubuntukylin-desktop
    LXDElubuntu-desktop
    MATEubuntu-mate-desktop
    Studioubuntustudio-desktop
    Unityubuntu-unity-desktop
    Xfcexubuntu-desktop
    Ubuntu/DebianCinnamontask-cinnamon-desktop
    GNOMEtask-gnome-desktop
    GNOME Flashbacktask-gnome-flashback-desktop
    KDE Plasmatask-kde-desktop
    LXDEtask-lxde-desktop
    LXQttask-lxqt-desktop
    MATEtask-mate-desktop
    Xfcetask-xfce-desktop
  2. Once you have chosen the metapackage, let's install it. For example, if you choose ubuntu-desktop, the command will be:

    sudo apt install ubuntu-desktop xwayland
    

    This will install the ubuntu-desktop and xwayland (if not already included as dependency for your metapackage). The installation will take a while, so be patient.

  3. If in Ubuntu, you may want to install snap-store. If you don't need it, you can skip this step:

    sudo snap install snap-store
    

Configuring the environment

If you are using Debian, you need to configure the locale (this is not needed in Ubuntu):

echo "LANG=en_US.UTF-8" | sudo tee -a /etc/default/locale

Create and modify services

  1. Now we have everything installed, we need to fix the directory /tmp/.X11-unix/, because it's mounted as read-only by default. We will create a new systemd unit:

    sudo systemctl edit --full --force wslg-fix.service
    
  2. Paste the code below in the editor:

    [Unit]
    After=wslg.service
    
    [Service]
    Type=oneshot
    ExecStart=-/usr/bin/umount /tmp/.X11-unix
    ExecStart=/usr/bin/rm -rf /tmp/.X11-unix
    ExecStart=/usr/bin/mkdir -m 1777 /tmp/.X11-unix
    ExecStart=/usr/bin/ln -s /mnt/wslg/.X11-unix/X0 /tmp/.X11-unix/X0
    ExecStart=/usr/bin/chmod 0666 /mnt/wslg/runtime-dir/wayland-0.lock
    
    [Install]
    WantedBy=multi-user.target
    
  3. Exit the editor saving the changes to the file.

  4. Let's enable wslg-fix.service:

    sudo systemctl enable wslg-fix.service
    
  5. We also need to remove all references to Wayland, because if not, some apps (gnome-terminal, for example) will open outside the desktop shell. We will mask the wslg-session service:

    sudo ln -s /dev/null /etc/systemd/user/wslg-session.service
    
  6. We must disable the acceleration check, because gnome-session will refuse to start:

    sudo sed -i 's/gnome-session-binary/gnome-session-binary --disable-acceleration-check/' /usr/bin/gnome-session
    
  7. Now we will change the default startup target, because if not, a shell window will appear everytime you start your distro (for example, opening a Terminal of your distro in Windows).

    sudo systemctl set-default multi-user.target
    

Replacing default Xorg by XWayland

By default, the display manager call multiple Xorg instances, one for each user session, including the login screen, provided by GDM (if you are using the GDM as your display manager, of course). So we will replace Xorg script by a new version which calls Xwayland instead the classic Xorg. This is the real magic we are trying to do.

  1. First, we create a new Xorg script.

    sudo nano /usr/bin/Xorg.Xwayland
    
  2. Paste the code below in the editor:

    #!/bin/bash
    for arg do
      shift
      case $arg in
        # Xwayland doesn't support vtxx argument. So we convert to ttyxx instead
        vt*)
          set -- "$@" "${arg//vt/tty}"
          ;;
        # -keeptty is not supported at all by Xwayland
        -keeptty)
          ;;
        # -novtswitch is not supported at all by Xwayland
        -novtswitch)
          ;;
        # other arguments are kept intact
        *)
          set -- "$@" "$arg"
          ;;
      esac
    done
    
    # Check if the runtime dir is present, and create it if not
    if [ ! -d $HOME/runtime-dir ]
    then
     mkdir $HOME/runtime-dir
     ln -s /mnt/wslg/runtime-dir/wayland-0 /mnt/wslg/runtime-dir/wayland-0.lock $HOME/runtime-dir/
    fi
    
    # Point the XDG_RUNTIME_DIR variable to $HOME/runtime-dir
    export XDG_RUNTIME_DIR=$HOME/runtime-dir
    
    # Find an available display number
    for displayNumber in $(seq 1 100)
    do
      [ ! -e /tmp/.X11-unix/X$displayNumber ] && break
    done
    
    # Here you can change or add options to fit your needs
    command=("/usr/bin/Xwayland" ":${displayNumber}" "-geometry" "1920x1080" "-fullscreen" "$@")
    
    systemd-cat -t /usr/bin/Xorg echo "Starting Xwayland:" "${command[@]}"
    
    exec "${command[@]}"
    

    Please note the resolution of the virtual screen. You can change that to fit your needs (1366x768, 3840x2160, etc).

  3. Exit the editor saving the changes.

  4. Finally, we set the correct permissions for the file and create a link to it after renaming the original Xorg:

    sudo chmod 0755 /usr/bin/Xorg.Xwayland
    sudo dpkg-divert --local --add --rename /usr/bin/Xorg
    sudo update-alternatives --install /usr/bin/Xorg Xorg /usr/bin/Xorg.Xwayland 100
    

Configuring the monitor resolution under GDM and GNOME

Currently, one of the annoying things is the resolution of Xwayland. Even with the -geometry switch, GDM and GNOME don't not respect it. Fortunately, this can be overriden by creating a monitors.xml file. Let's do it then.

  1. First, we create it in the current user directory:

    mkdir ~/.config
    nano ~/.config/monitors.xml
    
  2. Paste the code below in the editor (here it is configured for a 1920x1080 resolution, so change it to reflect your resolution if necessary):

    <monitors version="2">
      <configuration>
        <logicalmonitor>
          <x>0</x>
          <y>0</y>
          <scale>1</scale>
          <primary>yes</primary>
          <monitor>
            <monitorspec>
              <connector>XWAYLAND0</connector>
              <vendor>unknown</vendor>
              <product>unknown</product>
              <serial>unknown</serial>
            </monitorspec>
            <mode>
              <width>1920</width>
              <height>1080</height>
              <rate>59.963</rate>
            </mode>
          </monitor>
        </logicalmonitor>
      </configuration>
    </monitors>
  3. Exit the editor saving the changes to the file.

  4. Now let's copy this file to GDM's home directory:

    sudo mkdir /var/lib/gdm3/.config
    sudo cp ~/.config/monitors.xml /var/lib/gdm3/.config/
    
  5. Finally, we set the correct permissions to the monitors.xml of GDM user:

    sudo chown -R gdm:gdm /var/lib/gdm3/.config/
    
  6. Restart WSL using wsl.exe --shutdown, then reopen your distro terminal.

Running your distro with GUI enabled

Now you have everything ready to start. Just do the following command:

sudo systemctl start graphical.target

After a while (usually a few seconds, but it can take more if you don't have a SSD), the login screen must appear.

After logging in, the logged user's desktop must appear. When you log out, the screen will show the login interface again. This applies to GDM (which is the case if you installed Ubuntu Desktop). In GDM, you can change this behavior changing the configuration file like this:

  1. sudo nano /etc/gdm3/custom.conf

  2. Uncomment and edit the following lines:

     AutomaticLoginEnable=true
     AutomaticLogin=[your username without the brackets]
    

Shutting down

One important thing is: once you start your WSL instance, you cannot just stop it. You must perform a standard Linux shutdown. You can do one of the alternatives below:

  • Power off option on GUI menu
  • sudo poweroff

After doing that, you can safely shut down your WSL instance, either by wsl.exe --terminate or wsl.exe --shutdown. Not doing the shutdown process may cause damage to your WSL instance. So be careful.

Troubleshooting

  1. If it doesn't work at first, try to check your journalctl logs:

    journalctl -b -t /usr/lib/gdm3/gdm-x-session -t /usr/bin/Xorg --no-pager
    

    If you are using Debian, then the command is:

    journalctl -b -t /usr/libexec/gdm-x-session -t /usr/bin/Xorg --no-pager
    

    In the output, you must see what command line was generated for Xwayland, and which error messages appear. Of course, even if it works correctly, you can check the logs just to see what is happening, or for debugging.

  2. You must check if the custom Xorg script was not replaced by the default version of it. If it was the case, just repeat the steps of Replacing default Xorg by Xwayland section.

  3. Check if Xorg is your default display server, not Xephyr or Wayland. If it's not, you must change it to have Xorg as your default display server.

  4. If you are using LightDM, you also need to check logs at /var/log/lightdm (you will need to use sudo to cat files in that directory). The Xwayland output will be in the file /var/log/lightdm/x-0.log.

  5. If it still doesn't work, you can try to restart WSL with wsl.exe --shutdown (don't forget to save everything that is unsaved before, because WSL will shut down completely), then open your distro terminal again and repeat the steps of section Running your distro with GUI enabled.

Sample screenshots

GDM

GDM

LightDM (Kubuntu)

LightDM

GNOME

GNOME

KDE (Kubuntu)

KDE

LXDE (Lubuntu)

LXDE

Xfce (Xubuntu)

Xfce

Contributors

Thanks to this guys, whose feedback made this tutorial reach the current level of quality and completeness (and it will be more and more complete as more feedback is given).

@bakamake
Copy link

bakamake commented Nov 4, 2025

我不知道为什么但是在干净的ubuntu 24.04 lts 上我的gdm不能启动

@TheSystemGuy1337
Copy link

Doesn't work - login screen flashes about four times before it quits.

@lingmingxi
Copy link

lingmingxi commented Nov 10, 2025

This method does not support the latest WSL versions (2.6.1/2.6.2). If you see an "OH NO!" error, please downgrade back to version 2.5.10. Download link: https://github.com/microsoft/WSL/releases/tag/2.5.10

这个方法不支持最新的wsl版本(2.6.1\2.6.2),如果你们看到OH NO!报错,请降级回wsl 2.5.10 ,下载连接https://github.com/microsoft/WSL/releases/tag/2.5.10

You can use wsl -v to check your current WSL version.
你可以使用wsl -v 查看你现在使用的wsl版本
@TheSystemGuy1337 @bakamake @PuNkYsHuNgRy @tdcosta100

@MaMo7x
Copy link

MaMo7x commented Nov 12, 2025

Just made it work on Arch Linux with LightDM + KDE.
Though I was stuck for a while and found that it's good to set logind-check-graphical=false might be a must.

@pentaly7
Copy link

pentaly7 commented Nov 15, 2025

i am using arch linux with Full KDE Plasma desktop installed, i have follow all of your steps with using sddm.
but when i start sudo systemctl start graphical.target nothing happen.

but when i start with startx it start the desktop but all of the component is in individual window, not inside the the Xwayland desktop. do you have solution for this?

edit :
i success by running it using this script

X &

sleep 2

DISPLAY=:1 WAYLAND_DISPLAY= startplasma-x11

@ienwb
Copy link

ienwb commented Nov 15, 2025

@lingmingxi
Is downgrade possible without reinstall in wsl, how?

edit
I got the same error, latest wsl version.

@tdcosta100
Copy link
Author

Hi guys. I updated the tutorial for the last version of WSL. Now we have to mask the user service wslg-session.service and add the --disable-acceleration-check switch to the gnome-session command.

@ienwb
Copy link

ienwb commented Nov 17, 2025

Any plan to add more* DE tutorial besides ubuntu gnome, e.g., Kubuntu? IK arch wiki has some of the display manager info but it warrants a lot of self research and time. Take your time, im currently on a new kubuntu install, my ubuntu gnome has some errors from wsl first try. Thank you for the update.

Edit:
Spellings

Edit 2:
I might make a feature request of this guide into a wsl command by posting the issue in wsl github repo, or posting it to each DE flavor support team eg kubuntu repo issue, GNOME, xfce. If anyone got the time feel free to make a feature request out of this. This guide with GPU pass-through if m$ ever implemented it would mean WSL is close to r/linux_gaming specification. GPU pass-through and the year of linux DE on wsl.

@tdcosta100
Copy link
Author

Currently I'm overwhelmed by my work demands, so I cannot promise anything but the maintenance of this tutorial for now. But I want to add more supporting DEs as much as possible.

While I was testing the tutorial (yes, I recreate everything from scratch to guarantee everything is fine) I faced some errors too. Some gnome-shell services are not correctly detected as active, maybe caused by a race condition. Anyway, I started my PC now and while I'm writing this message, everything is working as intended, so maybe for others this will happen too.

Since I created this tutorial, I think how beneficial would be a better architecture for WSLg, where the GPU were presented as a device inside WSL, and on the Windows side it would be possible to choose wether I want separate windows, or surfaces for each virtual screen, allowing Desktop Environments to be present.

The way it is set now, we are seeing through RDP connections. This is very slow compared to direct rendering, so it's a huge bottleneck. Maybe a redesign will come in the future, I hope so.

@ienwb
Copy link

ienwb commented Nov 19, 2025

I'm gonna report this as feature request to Microsoft, and other DE companies, eg kubuntu team, ubuntu gnome team, so that the workload are shared between company and community devs. after i got more free time, currently busy on other paper.
Thanks for your continuous support on updating this.🙏🏽🙏🏽🙏🏽 @tdcosta100
this is basically a pioneer on WSL as GUI desktop environment besides the default server usage.

as to not burden you anymore, im gonna reinstall with gnome ubuntu, kde could wait, take your time king.

edit 1:
yeah linux philosophy if implemented fully would mean, gpu passthrough means the gpu is presented as physical device or could be accessed from wsl. the way i see this atm, only app like CUDA has accel, other apps dont have accel.

@Kyant0
Copy link

Kyant0 commented Nov 23, 2025

Not work

@priamfive
Copy link

This now works again for me - many thanks for all your work.

@krad213
Copy link

krad213 commented Dec 3, 2025

Sound with ubuntu-desktop doesn't work (it works when I start GUI apps from WLS CLI), is there any way to fi this, or maybe there is other environment where it works ?

@tdcosta100
Copy link
Author

There are some suggested solutions, but unfortunately none of them are very effective for now. Yet, I accept suggestions.

@tling0001
Copy link

It doesn't at all in development daily build ubuntu 26.04 wsl2. No screen shows up at all and no black screen. Nothing happens when you run sudo systemctl start graphical.target

@tling0001
Copy link

I installed Flatpak in Ubuntu 24.04 and now Ubuntu won't get past the login screen. It shows infinite black screen.

@tling0001
Copy link

Actually, it just took a lot longer. Like over half an hour.

@tling0001
Copy link

Just twice

@linghengqian
Copy link

I noticed that Nov 17, 2025 made a change to sudo systemctl edit --full --force wslg-fix.service, changing

ExecStart=/usr/bin/ln -s /mnt/wslg/.X11-unix/X0 /tmp/.X11-unix/X0
ExecStart=/usr/bin/chmod 0777 /mnt/wslg/runtime-dir
ExecStart=/usr/bin/chmod 0666 /mnt/wslg/runtime-dir/wayland-0.lock

to

ExecStart=/usr/bin/ln -s /mnt/wslg/.X11-unix/X0 /tmp/.   X11-unix/X0
ExecStart=/usr/bin/chmod 0666 /mnt/wslg/runtime-dir/wayland-0.   lock

I would say I'm curious why there's a space between /mnt/wslg/runtime-dir/wayland-0. and lock. The combination of /tmp/. and X11-unix/X0 is also strange.

@tdcosta100
Copy link
Author

That space was a mistake. I fixed it. The .X11-unix in /tmp is how the X11 works.

@terrex
Copy link

terrex commented Jan 7, 2026

Thanks for your instructions, it worked for me!

But, how can I share the same clipboard between windows and gnome ? thank you.

@tdcosta100
Copy link
Author

Some solutions were proposed, none of them are flawless but at least one might work for you. I don't remember which tutorial has this comment, sorry. But if you look at the comments in this tutorial and others, you will find it.

@jkuehnis
Copy link

is there also a guide for KDE? some of these commands are only for GNOME/GDM.
I'm using Debian 13, desktop works already and i managed to get the windows to works inside of the desktop and not outside of the desktop.

im currently struggling to change the scaling for the desktop (e.g. FullScreen or change it to a bigger window than 1024x768)
and my next question will bee, is there a way to copy paste text into the desktop from the Windows Session?

@aleda86bbl
Copy link

aleda86bbl commented Jan 19, 2026

With regards to no audio when running the GNOME desktop, a workaround that worked for me is to create a script that launched gnome-session first and then kill it before staring the GUI.

# Hack to get audio working
gnome-session &
gnome_session_pid=$!
sleep 3
kill -9 $gnome_session_pid
# Start the Desktop
systemctl start graphical.target

When this script is run, RDP sink shows up instead of Dummy Output for me in sound settings.

I don't know the exact mechanism for why it works it was just discovered by accident. Maybe someone can find a more elegant solution.

Update:

I masked the pulse service and socket and removed and relinked the XDG_RUNTIME_DIR/pulse directory. Audio now works like a charm. The only thing left is multi monitor support. Thanks for the great tutorial.

@aleda86bbl
Copy link

I have a dual monitor setup, the tutorial shows the setup for a single monitor. Does anyone know how to get the GUI to display correctly accross two monitors?

@aleda86bbl
Copy link

Just some extra logging for anyone out there who might have some ideas:

When I use xrandr in WSL2 (outside of Ubuntu Desktop 24.04) I am getting the following output:

XWAYLAND0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1920x1080     59.96*+
   1440x1080     59.99
   1400x1050     59.98
   1280x1024     59.89
   1280x960      59.94
   1152x864      59.96
   1024x768      59.92
   800x600       59.86
   640x480       59.38
   320x240       59.52
   1680x1050     59.95
   1440x900      59.89
   1280x800      59.81
   720x480       59.71
   640x400       59.95
   320x200       58.96
   1600x900      59.95
   1368x768      59.88
   1280x720      59.86
   1024x576      59.90
   864x486       59.92
   720x400       59.55
   640x350       59.77
XWAYLAND1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 508mm x 286mm
   1920x1080     59.96*+
   1440x1080     59.99
   1400x1050     59.98
   1280x1024     59.89
   1280x960      59.94
   1152x864      59.96
   1024x768      59.92
   800x600       59.86
   640x480       59.38
   320x240       59.52
   1680x1050     59.95
   1440x900      59.89
   1280x800      59.81
   720x480       59.71
   640x400       59.95
   320x200       58.96
   1600x900      59.95
   1368x768      59.88
   1280x720      59.86
   1024x576      59.90
   864x486       59.92
   720x400       59.55
   640x350       59.77

So I can see that the system is correctly detecting both outputs XWAYLAND0 AND XWAYLAND1 and SCREEN0 which spans both outputs. However when I run the same command inside a terminal running in Ubuntu Desktop 24.04 I get the following:

Screen 0: minimum 16 x 16, current 1920 x 1080, maximum 32767 x 32767
XWAYLAND0 connected primary 1920x1080+0+0 1016mm x 285mm
   5120x2880     59.99 +
   4096x2304     59.99  
   3840x2160     59.98  
   3840x1080     59.96  
   3200x1800     59.96  
   2880x1620     59.96  
   2560x1600     59.99  
   2560x1440     59.96  
   2048x1536     59.95  
   2048x1152     59.90  
   1920x1440     59.97  
   1920x1200     59.88  
   1920x1080     59.96* 
   1680x1050     59.95  
   1600x1200     59.87  
   1600x900      59.95  
   1440x1080     59.99  
   1440x900      59.89  
   1400x1050     59.98  
   1368x768      59.88  
   1280x1024     59.89  
   1280x960      59.94  
   1280x800      59.81  
   1280x720      59.86  
   1152x864      59.96  
   1152x720      59.97  
   1024x768      59.92  
   1024x576      59.90  
   960x600       59.63  
   928x580       59.88  
   864x486       59.92  
   800x600       59.86  
   800x500       59.50  
   768x480       59.90  
   720x480       59.71  
   720x400       59.55  
   640x480       59.38  
   640x400       59.95  
   640x350       59.77  
   320x240       59.52  
   320x200       58.96

I get some crazy large resolutions and only one output, XWAYLAND0. So it seems as if both outputs are not being correctly passed to Ubuntu Desktop. I rembmer that this worked "out of the box" when I was using Ubuntu 22.04 and Xwayland but that was a different tutorial that allowed me to start up the desktop doing something like this:

Xwayland :1 &
xw_pid=$!
WAYLAND_DISPLAY=
gnome-session --session=ubuntu
kill $xw_pid

But I have not been successful in replicating the old tutorial with Ubuntu 24.04.

I am currently using a workaround to stretch the screen manually using xrandr to fill both screens 3480x1080 but this has its disadvantages because:

  1. Maximisation of window covers both monitors.
  2. Pop up windows show up in the middle of both monitors
  3. Doesn't detect change of resolution when unplugging my laptop to the external screen.

This all worked with the old tutorial + Ubuntu 22.04 but I haven't been able to locate it.

If anyone has any ideas, let me know. I'll also post any discoveries here on my end.

@aleda86bbl
Copy link

I did a fresh installation of Ubuntu 22.04 WSL2 and followed the tutorial once more.
The only changes were that I had to do were to disable ACPI service from being set up and installed by doing

sudo apt-mark hold acpid acpi-support

As well as disabling the acpid service

sudo systemctl mask acpid.service

I also removed all the -geometry and -fullscreen flags from the Xwayland command in Xorg.Xwayland file
I also made sure to install the full ubuntu desktop and not the minimal desktop. I noticed that a lot of drivers are installed in the full desktop setup.

When I booted up the GUI I got both screens running correctly in GNOME AND it now detects the onboard Intel Graphics GPU as well (it was always CPU rendering in my past setup) which is truly awesome. GUI animations are active and everything is silky smooth.

Ideally I'll hope to get this working on 24.04. I don't know exactly why this works (it could be drivers or different versions of different components playing nice with my laptop hardware). Either way I have a barebones setup that I can now use for reference :).

@tling0001
Copy link

In Ubuntu 24, you have to downgrade Mesa drivers from 25 to Mesa 23 to get accelerated GPU rendering with opengl. Run

sudo tee /etc/apt/sources.list > /dev/null << 'EOF' deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse deb [arch=amd64] http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse EOF

sudo apt update

sudo apt install libegl1-mesa/jammy libegl-mesa0/jammy libglapi-mesa/jammy libgbm1/jammy libgl1-mesa-dri/jammy libllvm13/jammy libglx-mesa0/jammy

@aleda86bbl
Copy link

aleda86bbl commented Jan 24, 2026

@tling0001 Thanks for the tip, I have tried it out and yes I do get GPU rendering on Ubuntu 24 when downgrading the Mesa drivers. That is really useful to know.

As for Xwayland/Multiple screen behaviour sadly it still exhibits the same behaviour (large/wrong resolution and single monitor output detection). I highly suspect that something is off with the way Xwayland version in Ubuntu 24.04 works with WSL2 and passes on that information to the Ubuntu Desktop.

I tried to downgrade the whole ubuntu-desktop / xwayland to jammy (22.04) ontop of 24.04 but my APT package manager was having none of it.

I really wanted to upgrade to 24.04 and maintain all functionality but looks like I will go back to 22.04 for now. I really need my multi-monitor setup.

@linghengqian
Copy link

linghengqian commented Jan 24, 2026

In Ubuntu 24, you have to downgrade Mesa drivers from 25 to Mesa 23 to get accelerated GPU rendering with opengl.

  • @tling0001 The decision to downgrade Mesa seems rather strange. Unless you happen to be using software that only supports the Vulkan API and not the OpenGL API. Are you using Steam under WSLg and have installed some games that can only be played through Wine?

Thanks for the tip, I have tried it out and yes I do get GPU rendering on Ubuntu 24 when downgrading the Mesa drivers. That is really useful to know.

  • @aleda86bbl If you know that WSL's OpenGL Renderer is using the CPU via glxinfo -B, then you probably haven't performed the following operation within Ubuntu 24.04 WSL's bash:
sudo tee /etc/profile.d/myenvvars.sh <<EOF
export GALLIUM_DRIVER="d3d12"
EOF

sudo tee --append /etc/environment <<EOF
GALLIUM_DRIVER="d3d12"
EOF
  • Then, in Windows PowerShell 7, execute wsl --terminate Ubuntu-24.04 or wsl --shutdown, and restarting Ubuntu should then enable GPU acceleration.

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