Ubuntu 20.04 Desktop GUI on WSL 2 on Surface Pro 1

Similar Posts

42 Comments

  1. Hi, nice doc.
    Tweak SystemD-Genie for Ubuntu
    ….

    sudo nano /usr/lib/genie/deviated-preverts.conf

    This dir “/usr/lib/genie/” does not exist. Should I Create it ?
    Emmanuel

    1. It sounds like your SystemD-Genie didn’t get installed properly. I would imagine there’s little point in creating the directory.

      You could test genie to see if it did install by typing genie -s and seeing what happens. If you get an error saying it can’t be found then go back to the instructions where it says to install systemd-genie πŸ™‚

      If it doesn’t error then you could try creating the directory and see how you get on.

      Steve

      1. My mistake – for anyone else reading this, please see the edits to the article.

        This directory and the deviated-preverts.conf file is no longer required.

  2. Steveβ€” thanks for the fine, comprehensive doc.

    Like Emmanuel, my /usr/lib/genie didn’t exist. I checked the genie man page and found no mention of this directory or config file. Nonetheless, I created it, then started genie; everything fired up as expected. (Haven’t tried yet without this file.)

    The current gdm (3.34.1) is installed with XDMCP support disabled by default. The symptom is, Xlaunch produces a black screen after responding to startup dialogs. To fix, change the [xdmcp] section of /etc/gdm3/custom.conf to include “Enable=true”.

    1. Hi Jim,
      Having gone through the process again for another article and Desktop Environment under WSL2, I can confirm that the file and directory is in fact not required.

      I’ve updated the article but of course for anyone who’s already read it, here’s the answer πŸ™‚ You don’t need it πŸ™‚

      Cheers,
      Steve

  3. hmmm you say copy and paste content, but you block copy and paste… you should make your mind either remove copy/paste content that you say, or remove protection so we can copy and paste commands

      1. sorry if i offended you but i think there is nothing rudley….

        btw i did share with multiple people your post πŸ˜‰ so it will help a lot of people

        1. Hi Andre,
          All good, I’d put the content blocker on another site of mine because my content was getting ripped off and then ranking better on Google than my own stuff! I then added it here too without really thinking about whether it was even justified (it’s not really – though I’m sure someone will just copy it and pretend they wrote it one day)

          Anyway, no offence taken, thanks for coming back and thanks for sharing πŸ™‚

          All the best!

  4. Here is my ~/startup.sh wsl script that runs genie and substitutes XDMCPHost value to correct IP address in C:\config.xlaunch every time I restart Windows.
    #!/bin/bash
    genie -i
    sed -i -E “s/(XDMCPHost=\”)[0-9.]*/\1`ip -4 addr show eth0 | grep -oP ‘(?<=inet\s)\d+(\.\d+){3}'`/" /mnt/c/config.xlaunch

    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\start-wsl-genie.bat:
    start /min wsl ~/startup.sh

    Thank you Steve for this guide

  5. Hey thanks for the article, I haven’t tried this yet but seems that it is what I’m looking for. I have a question though. If I don’t care about VNC, can I jump directly to the “Use XDMCP Instead Of VNC” section from the “Install Ubuntu Desktop Components” section?

    1. Hi Manuel,
      Yes, you can – indeed it’s what I actually did originally. Be aware, if you’re using it on the Surface Pro 4 that the experience is a little laggy – at least it was on mine. I’m not sure if it’s WSL networking or just the SP4 being a bit underpowered in general for it all?

      1. Doesn’t work. I only get a black screen when I run XLaunch.

        I have two questions.
        1. What are the “minimal” options from tasksel
        2. Do I need to do all the Systemd-Genie stuff if not installing VNC?

        1. Hi Manuel,
          Yes, you still need the Genie installed as it’s what will startup the LightDM server, which sounds like why you’re seeing the black screen.

          Black screen from VcXsrv means you’ve either got the wrong IP address in the Xlaunch settings, or you didn’t allow Public networks through the Windows firewall, or that LightDM isn’t running.

          The latter you can check in a standard WSL shell by typing “ps auxww | grep lightdm” and seeing if it’s there.

          Hope that helps,
          Steve

          1. Awesome! I was able to make it work!

            Thanks for the very nice tutorial! It is really good and perfect for what I was looking for.

  6. I was trying out your instructions until I reached the installation of systemd-genie:
    On trying
    ~$ sudo apt install systemd-genie
    results in the following error message:
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    E: Unable to locate package systemd-genie

    I downloaded the systemd package for “focal” from “https://packagecloud.ioarkane-systems/wsl-translinux” using wget and tried to install it with
    ~$ sudo apt install ./systemd-genie_1.28_amd64.deb
    and this results in the error message
    Reading package lists… Error!
    E: Invalid archive signature
    E: Internal error, could not locate member control.tar.{zstlz4gzxzbz2lzma}
    E: Could not read meta data from /home/raj/systemd-genie_1.28_amd64.deb
    E: The package lists or status file could not be parsed or opened.
    Now I am stuck. How to move ahead?

  7. Hi Steve,
    Thank you for your wonderful tutorial.
    I followed your guide successfully until the VcXsrv connection.
    After I clicked finish, the VcXsrv show a black screen for a while then pop up an error saying Session failed to connect to display. And the log says:
    LoadPreferences: C:\Users\bangn\AppData\Roaming\.XWinrc not found
    LoadPreferences: Loading C:\Program Files\VcXsrv\system.XWinrc
    Warning: Locale not supported by X, falling back to ‘C’ locale.
    (II) AIGLX: Testing pixelFormatIndex 1
    (II) GLX: enabled GLX_SGI_make_current_read
    (II) GLX: enabled GLX_SGI_swap_control
    (II) GLX: enabled GLX_MESA_swap_control
    (II) GLX: enabled GLX_SGIX_pbuffer
    (II) GLX: enabled GLX_ARB_multisample
    (II) GLX: enabled GLX_SGIS_multisample
    (II) GLX: enabled GLX_ARB_fbconfig_float
    (II) GLX: enabled GLX_EXT_fbconfig_packed_float
    (II) GLX: enabled GLX_ARB_create_context
    (II) GLX: enabled GLX_ARB_create_context_profile
    (II) AIGLX: enabled GLX_MESA_copy_sub_buffer
    (II) 467 pixel formats reported by wglGetPixelFormatAttribivARB
    (II) GLX: Initialized Win32 native WGL GL provider for screen 0
    (EE)
    Fatal server error:
    (EE) XDMCP fatal error: Session failed
    (EE)
    (EE) Server terminated with error (1). Closing log file.
    Can you help me with problem, thanks.

    1. I suspect, but can’t say for sure, that you didn’t put the tick in the Firewall popup box for Public Networks. Windows Firewall sees WSL2 network interfaces as public, so if you don’t allow public networks when it pops up the box when you’re installing everything then it’ll fail.

      It’s of course not overly ideal to allow public networks, but I’m assuming that you’re behind a NAT firewall router using it at home where you’re not likely to be hacked using XDMCP. If that’s a concern you’re better off with XRDP or VNC

      Hope that helps,
      Steve

  8. Awesome writeup.. Works great for me. I found that it’s much more responsive using Mate vs. Gnome on my laptop.

    Also…
    once you have saved off the config.xlaunch file , you can create a script in the same directory (I did it in c:\users\myuser\wsl\).. you can write a script to launch both wsl and the x terminal program in one go

    wsl genie -i
    .\config.xlaunch

    and name it whatever you want.ps1

    After that I created a shortcut on my desktop, named it wsl, and gave it a tux icon. Now I just double click tux and my wsl environment fires up and my x server fires up and connects right after. Takes about 5 seconds from second click to in the environment.. Just to save a hair extra time (vs having one script to launch the wsl and then launching the x server seperately)

  9. I’m trying to do this on another computer and I’m getting this:

    Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
    Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
    Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]
    Get:4 https://packages.microsoft.com/ubuntu/20.04/prod focal InRelease [10.5 kB]
    Get:5 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 Packages [32.5 kB]
    Err:5 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 Packages
    File has unexpected size (32530 != 32455). Mirror sync in progress? [IP: 40.117.131.251 443]
    Hashes of expected file:
    – Filesize:32455 [weak]
    – SHA512:bae554eca563c97a3485b455dad761a9f09a224b183bd38b7b4886dc5344956091fe1ce1631a108498b915a14bc8c482c322317651223e3b80a66168f7344796
    – SHA256:49404714b581362e4f28464472c27d814ef673c39e6e73f23083e0fc44e09df1
    – SHA1:d6d3b621e684bcc82a8b7fbc0d8acf8301ccbb87 [weak]
    – MD5Sum:e45e188fbf01cd5ab4e3559b2463d655 [weak]
    Release file created at: Tue, 13 Oct 2020 22:37:20 +0000

    I don’t know why this is happening, any ideas?

  10. Hi Steve,
    Thank you for this wonderful blog on installing the Linux desktop. I’m reporting on my experience following this. I had one or two minor things to fix on my laptop. You can decide if you want to warn users about these possibilities.

    Thank you for this wonderful guide to WSL2 with the graphics.
    Here are some small comments on my experience in following the directions.
    I hope you find the feedback useful. You can decide if you want to update this
    to warn users about some of these minor issues.

    1. > sudo tasksel
    I have a 4 GB laptop. tasksel often crashes in the middle for me.
    After a crash, I would do:
    > sudo apt-get update
    > sudo dpkg –configure -a
    In the end, I was still getting: tasksel: apt-get failed (100)
    So I just moved on, figuring that I could come back again
    if needed. I didn’t need to return to this step.

    2. > sudo nano /usr/lib/genie/deviated-preverts.conf
    As others had commented, the /usr/lib/genie directory didn’t exist for me.
    So, I added: mkdir /usr/lib/genie

    3. Minor typo: I advice LightDM -> I advise LightDM

    4. > sudo dpkg-reconfigure lightdm
    I found that I first needed to do: sudo apt-get install lightdm

    Thanks again for this great guide.

  11. Hi,
    I’ve just updated to WSL2 and installed the Ubuntu Desktop on Ubuntu 20.04 – thanks for the detailed instructions.

    I’m working on a corporate PC and have no means to change the firewall settings which means I cannot run any apt update/install commands etc. This has become the case after I installed the desktop. Originally I was able to access the internet and install the Ubuntu Desktop, of course.

    Is there a way to circumvent the virtual IP address used by WSL2 (Which is clashing with the firewall)?

    Failing that and short of a new Ubuntu installation from scratch, what can I do to access the internet without the desktop (so no VcXsrv and no ‘genie -s’)? This would at least allow me to use the terminal when I want to reach to the internet.

  12. Hi, need a little help please.
    This command:
    sudo dpkg-reconfigure lightdm
    Says:
    dpkg-query: package ‘lightdm’ is not installed and no information is available
    Use dpkg –info (= dpkg-deb –info) to examine archive files.
    /usr/sbin/dpkg-reconfigure: lightdm is not installed
    What did i miss?
    Thanks

    1. Sounds like lightdm isn’t installed – you should be able to install it with

      sudo apt install lightdm

      Let me know how you get on, it may be that I’ve missed a step in the instructions to actually install it (I may have already had it installed when I wrote it and assumed it came with ubuntu-desktop?)

      Incidentally, if you install it through apt like that, you won’t need to do the dpkg-reconfigure, because apt will run that bit for you.

      Hope that helps,
      Steve

  13. Hi. Great post. The issue is all I get after inserting the password is “Oh no! Something went wrong!” and reverts to login screen.
    Windows 19042.630 WSL and Ubuntu 20.04 LTS

    1. So – I found why. Maybe something Steve can test to add to the known issues. If there are multiple screens this solution may give the error I got.
      In my case launching XLaunch on the additional screen gives the problem. Moving XLaunch window to the laptop screen and then connect to the XDMCP server works fine. Go figure… This is a great post. Thank you Steve.

  14. This is AWESOME !
    Absolutely fantastic. Have it all set up on my windows laptop no problem.

    Do you have a post on how to VNC to the WSL Ubuntu from another machine on a local network ?
    I’ve tried using RealVNC from my linux (ubuntu) desktop but I just can’t seem to make it work…

    Thanks again !

    1. Hi there,
      I’ve not looked into it, other than to know that because the WSL networking is a NATted connection, it’s a bit of a pain and requires lots of Firewall manipulation using PowerShell. It is doable though, I believe.

      For me I just use a VPN which allows port forwarding and run the VPN from within my WSL. With that I can access the WSL desktop from anywhere πŸ™‚ PureVPN does the job for me – but YMMV.

      1. I did some more digging and found some scripts which forward ports and manipulate the firewall – looks really messy and a pain if you need to add more ports.
        I already pay for a VPN, which unfortunately doesn’t support port forwarding, but I’ve seen reports that it’s possible if you set up OpenVPN in WSL. I’ll have a go at that and post a link if I can make it work.
        Thanks again for a really informative post.

        1. Heya,
          Thanks for your kind words too. I suspect it would be perfectly possible to do it with OpenVPN if you can play with port forwarding on the server end. My suggestion of PureVPN was purely because they make it simple through a web interface πŸ™‚ I actually use OpenVPN on a VULTR server for other things and definitely rate it – but it takes a lot more admin time than PureVPN to set up πŸ™‚

          Glad you liked the article – here’s hoping that we won’t need all this shenanigans soon with MS working on GUI stuff built in to WSL

          1. Hi there, I’ve come up with a workaround – not particularly pretty but quite easy to set up.

            First I set up xrdp in the wsl2 ubuntu and checked I could RDP to it from the windows laptop it is running on – I can connect fine with Windows RDP on the 172. address of the WSL ubuntu.

            I can’t however connect from another box because the 172 address is not visible to the local network (as above).

            But then I installed and set up (very simple) Chrome Remote Desktop (works from chrome or firefox) on the WSL ubuntu and my linux box and I can remote desktop to the WSL ubuntu no problem (and vice versa).

            I installed it on the windows laptop too – so can use chrome remote desktop to connect from there to the WSL ubuntu running on it – and my other ubuntu box.

            Seems not a terrrible solution – very easy to set up, seems stable and no need for continuous config and seems secure from web posts.

            I’m guessing it’s not necessary to set up xrdp on WSL – I just did that to see if I could get it to work but then ran into the same networking problems.

  15. Steve,

    Thanks for all of your work, but I’m having the same problem that Manuel had on Oct 15. I ran “ps auxww | grep lightdm” and that made no difference. I followed all of your instructions down and including launching Xlaunch. That’s when I got the black screen. I stopped there.

    I am running a laptop with latest, Fall update, version of Windows 10.

  16. Hello good afternoon. I would like you to do a tutorial on how to install the xubuntu environment in Ubuntu 20.04 on WSL

    1. Hi Lucio,
      Thanks for this one – I’ve been having the same issues with the latest Genie because of services that wouldn’t start – these are probably the ones I was looking for.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.