1

xeyes and git citool are working but I can not start ubuntu-desktop. Tried

startx

or

sudo startx

but error message reads: no screens found(EE)

Is is possible at all to make the ubuntu-desktop run with vcxsrv on Windows 10 Pro? Did search the internet for hours but can not find solution.

gute Fee
  • 13
  • 3

1 Answers1

0

Before I get started, let me just say "Don't do that" ;-). I've done it, and I'll tell you how to do it, but ... just don't. I'll cover why as we get into the answer.

There's an "easy part" to your answering your question and, well ... The hard part.

Let's cover the two main problems:

The easy part

First, by issuing startx, you are attempting to start the X server in Linux. You've actually already done that by running VcXsrv. What you really need at this point is the session manager -- That's gnome-session. That's the easy part.

The hard part

The hard part is that Gnome (and thus Ubuntu Desktop) really requires Systemd. WSL doesn't support Systemd, at least not without a lot of hackery. That hackery changes the way a lot of things work in WSL. You should be comfortable diving fairly deep into the internals of WSL, Linux, and Systemd in order to troubleshoot things that "go wrong".

While there are projects out there that attempt to do this hackery for you, I still recommend having some understanding of the hows and whys of the changes being made to your WSL instance.

So, at a very high-level, I'm going to cover some of that here.

Some alternatives

But let me first offer a few alternatives to running Ubuntu Desktop on WSL:

  • If you really want a Linux desktop experience on WSL, go with one that doesn't require Systemd, such as Xfce4.
  • If you really want Ubuntu Desktop/Gnome on Windows, then run it in a VM. You'll give up the tight integration with Windows that WSL provides, but you'll have an Ubuntu with a fully supported Systemd.

Ok, so now that I've tried to talk you out it and failed ... ;-)

How to run Systemd on WSL2, allowing you to run Ubuntu Desktop on VcXsrv

Let's cover some of the projects that "help" you run Systemd on WSL:

And I'll also point out that Genie is used for these instructions on running Ubuntu Desktop.

If you'd like to skip the rest of this, you can go straight to those instructions. Or, I can show you the "quick and dirty" way of getting up and running. You can then decide if you want to go through the full setup.

Ultimately, what all of these do is create a new namespace in WSL/Linux where Systemd can run as PID1.

You can see this (and get Ubuntu Desktop running quickly) by executing:

sudo -b unshare --pid --fork --mount-proc /lib/systemd/systemd --system-unit=multi-user.target

This starts Systemd in a new namespace with its own PID mapping. Inside that namespace, Systemd will be PID1 (as it must, to function) and own all other processes. However, the "real" PID mapping still exists outside that namespace.

Note that this is a "bare minimum" command-line for starting Systemd. It will not have support for, at least:

  • Windows Interop (the ability to run Windows .exe)
  • The Windows PATH (which isn't necessary without Windows Interop anyway)

The scripts and projects listed above do extra work to get these things working as well.

Wait a few seconds for Systemd to start up, then:

sudo -E nsenter --all -t $(pgrep -xo systemd) runuser -P -l $USER -c "exec $SHELL"

This enters the namespace, and you can now use ps -efH to see that systemd is running as PID 1 in that namespace.

At that point, there's enough of Systemd running and configured to run gnome-session and have it connect to VcXsrv. It might take a few minutes to start up, though.

Note that after trying this out, you really should exit WSL, issue a wsl --terminate <distroname> and restart it. Otherwise there are a number of things that just won't work in the meantime.

Again, to do this "better", use one of the scripts/projects listed above. They will attempt to set the environment variables, sockets, and symlinks inside that namespace to allow things to function more properly.

NotTheDr01ds
  • 3,321
  • 1
  • 5
  • 28