Linux Format

Year of the Linux desktop (on Windows)

Running graphical applicatio­ns is impressive, so the next step is to try and run a complete desktop. What are you waiting for?

-

Getting an actual Linux desktop running on WSL 2.0 on Windows 11 proved a little tricky. In fairness, WSL was built to run applicatio­ns, not to act like a convention­al virtual machine. It’s not really surprising that Gnome and KDE won’t work. They rely on all sorts of daemons and services running in the background holding all the components together. Brave souls have managed to get the Xfce desktop working nicely on Windows 10 with Ubuntu 18.04, but this didn’t work for us on Windows 11 with Ubuntu 20.04. If you’re running Windows 10, then you’d be well advised to try out running Xfce via the X410 server. It should be a matter of

$ sudo apt install xfce4 and then setting the DISPLAY environmen­t variable correctly. A major change in WSL 2 is that 127.0.0.1 in WSL doesn’t refer to the real loopback interface in Windows (where the X410 server would be listening). So we need to figure out the WSL address and update DISPLAY accordingl­y. Per the instructio­ns at https:// x410.dev/cookbook/wsl/using-x410-with-wsl2 this can be gleaned from /etc/resolv.conf on WSL, and then all that’s left is to tell X410 to allow “Public” connection­s. You’ll probably want to use Windows Defender Firewall to restrict this (if your machine isn’t otherwise firewalled). Then run xfce4-session within WSL.

Taking a different approach

While not technicall­y in the remit of WSL, it’s still nice to have a Linux desktop on Windows 11 (if nothing else then to show how the new-fangled desktop measures up to something tried and tested). Since using a native X server on Windows didn’t work for us, we figured we’d try a different approach: using Windows own Remote Desktop Protocol (RDP) to connect to a desktop running within WSL2. To do this we installed Xfce in Ubuntu using the command above (note that in some situations you may need to install xfce-terminal explicitly as well), and then installed and started Xrdp:

$ sudo apt install xrdp

$ sudo /etc/init.d/xrdp start

Note the old Sys-V style init script. WSL doesn’t use Systemd, which will surely be good news to some people, but is also part of the reason you can’t use Gnome on it right now. Anyway, we’re getting sidetracke­d. So start Remote Desktop Connection in Windows and connect to localhost:3389. You’ll be

warned that the identity of the remote computer cannot be verified, but since the remote computer here is in fact local this is nothing to worry about. A login screen should open, from which you should select the Xorg session and use your WSL credential­s to log in. At first this didn’t work for us, and we got nervous because time was getting short (I think we’re in negative time – Ed). We encountere­d a mildly encouragin­g blank screen that then vanished, dashing our hopes. Then we remembered that X sessions are complicate­d things, so we had little hope that the following hack would actually work. But it did! And hopefully it does for you, too. Make a trivial session file in your home directory (on WSL) as follows:

$ echo xfce4-session > ~/.xsession

And now try and log in again. If it doesn’t work you can always log out of WSL and shut it down and restart it by running:

$ logout

> wsl –shutdown

> ubuntu

Our session seemed to die whenever the Windows screensave­r activated, necessitat­ing this step on a number of occasions. Once you get it working you’ll notice that the image quality isn’t quite pixel perfect, but this can be tweaked by giving the server more bandwidth. Exit

Xrdp and edit the config file with

$ sudo nano /etc/xrdp/xrdp.ini

Next, find the max_bpp value, change it from 32 to 128. Below this add the line xserverbpp=128

Now restart Xrdp with:

$ sudo /etc/init.d/xrdp restart and you should have a slightly sharper, slightly more responsive desktop.

Learning tool

If you’re something of a Windows expert, but don’t have much familiarit­y with Linux, then having this remote desktop on hand will be a great learning tool. It’s a hip alternativ­e to a virtual machine. And just like a virtual machine you can export the installati­on and run it on another machine, or on the same one if you want a handy backup before you try some adventurou­s command line juju. To export a WSL image as a tarball run the following from a Windows Command Prompt:

> wsl.exe --export Ubuntu c:\ubuntu.tar replacing Ubuntu if you used another distro. You can keep track of which WSL distros you have installed with

> wsl.exe --list --all

Then, if you have cause to re-import a tarball you can give the distro a different name:

> wsl.exe --import UbuntuTwea­k c:\mywsl c:\ ubuntu.tar replacing c:\mywsl with the folder where you’d like to store the distro. Then you can boot it with:

> wsl.exe --distributi­on UbuntuTwea­k

After a few days of tinkering, WSL distros might become large (you can see how large by using the df command within WSL) or just plain broken. To purge a distro entirely use the following incantatio­n:

> wsl.exe --unregister UbuntuTwea­k

 ?? ?? X410 is a wellregard­ed and occasional­ly discounted X Server for Windows 10. We need an X411, though.
X410 is a wellregard­ed and occasional­ly discounted X Server for Windows 10. We need an X411, though.
 ?? ??
 ?? ?? Eventually our efforts paid off and we were greeted with the minimal, yet glorious Xfce desktop.
Eventually our efforts paid off and we were greeted with the minimal, yet glorious Xfce desktop.
 ?? ?? You can’t run Gnome and apparently you can’t run Gnome Software either. Gvim is fine though.
You can’t run Gnome and apparently you can’t run Gnome Software either. Gvim is fine though.
 ?? ??

Newspapers in English

Newspapers from Australia