Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A tutorial to use GUI in WSL2 replacing original XServer by Xvnc, allowing WSL to work like native Linux, including login screen

WSL2 with GUI using Xvnc

In this tutorial, we will setup GUI in WSL2, and access it using VNC. No additional software outside WSL (like VcXsrv) is required, except, of course, a VNC Viewer (RealVNC, TightVNC, TigerVNC, UVNC, etc, all of them might work flawlessly).

The key components we need to install are tigervnc-standalone-server and systemd-genie.

For this setup, I will use Ubuntu 20.04 LTS (Focal Fossa), and install GNOME Desktop. 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.

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

sudo apt update
sudo apt upgrade

If you are trying to use Debian, you also will need:

sudo apt install curl wget

Now we are ready to go.

Installing components

Installing GUI

  1. Ubuntu has a handy component installer called tasksel, but it's not installed by default. So let's install it.

    sudo apt install tasksel
    
  2. Once we have it installed, let's run it.

    sudo tasksel
    
  3. At the package list, select your favorite GUI package. Use spacebar to select the package, and Tab to confirm your choice. I selected Ubuntu Desktop. The installation will take a while, so be patient.

Installing VNC Server

Pretty easy, one command and you are done:

sudo apt install tigervnc-standalone-server

Installing dotnet-runtime

systemd-genie requires dotnet-runtime, but it ins't installed automatically. Follow the install instructions. Here are the commands to install dotnet-runtime-5.0 on Ubuntu 20.04 LTS (Focal Fossa):

wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install dotnet-runtime-5.0

If you are using Debian, the commands are almost the same:

wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install dotnet-runtime-5.0

Installing systemd-genie

Now we will install systemd-genie, which is responsible for turning the minimalist WSL into a more complete Linux instance, with systemd and other related stuff. This is necessary to run GDM (GNOME Display Manager) and LightDM properly, giving the user a full graphic interface experience, with login and everything. Here are the install instructions. As of April 6th, 2021, these following commands are needed to install it (and I only guarantee they will work Ubuntu and Debian. For other distros, you must check how to get the appropriate package for your system):

sudo apt install apt-transport-https
sudo wget -O /etc/apt/trusted.gpg.d/wsl-transdebian.gpg https://arkane-systems.github.io/wsl-transdebian/apt/wsl-transdebian.gpg
sudo chmod a+r /etc/apt/trusted.gpg.d/wsl-transdebian.gpg
source /etc/os-release
cat << EOF | sudo tee /etc/apt/sources.list.d/wsl-transdebian.list
deb https://arkane-systems.github.io/wsl-transdebian/apt/ $VERSION_CODENAME main
deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ $VERSION_CODENAME main
EOF
sudo apt update
sudo apt install systemd-genie

The installation process is finally done.

Configuring the environment

Creating VNC Server passwords

  1. In this setup, each user has a different VNC password. So you have to configure at least three passwords, one for the current user, other for root, and other for gdm, who whill present the login screen. If you don't configure the password, you won't able to access the login screen, or the user's desktop. First, let's configure the VNC password current user:

    vncpasswd
    
  2. Now, let's configure the VNC password for root (needed if you use LightDM instead GDM):

    sudo -H vncpasswd
    
  3. Finally, let's configure the VNC password for GDM (you need to skip this step if you didn't install GNOME):

    sudo -H -u gdm vncpasswd
    

    Tip: In Debian, the GDM user is Debian-gdm.

    You can repeat the process for other existing users.

Replacing default X by Xvnc

By default, the display manager call multiple X instances, one for each user session, including the login screen, provided by gdm. So we will replace Xorg script by a new version which calls Xvnc instead the classic X/Xorg. This IS the real magic we are trying to do.

  1. First, let's backup the original Xorg script.

    sudo mv /usr/bin/Xorg /usr/bin/Xorg_old
    
  2. Then, we create a new Xorg script.

    sudo nano /usr/bin/Xorg_new
    
  3. Paste the following content in the editor (remember, WSL shell uses CTRL + SHIFT + V for pasting, instead our traditional CTRL + V key combination):

    #!/bin/bash
    for arg do
      shift
      case $arg in
        # Xvnc doesn't support vtxx argument. So we convert to ttyxx instead
        vt*)
          set -- "$@" "${arg//vt/tty}"
          ;;
        # -keeptty is not supported at all by Xvnc
        -keeptty)
          ;;
        # -novtswitch is not supported at all by Xvnc
        -novtswitch)
          ;;
        # other arguments are kept intact
        *)
          set -- "$@" "$arg"
          ;;
      esac
    done
    
    # Here you can change or add options to fit your needs
    command=("/usr/bin/Xvnc" "-geometry" "1024x768" "-PasswordFile" "${HOME:-/root}/.vnc/passwd" "$@") 
    
    systemd-cat -t /usr/bin/Xorg echo "Starting Xvnc:" "${command[@]}"
    
    exec "${command[@]}"
    

    Please note the resolution of the virtual screen. You can change that to fit your needs (1366x768, 1920x1080, etc). Also, you can change the -PasswordFile option to point to a fixed location instead the home of current user, so you don't need to have a password for each user.

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

    sudo chmod 0755 /usr/bin/Xorg_new
    sudo ln -sf Xorg_new /usr/bin/Xorg
    

    Attention: sometimes, system updates replace Xorg link with the original version. Just repeat this step if this happens, and Xvnc will work again as Xorg replacement.

Running systemd-genie

Finally, it's time to put everything together.

genie -s

If you are using Debian, you need one extra step:

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

Doing this is like booting Linux again, this time with systemd. Because of systemd, gdm will start automatically, and will create a X instance to display the login interface. We changed this process to make it create Xvnc instances, so we can access them. The first instance will listen to port 5900, the second instance will listen to port 5901, and so on.

Attention: When running genie for the first time, it will take a lot of time, and probably will show an error message. After that, you must check what systemd units have failed. You can check that with a systemctl list-units --failed, then you must check this page to see what to do with each failed unit. Most of them can be simply disabled/masked with no harm or side effects, and after doing that, genie will start much faster and without any error messages.

Accessing the VNC screen

After a while (usually 30 seconds, but it can take more if you don't have a SSD, maybe one minute or two), you can test if it's working properly. Use your favorite VNC Viewer to connect to your localhost port 5900. Use the VNC password set for user gdm. The login screen must appear.

After logging in, the screen will be blank. This is because a new instance of Xvnc was created for user desktop, listening to port 5901. Connect to this screen now. The logged user's desktop must appear. When you log out, the screen at port 5900 will show the login interface again. This applies to GDM (which is the case if you installed Ubuntu Desktop). 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]
    

If you are using LightDM, the desktop screen will appear in port 5900, so there's no need to connect to port 5901.

Shutting down

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

  • Power off option on GUI menu
  • sudo init 0, inside the genie bottle
  • genie -u, outside the genie bottle

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

Tips and tricks

  • VNC is a very adaptive protocol, and by default tries to use the most aggressive compression available, for better networking performance. But in our case, doing this only adds unnecessary CPU extra load, since you are connecting to localhost ("infinite" bandwith, near zero ping). To remove all compression algorithms and reduce lagging, force your VNC Viewer to connect using RAW encoding. The performance gain is noticeable, specially when playing videos (not a spectacular performance in this particular scenario, though).

  • If you are trying to use Debian, you need to do the following or some apps will not launch (at least in Buster):

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

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 Xvnc, 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 X by Xvnc 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 Xvnc output will be in the file /var/log/lightdm/x-0.log.

  5. If you can connect to 59XX ports, but receive an error like Authentication failure: No password configured for VNC Auth, the file $HOME/.vnc/passwd is missing for that particular user (on port 5900, the user is gdm). Try to repeat the steps described in section Creating VNC Server passwords and try to connect again.

  6. If it still doesn't work, you can try to restart WSL. Open a Windows PowerShell command prompt, and execute the following command (don't forget to save everything that is unsaved before, because WSL will shut down completely):

    PS > wsl --terminate <your distro name>
    

    After that, open your distro shell again and repeat the steps of section Running systemd-genie.

Sample screenshots

GDM

GDM

LightDM

LightDM

GNOME

GNOME

KDE

KDE

Xfce

Xfce

Budgie Desktop

Budgie Desktop

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).

@keepitsane

This comment has been minimized.

Copy link

@keepitsane keepitsane commented Jul 8, 2020

This is super helpful thank you very much! Just a quick question is it possible to display a single GUI application if I don't need the entire Ubuntu Desktop GUI?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Jul 8, 2020

Hi! Thank you for your feedback! Yes, it's possible to display a single GUI application, and you can use it like a Windows application. There are a lot of tutorials around here, just search for WSL and VcXsrv and you will find plenty of how-tos.

@keepitsane

This comment has been minimized.

Copy link

@keepitsane keepitsane commented Jul 8, 2020

Thanks was just looking into it. So is the new GPU support that windows announce is coming later this year meant to replace solutions like VcXsrv and Xvnc?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Jul 8, 2020

Yes, I hope so. They are all workarounds because Microsoft doesn't provide an "official" solution that works out of box. I'll be happy if this tutorial becomes obsolete, because Microsoft's Wayland will use GPU capabilities, so graphics performance will be much better than using VcXsrv or Xvnc.

@keepitsane

This comment has been minimized.

Copy link

@keepitsane keepitsane commented Jul 9, 2020

Hey just one last quick question if we want to remove all of this other then uninstalling all the packages are there any recommend steps to revert back?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Jul 10, 2020

Basically you have to remove all GUI components you installed (there are many tutorials teaching how to do it in a normal Linux distro, should work for WSL as well), remove dotnet-runtime and genie, and then you remove Xorg script and revert the Xorg_old to Xorg. After that, you might have everything like before. I'd rather reset everything, but if you have lots of things installed and configured, the uninstall approach must be enough.

@shepherd1530

This comment has been minimized.

Copy link

@shepherd1530 shepherd1530 commented Jul 10, 2020

Good job. @tdcosta100 I successfully completed the steps above an I am at Ubuntu-desktop login screen but now I am experiencing a loop where I enter the correct password an I am taken back to the login screen.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Jul 11, 2020

Hi, @shepherd1530. You need to watch the logs. Do the following:

  1. Wait the login screen appear in VNC Viewer. Then in a WSL Shell you type the following: journalctl -f

  2. Put your password and try to login.

  3. After returning to login screen, you can examine the log messages in WSL Shell to see any errors. Something is crashing, so you have first to discover what it is.

@shepherd1530

This comment has been minimized.

Copy link

@shepherd1530 shepherd1530 commented Jul 11, 2020

@tdcosta100 Thanks, I saw something about DISPLAY 0:0 in the logs failing and removing it from my .bashrc fixed it.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Jul 11, 2020

Great! Thank you for sharing your solution.

@gates17

This comment has been minimized.

Copy link

@gates17 gates17 commented Jul 20, 2020

well i followed this tutorial to the letter only to end up at wsl shell after starting genie. but i just cant connect to gui since i never used vnc. any particular command you have to type?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Jul 21, 2020

Hi. First you need to download a VNC Viewer. At the beginning of the tutorial you have some links. When you open the VNC Viewer, you connect to localhost:5900. It should ask the password if it's everything ok. After that, you are connected. Then after logging in, you can disconnect and connect to localhost:5901, then your desktop should appear after typing the password.

@DennisWangCW

This comment has been minimized.

Copy link

@DennisWangCW DennisWangCW commented Jul 21, 2020

捕获

hi @tdcosta100 Why I got this message?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Jul 22, 2020

@DennisWangCW very strange! Did you install Ubuntu Desktop using tasksel? If you did so, you can try running bash under gdm account: sudo -u gdm bash, and then you can cd ~/, and pwd. Check if the directory is /var/lib/gdm3. Also, check the permissions for file /home/1eakycau1dron/.vnc/passwd.

Apparently vncpasswd under gdm is trying to write a file in 1eakyca1dron profile. This can happen if $HOME is being set globally somewhere.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Jul 22, 2020

@gates17, were you able to connect to VNC with VNC Viewer?

@akhilkathi97

This comment has been minimized.

Copy link

@akhilkathi97 akhilkathi97 commented Aug 7, 2020

After a login I am getting a blank screen.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Aug 8, 2020

Hi, @akhilkathi97. You need to connect to localhost:5901 after logging in. If you have problems connecting to this screen in particular, please let me know.

@MonicaTiyyagura

This comment has been minimized.

Copy link

@MonicaTiyyagura MonicaTiyyagura commented Aug 27, 2020

I am authentication failure error, when i try to login
[gdm-password][1316]: pam_unix(gdm-password:auth): authentication failure; logname= uid=0 euid=0 tty=/dev/tty1 ruser= rhost= user=<user_name>

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Aug 29, 2020

Hi, @MonicaTiyyagura. If your password is correct, you should try this tutorial in a clean WSL2 installation. Maybe there is something wrong in your current setup.

@jalbarrang

This comment has been minimized.

Copy link

@jalbarrang jalbarrang commented Aug 31, 2020

Hi @tdcosta100, i got a problem where i followed this steps and when finished it finished it broke network connection, can't donwload nor browse through wsl2, any hints?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Aug 31, 2020

Hi, @jalbarrang. Sometimes it happened with me, I resolved it restarting WSL with wsl --shutdown in PowerShell. If it doesn't work, try to restart your PC. Tell me if it solves your problem.

@vdevan

This comment has been minimized.

Copy link

@vdevan vdevan commented Oct 22, 2020

Debian distribution is updated. The user name gdm doesn't exist anymore. I tried sudo -u gdm vncpasswd and it gave me an error. A quick look at /etc/passwd found at that it Debian-gdm. So for users not able to set vncpasswd please use sudo -u debian-gdm

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Nov 4, 2020

@vdevan, thanks a lot for this information! Did you succeed to make it work?

@Greasy-Monkey

This comment has been minimized.

Copy link

@Greasy-Monkey Greasy-Monkey commented Nov 6, 2020

For debian it should be sudo -u Debian-gdm vncpasswd not sudo -u debian-gdm vncpasswd

@vdevan

This comment has been minimized.

Copy link

@vdevan vdevan commented Nov 6, 2020

@vdevan, thanks a lot for this information! Did you succeed to make it work?

Yes. It works great. I use for both Ubuntu and Debian app. Since the Windows preview release allow you to mount ext4 volume as well, I am able to mount USB HDD from linux to Windows and make a backup

@geev-gv

This comment has been minimized.

Copy link

@geev-gv geev-gv commented Nov 20, 2020

Thank you, I am using Debian
ubu@WINTAB-5FDA1V5-wsl:~$ neofetch _,met$$$$$gg. ubu@WINTAB-5FDA1V5-wsl ,g$$$$$$$$$$$$$$$P. ---------------------- ,g$$P" """Y$$.". OS: Debian GNU/Linux 10 (buster) on Windows 10 x8 ,$$P' $$$. Kernel: 4.19.128-microsoft-standard
',$$P ,ggs. $$b: Uptime: 29 mins d$$' ,$P"' . $$$ Packages: 1377 (dpkg)
$$P d$' , $$P Shell: bash 5.0.3
$$: $$. - ,d$$' Resolution: 1024x768
$$; Y$b._ ,d$P' DE: MATE
Y$$. ."Y$$$$P"' WM: Metacity (Marco)
$$b "-.__ WM Theme: Menta Y$$ Theme: Menta [GTK2/3]
Y$$. Icons: menta [GTK2/3] $$b. Terminal: mate-terminal
Y$$b. Terminal Font: Monospace 13 "Y$b.
CPU: Intel Celeron N2940 (4) @ 1.833GHz
`""" Memory: 399MiB / 3108MiB

ubu@WINTAB-5FDA1V5-wsl:~$
`

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Nov 23, 2020

Hi, @geev-gv. I didn't undersand what you said. Are you having any trouble with the tutorial?

@ptflp

This comment has been minimized.

Copy link

@ptflp ptflp commented Dec 5, 2020

sometime /usr/bin/Xorg file gone, needs to reconfigure like in this tutorial
using ubuntu 20.04 and set auto login, to prevent redudant actions with connecting on second display on port 5901

sudo nano /etc/gdm3/custom.conf

then add or uncomment

 AutomaticLoginEnable=true 
 AutomaticLogin=user1

where user1 your username

@ptflp

This comment has been minimized.

Copy link

@ptflp ptflp commented Dec 5, 2020

is there way use 2 display in vnc?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Dec 9, 2020

Hmmm I don't know if there is a way to really create 2 displays, but you can create one big display with the twice of the normal width. 3840x1080, for example. Will this solve your problem?

You can also play with Xvfb and x0vnc. With Xvfb you create 2 screens, and with x0vnc you make a way to show them.

Btw, thank you for your tips! In future revisions I will add them, specially Xorg, which I had to reconfigure recently due to updates on XOrg packages.

@gokulyc

This comment has been minimized.

Copy link

@gokulyc gokulyc commented Dec 25, 2020

I am getting below error :

gokulyc@LAPTOP-LC4B480R:~$` sudo mv /usr/bin/Xorg /usr/bin/Xorg_old
gokulyc@LAPTOP-LC4B480R:~$ sudo nano /usr/bin/Xorg
gokulyc@LAPTOP-LC4B480R:~$ sudo chmod 0755 /usr/bin/Xorg
gokulyc@LAPTOP-LC4B480R:~$ genie -s
Failed to create bus connection: No such file or directory
genie: starting shell failed; machinectl shell returned 1.
@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Dec 25, 2020

Hi, @gokulyc. Could you please post the output of genie -s -v?

@gokulyc

This comment has been minimized.

Copy link

@gokulyc gokulyc commented Dec 26, 2020

Hi, @gokulyc. Could you please post the output of genie -s -v?

Output:

gokulyc@LAPTOP-LC4B480R:~$ genie -s -v
'-v' was not matched. Did you mean '-h'?
Unrecognized command or argument '-v'

--shell:
  Initialize the bottle (if necessary), and run a shell in it.

...
...
...
...

I have used exact same content in /usr/bin/Xorg , what values should i replace with?
image

Unable to enter username(textbox disabled):

image

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Dec 29, 2020

Hi, @gokulyc. Sorry for the long wait. My genie version was outdated, so I had to upgrade it (and they changed the install procedure - AGAIN). In this current version, I was able to reproduce the same error you had. But despite the error, genie is initializing. You can check this by running genie -s a second time.

About the username greyed out option, it's correct. You can just type the password, not the username. After you enter the password you have set in the vncpasswd phase, the GDM's login screen should appear.

Please tell me if you can log in into GNOME.

And don't forget: after logging in the login screen will be blank, and you will have to connect again, this time to port 5901.

@gokulyc

This comment has been minimized.

Copy link

@gokulyc gokulyc commented Dec 29, 2020

I am still facing issues, I am not much into bash/linux.

image

Bash Output :

gokulyc@LAPTOP-LC4B480R-wsl:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 2a:d5:eb:d5:ec:49 brd ff:ff:ff:ff:ff:ff
3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 36:7c:54:8c:8b:c7 brd ff:ff:ff:ff:ff:ff
4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:b5:9a:67 brd ff:ff:ff:ff:ff:ff
    inet 172.27.149.60/20 brd 172.27.159.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:feb5:9a67/64 scope link
       valid_lft forever preferred_lft forever
5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0


gokulyc@LAPTOP-LC4B480R-wsl:~$ sudo vncpasswd
[sudo] password for gokulyc:
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
gokulyc@LAPTOP-LC4B480R-wsl:~$ journalctl -f
-- Logs begin at Fri 2020-12-25 22:30:52 IST. --
Dec 29 13:46:55 LAPTOP-LC4B480R-wsl /usr/lib/gdm3/gdm-x-session[614]:  SConnection: Client needs protocol version 3.8
Dec 29 13:46:55 LAPTOP-LC4B480R-wsl /usr/lib/gdm3/gdm-x-session[614]:  SConnection: Client requests security type VncAuth(2)
Dec 29 13:47:00 LAPTOP-LC4B480R-wsl /usr/lib/gdm3/gdm-x-session[614]: Tue Dec 29 13:47:00 2020
Dec 29 13:47:00 LAPTOP-LC4B480R-wsl /usr/lib/gdm3/gdm-x-session[614]:  SVncAuth:    opening password file '/var/lib/gdm3/.vnc/passwd' failed
Dec 29 13:47:00 LAPTOP-LC4B480R-wsl /usr/lib/gdm3/gdm-x-session[614]:  SConnection: AuthFailureException: No password configured for VNC Auth
Dec 29 13:47:00 LAPTOP-LC4B480R-wsl /usr/lib/gdm3/gdm-x-session[614]:  Connections: closed: 172.27.144.1::49256 (No password configured for VNC Auth)
Dec 29 13:47:00 LAPTOP-LC4B480R-wsl /usr/lib/gdm3/gdm-x-session[614]:  EncodeManager: Framebuffer updates: 0
Dec 29 13:47:00 LAPTOP-LC4B480R-wsl /usr/lib/gdm3/gdm-x-session[614]:  EncodeManager:   Total: 0 rects, 0 pixels
Dec 29 13:47:00 LAPTOP-LC4B480R-wsl /usr/lib/gdm3/gdm-x-session[614]:  EncodeManager:          0 B (1:-nan ratio)
Dec 29 13:47:05 LAPTOP-LC4B480R-wsl WSL2: Performing memory compaction.
@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Dec 29, 2020

Hi, @gokulyc. That's a progress, but you have to repeat the steps of the "Creating VNC Server passwords" section. There is no VNC password for the gdm3 user. Tell me if it works after repeating these steps I told you.

@gokulyc

This comment has been minimized.

Copy link

@gokulyc gokulyc commented Dec 31, 2020

Hi, @gokulyc. That's a progress, but you have to repeat the steps of the "Creating VNC Server passwords" section. There is no VNC password for the gdm3 user. Tell me if it works after repeating these steps I told you.

I have re-done from scratch . It working but have connect to 2 times.

"After logging in, the screen will be blank. This is because a new instance of Xvnc was created for user desktop, listening to port 5901. Connect to this screen now. The logged user's desktop must appear. When you log out, the screen at port 5900 will show the login interface again. This applies to GDM (which is the case if you installed Ubuntu Desktop). If you are using LightDM, the desktop screen will appear in port 5900, so there's no need to connect to port 5901."

how to connect using light dm ? Can you share DM contact?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Dec 31, 2020

Great, @gokulyc! If you want to change your default display manager do LightDM, first you need to install it with sudo apt install lightdm. Right after the install, you will be prompted to choose the display manager. Choose lightdm and everything will be ok. If you want to change your default display manager again, just execute sudo dpkg-reconfigure lightdm or sudo dpkg-reconfigure gdm3, and choose again what display manager you want to use.

You can also use @ptflp's tips and enable autologin for GDM3. If you do that, you will have a desktop instead a login screen when connecting to VNC port 5900.

@gokulyc

This comment has been minimized.

Copy link

@gokulyc gokulyc commented Dec 31, 2020

Great, @gokulyc! If you want to change your default display manager do LightDM, first you need to install it with sudo apt install lightdm. Right after the install, you will be prompted to choose the display manager. Choose lightdm and everything will be ok. If you want to change your default display manager again, just execute sudo dpkg-reconfigure lightdm or sudo dpkg-reconfigure gdm3, and choose again what display manager you want to use.

You can also use @ptflp's tips and enable autologin for GDM3. If you do that, you will have a desktop instead a login screen when connecting to VNC port 5900.

Done 👍 Thank you.

@ROBYER1

This comment has been minimized.

Copy link

@ROBYER1 ROBYER1 commented Jan 25, 2021

With Ubuntu Home on 20.04 Ubuntu, you can actually make the display stay on Display 1 (localhost 5900 or localhost) by going to Settings>Users>Automatic Login: On

I found this by accident last week and just tested on another machine, now you don't have to start up vnc viewer to go to localhost 5900 first then swap over to 5901 after, you can stay on 5900 👯‍♂️

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Jan 26, 2021

@ROBYER1, you are right. @ptflp pointed that too, but changing settings file instead using the GUI. Thank you for giving this alternative!

@ROBYER1

This comment has been minimized.

Copy link

@ROBYER1 ROBYER1 commented Jan 26, 2021

Any tips on getting this to run with Ubuntu 18.04 LTS? I set this up fine with 20.04 on a PC but I need 18.04 on a separate machine for python 3.6 for Nvidia stuff.. long story but I hit issues with saving the vnc password file and using the genie -s command doesn't work on 18.04 unfortunately

When repeating 'sudo -u gdm vncpasswd', I get:
Couldn't open /home/USER/.vnc/passwd for writing

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Jan 27, 2021

Hi, @ROBYER1. Try the following steps:

  1. sudo -H -u gdm vncpasswd and set the VNC password.
  2. genie -i to start genie. You can safely stop it if it gets stuck on "Waiting for systemd"
  3. genie -s to get inside genie bottle

Tell me if these steps work for you.

@siegLoesch

This comment has been minimized.

Copy link

@siegLoesch siegLoesch commented Feb 3, 2021

Hello tdcosta100,
thank you for your efforts to build and provide this tutorial. I succeded to install Debian Buster with Gnome 3.
The only subject is that I am not able to open a gnome-terminal what I have been worked around for the moment using sakura (that runs fine). The messages after trying to open a gnome terminal are as follows (maybe one of you had a similar experience and a better solution as my current workaround):

Feb 3 14:33:34 localhost org.gnome.Shell.desktop[542]: Xlib: extension "DPMS" missing on display ":0".
Feb 3 14:33:34 localhost gsd-color[690]: could not find device: property match 'XRANDR_name'='VNC-0' does not exist
Feb 3 14:36:45 localhost org.gnome.Terminal.desktop[542]: # Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: Timeout was reached

Siegfried

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Feb 3, 2021

Hi, @siegLoesch. I had to install a Debian distro to understand your problem. I also couldn't open gnome-terminal, and the same error was showing up. So I found this solution and it worked. So try it and tell me if it works for you too.

@siegLoesch

This comment has been minimized.

Copy link

@siegLoesch siegLoesch commented Feb 4, 2021

Hello @tdcosta. Thanks a lot for looking into it. I am currently working from home office and will check it next Monday, when I will back to my office. Please stand by.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Feb 4, 2021

@siegLoesch, no problem, take your time =)!

@siegLoesch

This comment has been minimized.

Copy link

@siegLoesch siegLoesch commented Feb 5, 2021

@tdcosta100: just tested and I must say worked like a charm! Thank you so much!
I also have to remark that the solution according your tutorial works much better than any I tried before: rdp/xrdp and running a x-server on windows.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Feb 6, 2021

@siegLoesch, that's very nice to know! I have made some improvements to guide other Debian users, thank your for telling me your problem!

@NoroelleSaeth

This comment has been minimized.

Copy link

@NoroelleSaeth NoroelleSaeth commented Mar 29, 2021

Couldn't get it working with KDE, but overall - awesome tutorial, helped me a lot. Thanks!

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Mar 29, 2021

@NoroelleSaeth, thank you! Could you provide more details of what's happening? Maybe I can help you and improve the tutorial even further.

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 7, 2021

Does this work with CentOS?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 8, 2021

Hi, @adamgranthendry. It might work, but maybe you will have some trouble making systemd-genie work in it:

arkane-systems/genie#114

I can't test it by myself, since in Windows Store I will have to pay to download CentOS Distro.

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 8, 2021

@tdcosta100 Actually, yes you can. You don't have to pay for CentOS. Just download and install your desired version (6, 7, or 8) here. Then install systemd-genie (unzip tarball into root / if necessary). Would you please be able to test?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 9, 2021

Great, @adamgranthendry!

Here are my steps for CentOS8-Stream (after creating a user and adding it to wheel group, then logging in with it):

Preparing the environment

sudo yum update
sudo yum install epel-release
sudo yum install nano

Installing Components

Installing GUI

sudo yum groupinstall "GNOME" "GNOME Applications"
sudo ln -sf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

Installing VNC Server

sudo yum install tigervnc-server

Installing systemd-genie dependencies

sudo yum install dotnet-runtime-5.0 daemonize

Installing systemd-genie

rpm_name=`curl -s https://api.github.com/repos/arkane-systems/genie/releases/latest | grep name | grep rpm | cut -d '"' -f 4`
curl -L https://github.com/arkane-systems/genie/releases/latest/download/$rpm_name --output $rpm_name
sudo yum localinstall $rpm_name

After that, you can follow the remaining steps of the Debian tutorial. Please tell me if it works for you.

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 9, 2021

@tdcosta100 Thank you so much! A couple things:

  1. At sudo yum localinstall $rpm_name, I get the following output:
Loaded plugins: fastestmirror, langpacks
Examining genie-1.36-1.fc33.x86_64.rpm: genie-1.36-1.fc33.x86_64
Marking genie-1.36-1.fc33.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package genie.x86_64 0:1.36-1.fc33 will be installed
--> Processing Dependency: systemd-container for package: genie-1.36-1.fc33.x86_64
Loading mirror speeds from cached hostfile
 * base: mirror.sov.uk.goscomb.net
 * epel: mirror.siena.edu
 * extras: uk.mirrors.clouvider.net
 * updates: mirror.sov.uk.goscomb.net
--> Finished Dependency Resolution
Error: Package: genie-1.36-1.fc33.x86_64 (/genie-1.36-1.fc33.x86_64)
           Requires: systemd-container
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
  1. At sudo -H -u gdm vncpasswd, I get:
sudo: unable to execute /bin/vncpasswd: Permission denied
  1. At genie -s, I get:
Unknown operation shell.
genie: starting shell failed; machinectl shell returned 1.

(genie -i > /dev/null & outputs [1] 589).

  1. I'm not sure how to use VcXsrv XLaunch to view the VNC. (or should I use the Windows Remote Desktop Connection tool?). How do I view the VNC screen?
@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 9, 2021

@tdcosta100 Or maybe on 4 I should use Xming and putty?

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 9, 2021

@tdcosta100 FYI, I have CentOS 7 installed.

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 9, 2021

@tdcosta100 Maybe could you show me creating a user, adding to wheel group, and logging in? I've tried:

sudo useradd hendra11
sudo passwd hendra11
sudo usermod -aG wheel root
sudo usermod -aG wheel hendra11

However, when I run

sudo su hendra11

from root, I get

su: failed to execute /bin/bash: Permission denied

I even tried

sudo chmod 755 /
sudo chmod 755 /bin
sudo chmod 755 /lib
@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 9, 2021

@tdcosta100 I can confirm that when I use CentOS 8 Stream, all those errors go away. However, I do the following with VcXsrv:

image

image

image

image

image

image

image

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 9, 2021

@tdcosta100 Basically, I think I just don't know how to get the VNC screen up...

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 9, 2021

@tdcosta100 I can't get a VNC viewer to work. Can you help me?

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 9, 2021

@tdcosta100 I got this to work as follows:

  1. sudo yum install -y xrdp

  2. sudo nano /etc/xrdp/xrdp.ini

    • Change port from 3389 to 3390
  3. sudo systemctl start xrdp

  4. Run Windows Remote Desktop Connection

  5. Connect to localhost:3390

GNOME now opens up!! Thank you!!!

@To-beas

This comment has been minimized.

Copy link

@To-beas To-beas commented Apr 10, 2021

Hi,

I luckily found this thread. And it's alive - that's the best part.

Edit: The next day the setup doesn't work anymore. I can't get ubuntu-desktop to appear anymore. What measures I took:
reinstalling all of .dnet, genie, tigervnc and setup new passwords for vncserver. Having same problom like @gokulyc with genie: (most recent version):

  1. genie -s: can't open shell: Looked into man and --help: running and can't use "genie -u" to stop it because within shell
  2. genie -s: "ipconfig.exe command not found"
    Starts and can go to a desktop similar environment with "vncserver && tigervnc -xstartup /usr/bin/xterm"
@swapansanjay

This comment has been minimized.

Copy link

@swapansanjay swapansanjay commented Apr 14, 2021

Installing systemd-genie has been failing. All the above steps suggested dont work.
Giving up.

@cerebrate

This comment has been minimized.

Copy link

@cerebrate cerebrate commented Apr 16, 2021

@tdcosta100 genie author here. Just a quick note or two:

  1. The first line in

genie -i > /dev/null &
genie -s

isn't actually necessary. The commands to do something inside the bottle (-s, -l, and -c) all initialize the bottle automatically if it hasn't been already. -i exists so that you can get systemd services running without opening a shell/running a command or so that you can preinitialize it to start faster the first time you use one of the others.

  1. If it looks like it's timing out or times out at the "Waiting for systemd...!!!" stage, that means one or more of your systemd units is failing. You should probably fix that, because while the examples I've seen so far are innocuous, there's no guarantee all of them are. Notes on known-to-cause-issues units are available on the genie repo wiki. (1.37, forthcoming, will automatically list them for you to make this process easier.)

  2. It's also a good idea to shut down systemd and its units properly using the shutdown option in your GUI or wsl genie -u from a Windows prompt before terminating the distro or shutting down Windows. While systemd services are robust enough to handle it most of the time, just using wsl --terminate <distro> or wsl --shutdown is in many ways like yanking the power cord on a Linux machine; not to be recommended, no matter how many times you get away with it.

@cerebrate

This comment has been minimized.

Copy link

@cerebrate cerebrate commented Apr 16, 2021

(Also, for those having trouble with CentOS 7 or otherwise having machinectl shell errors: the problem is that since 1.29, genie requires a newer version of systemd and systemd-container (>= 232-25) than your distro has. Gory details here:

arkane-systems/genie#104

The short version of the workaround is to update your distro (if available), update your systemd, or grab 1.28 from the releases page for manual install.)

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 16, 2021

@tdcosta100 If I have a GUI program in GNOME I want to run and it is giving me an error

Error: Unable to initialize gtk, is DISPLAY set properly?

How can I fix this? I have tried adding export DISPLAY=local:0.0 to my runcom file (.zshrc) within GNOME and then re-sourcing (i.e. source ~/.zshrc), but this does not work. I am using xrdponlocalhost:3390`.

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 16, 2021

@tdcosta100 FYI, I ran

loginctl list-sessions

which gave

SESSION  UID USER     SEAT  TTY 
     c3    0 root               
     c4   42 gdm      seat0 tty1
     c5 1000 hendra11           

Then, running

loginctl show-session -p Display -p Active c5

showed

Display=:10 Active=yes

and in fact, I have Display=:10 listed when I run printenv. However, exporting this in ~/.zshrc with

export DISPLAY=:10

and then resourcing

source ~/.zshrc

does not fix the problem.

Any thoughts?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 17, 2021

Hi, guys. I'm sorry being silent for so many days. I'm having serious issues with my Internet provider, so I was unable to test everything and answer your questions in a reasonable time. But I will answer what is possible with my bad mobile connection.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 17, 2021

@adamgranthendry, wow, so many issues. But let's address them all:

  1. I tried very hard to make systemd-genie to work properly in CentOS7. Unfortunately, there are some dependencies in the latest version which prevent it to be properly installed, and it's not usable because it requires some component versions that are not avaliable to CentOS7. So you have to try the 1.28 version, which was pointed by @cerebrate. In my research, I also arrived on the discussion pointed by @cerebrate (arkane-systems/genie#141), and I think it's the only possible current workaround if you want to use systemd-genie. There are other options to run systemd in a container, but they are beyond the scope of this tutorial.

  2. My steps to create a user in CentOS7 right after running it for the first time (the user is called "user1"):

    useradd user1
    passwd user1
    usermod -a -G wheel user1
    

    Then I exited the shell and used this command:

    CentOS7 config --default-user user1
    

    After that, my user was able to sudo and everything.

  3. You tried to use VcXsrv, but the purpose of this tutorial is not to use such a thing (and X410, or any other external X Server). You also don't need to use PuTTY. With a VNC Viewer, you just connect to port 5900/5901 and get a full GUI. Of course, after everything is correctly set-up. Using XRDP is a good alternative to this tutorial, but if you use it, you don't need to follow the steps of this tutorial. It's redundant, or maybe it will interfere in your XRDP setup, so it's not productive to use both solutions unless you know enough about them both to not mess up with them. If XRDP works for you, keep with it, there is no need to use my solution. And that's ok, because a good solution is a solution which fit your needs =).

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 17, 2021

Hi,

I luckily found this thread. And it's alive - that's the best part.

Edit: The next day the setup doesn't work anymore. I can't get ubuntu-desktop to appear anymore. What measures I took:
reinstalling all of .dnet, genie, tigervnc and setup new passwords for vncserver. Having same problom like @gokulyc with genie: (most recent version):

  1. genie -s: can't open shell: Looked into man and --help: running and can't use "genie -u" to stop it because within shell
  2. genie -s: "ipconfig.exe command not found"
    Starts and can go to a desktop similar environment with "vncserver && tigervnc -xstartup /usr/bin/xterm"

Hi, @To-beas. Maybe you could share your issues with genie in the here. In version 1.36, it was ok. But in some earlier versions it was broken, so it's a good idea, if the latest version isn't working, open a issue and see if they can help you.

Also, if you update your components, the Xorg script may have been replaced by the original version. See the step 4 of Replacing default X by Xvnc. I also updated this section to make the restore of the modified Xorg script easier.

If you fix genie -s and are still having trouble, please check your logs, like described in Troubleshooting section.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 17, 2021

Installing systemd-genie has been failing. All the above steps suggested dont work.
Giving up.

Hi, @swapansanjay. Could you provide more details of your system? What distro are you using? Which version? What happens when you try to start genie? Are you having trouble installing the required components? Let me know, maybe you could give it one more chance.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 17, 2021

@tdcosta100 genie author here. Just a quick note or two:

  1. The first line in

genie -i > /dev/null &
genie -s

isn't actually necessary. The commands to do something inside the bottle (-s, -l, and -c) all initialize the bottle automatically if it hasn't been already. -i exists so that you can get systemd services running without opening a shell/running a command or so that you can preinitialize it to start faster the first time you use one of the others.

  1. If it looks like it's timing out or times out at the "Waiting for systemd...!!!" stage, that means one or more of your systemd units is failing. You should probably fix that, because while the examples I've seen so far are innocuous, there's no guarantee all of them are. Notes on known-to-cause-issues units are available on the genie repo wiki. (1.37, forthcoming, will automatically list them for you to make this process easier.)
  2. It's also a good idea to shut down systemd and its units properly using the shutdown option in your GUI or wsl genie -u from a Windows prompt before terminating the distro or shutting down Windows. While systemd services are robust enough to handle it most of the time, just using wsl --terminate <distro> or wsl --shutdown is in many ways like yanking the power cord on a Linux machine; not to be recommended, no matter how many times you get away with it.
  1. First of all, a huge thank you for providing such a incredible useful tool like systemd-genie. It's the reason my tutorial is not a huge amount of complex commands everytime you want to start a complete systemd environment. The setup is not so easy, but once everything is put on its place, it just works (at least for most time).

  2. I wasn't aware of these details. I will improve the tutorial, so it matches the correct usage. Originally I used genie -c journalctl -f, but it stopped working properly some versions ago. Now, after disabling the recommended units and adjusting some settings like described here, it worked very well.

  3. Usually, like I'm using the GUI, I just select the "Power off" option, or if I'm in a shell window, I do a sudo init 0 before wsl --shutdown. These are good approaches, or it's better to stick with the genie -u option?

Thanks for being here to interact with us. Your advice to improve the tutorial is welcome =).

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 17, 2021

@tdcosta100 If I have a GUI program in GNOME I want to run and it is giving me an error

Error: Unable to initialize gtk, is DISPLAY set properly?

How can I fix this? I have tried adding export DISPLAY=local:0.0 to my runcom file (.zshrc) within GNOME and then re-sourcing (i.e. source ~/.zshrc), but this does not work. I am using xrdponlocalhost:3390`.

Hi, @adamgranthendry. This problem seems to be similar to @siegLoesch's one. Can you look at the solution I pointed to him and check if it works for you?

@adamgranthendry

This comment has been minimized.

Copy link

@adamgranthendry adamgranthendry commented Apr 17, 2021

@tdcosta100 It was actually a simple error. I tried to run the GUI as root. I needed to switch to my user (hendra11) since we log into xrdp as a user, not root. The GUI works great afterwards! (If the DISPLAY error pops up, it is in fact as simple as using export DISPLAY=:10.0)

@cerebrate

This comment has been minimized.

Copy link

@cerebrate cerebrate commented Apr 17, 2021

Usually, like I'm using the GUI, I just select the "Power off" option, or if I'm in a shell window, I do a sudo init 0 before wsl --shutdown. These are good approaches, or it's better to stick with the genie -u option?

Sure, either of those will work: all genie -u actually does is run systemctl poweroff inside the bottle and wait for it to complete, so init 0/shutdown now/a GUI "power off", etc., etc., all end up in the same place, anyway. As long as it runs to completion before you wsl --shutdown or shutdown windows, everything should be fine.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 17, 2021

@tdcosta100 It was actually a simple error. I tried to run the GUI as root. I needed to switch to my user (hendra11) since we log into xrdp as a user, not root. The GUI works great afterwards! (If the DISPLAY error pops up, it is in fact as simple as using export DISPLAY=:10.0)

@adamgranthendry, nice to know you found a solution. Indeed, running the GUI as root is bad from de security point of view, and also from the usability as well. Thank you for sharing your solution.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 17, 2021

Usually, like I'm using the GUI, I just select the "Power off" option, or if I'm in a shell window, I do a sudo init 0 before wsl --shutdown. These are good approaches, or it's better to stick with the genie -u option?

Sure, either of those will work: all genie -u actually does is run systemctl poweroff inside the bottle and wait for it to complete, so init 0/shutdown now/a GUI "power off", etc., etc., all end up in the same place, anyway. As long as it runs to completion before you wsl --shutdown or shutdown windows, everything should be fine.

@cerebrate, nice! I was worried I wasn't using it the appropriate way. Thank you! Looking forward the new systemd-genie version you are preparing!

Edit: already using it, very nice!

@kangarooo

This comment has been minimized.

Copy link

@kangarooo kangarooo commented Apr 22, 2021

image

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 23, 2021

Hi, @kangarooo. What distro are you using? What package did you select in tasksel (Installing GUI section)?

@kangarooo

This comment has been minimized.

Copy link

@kangarooo kangarooo commented Apr 23, 2021

Hi, @kangarooo. What distro are you using? What package did you select in tasksel (Installing GUI section)?

Ubuntu 20.04 LTS
Kubuntu-desktop in tasksel added

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Apr 23, 2021

Hi, @kangarooo. What distro are you using? What package did you select in tasksel (Installing GUI section)?

Ubuntu 20.04 LTS
Kubuntu-desktop in tasksel added

@kangarooo, once you didn't install GNOME, you can skip the sudo -H -u gdm vncpasswd command. Did you succeed in connecting to port 5900/5901?

@To-beas

This comment has been minimized.

Copy link

@To-beas To-beas commented May 8, 2021

Hi,

@tdcosta100: Danke for the help. The genie-tool's working fine even if you start it 2 times until systemd is started.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented May 8, 2021

Hi, @To-beas! Nice to hear from you! I think systemd-genie is more stable too, so it's easier to use and troubleshoot.

@hdhnl

This comment has been minimized.

Copy link

@hdhnl hdhnl commented Aug 29, 2021

Hi, @tdcosta. The script works perfectly!
Is it possible to activate the sound function?
Thanks a lot, @cerebrate for the system genie!

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Aug 30, 2021

Hi, @hdhnl. You must have an audio server, pretty much like people use X410 or VcXsrv. I never tried, but these links below might be useful to you:

https://x410.dev/cookbook/wsl/enabling-sound-in-wsl-ubuntu-let-it-sing/

microsoft/WSL#4205

@hdhnl

This comment has been minimized.

Copy link

@hdhnl hdhnl commented Aug 30, 2021

Thank you for the immediate response, @tdcosta100!

@anujgoyaljnu

This comment has been minimized.

Copy link

@anujgoyaljnu anujgoyaljnu commented Sep 10, 2021

Hi! I could not follow it from the section on 'accessing the VNC screen'. Could you please tell me the steps? And please be as elaborate as possible since I'm quite new to this. I'm using Debian version 10 wsl. How do I connect to port 5900/5901?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 10, 2021

Hi, @anujgoyaljnu. First, you need a VNC Viewer. You can download it from RealVNC, TightVNC or TigerVNC. There are other viewers, but these are very common. I use the VNC Viewer from RealVNC. Once you have your VNC Viewer opened, you will have to enter the host addres and port. Once you are connecting to your own computer, you can enter localhost:5900. If VNC Server is running, you will be prompted to enter the password you have set with vncpasswd.

If after these steps you still are facing trouble to connect, please tell me. I will help you as much as possible to me.

@anujgoyaljnu

This comment has been minimized.

Copy link

@anujgoyaljnu anujgoyaljnu commented Sep 11, 2021

Hi, @anujgoyaljnu. First, you need a VNC Viewer. You can download it from RealVNC, TightVNC or TigerVNC. There are other viewers, but these are very common. I use the VNC Viewer from RealVNC. Once you have your VNC Viewer opened, you will have to enter the host addres and port. Once you are connecting to your own computer, you can enter localhost:5900. If VNC Server is running, you will be prompted to enter the password you have set with vncpasswd.

If after these steps you still are facing trouble to connect, please tell me. I will help you as much as possible to me.

So, I used wsl hostname -I to find out the host address of my WSL2. Then I tried to connect to the host address using VNC Viewer. It tried to connect for about 30 seconds and then a dialogue box appeared. Attached herewith is a screenshot of the dialogue box.
image

Could you confirm if the host address of WSL is in the following format abc.de.fg.ij with all the characters except . being numeric. Could you show where to put the host address and the port in VNC Viewer sharing some screenshot?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 12, 2021

So, I used wsl hostname -I to find out the host address of my WSL2. Then I tried to connect to the host address using VNC Viewer. It tried to connect for about 30 seconds and then a dialogue box appeared. Attached herewith is a screenshot of the dialogue box.
image

Could you confirm if the host address of WSL is in the following format abc.de.fg.ij with all the characters except . being numeric. Could you show where to put the host address and the port in VNC Viewer sharing some screenshot?

Using localhost:5900 is just fine, you don't need to put your WSL2 hostname or IP address. You enter it at the box with the caption "Enter a VNC Server address or search".

After checking if your address was correctly put, you need to check if VNC Server is running in your WSL instance. You can do it after the command genie -i. These are the steps:

  1. Enter genie -s commmand. You will gain access to your genie instance.
  2. To check if VNC Server started correctly, enter the command journalctl -b -t /usr/lib/gdm3/gdm-x-session -t /usr/bin/Xorg --no-pager
  3. If possible, paste the result here, so I can analyse it and tell you if everything is running ok. Anyway, it will give you a good clue of what is happening.

Hope these steps help you, but if not, just tell me what happened, specially at step 2, then I can provide you more help.

@anujgoyaljnu

This comment has been minimized.

Copy link

@anujgoyaljnu anujgoyaljnu commented Sep 12, 2021

So, I used wsl hostname -I to find out the host address of my WSL2. Then I tried to connect to the host address using VNC Viewer. It tried to connect for about 30 seconds and then a dialogue box appeared. Attached herewith is a screenshot of the dialogue box.
image
Could you confirm if the host address of WSL is in the following format abc.de.fg.ij with all the characters except . being numeric. Could you show where to put the host address and the port in VNC Viewer sharing some screenshot?

Using localhost:5900 is just fine, you don't need to put your WSL2 hostname or IP address. You enter it at the box with the caption "Enter a VNC Server address or search".

After checking if your address was correctly put, you need to check if VNC Server is running in your WSL instance. You can do it after the command genie -i. These are the steps:

  1. Enter genie -s commmand. You will gain access to your genie instance.
  2. To check if VNC Server started correctly, enter the command journalctl -b -t /usr/lib/gdm3/gdm-x-session -t /usr/bin/Xorg --no-pager
  3. If possible, paste the result here, so I can analyse it and tell you if everything is running ok. Anyway, it will give you a good clue of what is happening.

Hope these steps help you, but if not, just tell me what happened, specially at step 2, then I can provide you more help.

I put localhost:5900 in the designated spot that you mentioned. But it showed an error. Here's a screenshot.
image

Here is a screenshot of the result when I do steps 1 and 2.
image

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 14, 2021

@anujgoyaljnu That's very strange, Xorg is not being started at all. Did you install Ubuntu Desktop (step 3 of "Installing GUI" section)?

@anujgoyaljnu

This comment has been minimized.

Copy link

@anujgoyaljnu anujgoyaljnu commented Sep 14, 2021

@tdcosta100 I installed Debian desktop environment because Ubuntu was not an option. I think that is because I have Debian distro. Here's a screenshot.
image

@hdhnl

This comment has been minimized.

Copy link

@hdhnl hdhnl commented Sep 14, 2021

@anujgoyaljnu, Is the whole process easy, with debian?

@anujgoyaljnu

This comment has been minimized.

Copy link

@anujgoyaljnu anujgoyaljnu commented Sep 14, 2021

@hdhnl Not really. You go through exactly the same procedure.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 14, 2021

@tdcosta100 I installed Debian desktop environment because Ubuntu was not an option. I think that is because I have Debian distro. Here's a screenshot.
image

Since my tutorial is targeted to Ubuntu, some steps are slightly different, so you need to have some extra effort to make everything working correctly. Yor screenshot doesn't show any graphical environment selected. You have to choose one. My tutorial fits better with GNOME installed. Did you explicitly chose GNOME? If so, can you provide a new screenshot showing it already installed?

@anujgoyaljnu

This comment has been minimized.

Copy link

@anujgoyaljnu anujgoyaljnu commented Sep 15, 2021

@tdcosta100 I installed Debian desktop environment because Ubuntu was not an option. I think that is because I have Debian distro. Here's a screenshot.
image

Since my tutorial is targeted to Ubuntu, some steps are slightly different, so you need to have some extra effort to make everything working correctly. Yor screenshot doesn't show any graphical environment selected. You have to choose one. My tutorial fits better with GNOME installed. Did you explicitly chose GNOME? If so, can you provide a new screenshot showing it already installed?

Hi @tdcosta100 The red marker in my screenshot indicates the environment selected. Also, the steps would be along the same lines even in Debian, no?

I already installed GNOME. Attached herewith is a screenshot that indicates that GNOME is already installed.
image

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 15, 2021

@anujgoyaljnu Actually you need to press spacebar to select the packages to be installed. The red marker is just the cursor. The selected items for install are marked with an asterisk (*). You need to install Debian desktop environment, and at least GNOME. After selecting the packages you want, you need to use tab to confirm the installation, like below:

image

@anujgoyaljnu

This comment has been minimized.

Copy link

@anujgoyaljnu anujgoyaljnu commented Sep 15, 2021

Hi @tdcosta100! I've installed GNOME and Debian Desktop Environment. However, I again ran the two commands that you had recommended. Xorg is not starting even now.
image
image

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 15, 2021

Hi @tdcosta100! I've installed GNOME and Debian Desktop Environment. However, I again ran the two commands that you had recommended. Xorg is not starting even now.
image
image

Great, now it's better. But after executing genie -i, you need to execute genie -s to enter inside Genie environment. Only after that you run journalctl. Please try that and tell me if it makes any difference.

@hdhnl

This comment has been minimized.

Copy link

@hdhnl hdhnl commented Sep 15, 2021

# Debian bullseye installation on wsl2 according to @tdcosta100 tutorial
# Debian must be installed from the Microsoft Store if we want Debian bullseye

sudo apt update
sudo apt dist-upgrade

sudo apt install git wget curl lsb-release
sudo apt install dbus policykit-1 daemonize systemd-container gawk

sudo apt install tasksel # I think it's already installed
sudo tasksel # Just choose Gnome (and SSH server if you want), but not Debian desktop environment.
             # At least in my case.

sudo apt install tigervnc-standalone-server

# dotnet-runtime
sudo wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt-get install -y apt-transport-https
sudo apt update
sudo apt-get install -y dotnet-sdk-5.0

# systemd-genie. Setting up Systemd from this post: https://waliwaqars.medium.com/setting-up-the-perfect-wsl-environment-for-routine-use-with-gui-and-audio-35316759872f
deb_name=`curl -s https://api.github.com/repos/arkane-systems/genie/releases/latest | grep name | grep deb | cut -d '"' -f 4`
sudo wget https://github.com/arkane-systems/genie/releases/latest/download/$deb_name
sudo dpkg -i $deb_name
sudo apt install -y systemd-genie
genie -i > /dev/null

vncpasswd
sudo -H -u Debian-gdm vncpasswd

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

# Then continue with the remaining sections. "Replacing default X by Xvnc" etc.

Debianwsl2-tdcosta100-Screenshot 2021-09-15 211650

Debianwsl2-tdcosta100-1-Screenshot 2021-09-15 211854

Debian-wsl2-tdcosta100 -2-Screenshot 2021-09-15 213006

@anujgoyaljnu

This comment has been minimized.

Copy link

@anujgoyaljnu anujgoyaljnu commented Sep 16, 2021

Hi @tdcosta100! I've installed GNOME and Debian Desktop Environment. However, I again ran the two commands that you had recommended. Xorg is not starting even now.
image
image

Great, now it's better. But after executing genie -i, you need to execute genie -s to enter inside Genie environment. Only after that you run journalctl. Please try that and tell me if it makes any difference.

Hi @tdcosta100! I did. It doesn't make any difference.
image

@MrRendroc

This comment has been minimized.

Copy link

@MrRendroc MrRendroc commented Sep 16, 2021

I have the same problem as @anujgoyaljnu and I am also on Debian.
I can run /usr/bin/Xorg from a command line and then connect with the VNC viewer, but I'm guessing my genie doesn't seem to be configured properly because the VNC viewer times out the same as @anujgoyaljnu with the same journalctl output.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 17, 2021

@hdhnl, a huge THANK YOU for sumarizing the Debian setup! That's great! I will update the tutorial to give more specific instructions for Debian.

I have the same problem as @anujgoyaljnu and I am also on Debian.
I can run /usr/bin/Xorg from a command line and then connect with the VNC viewer, but my genie doesn't seem to be configured properly because I timeout if I use that as instructed.

@MrRendroc, I did the Debian setup, and you have to install the Debian version of dotnet-runtime and genie, if you install Ubuntu version of these components, they will probably fail. You also have to mask the unit systemd-modules-load.service with the command sudo systemctl mask systemd-modules-load.service.

Hi @tdcosta100! I did. It doesn't make any difference.
image

@anujgoyaljnu, could you please try the modified command below?

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

Also, I updated the tutorial. You can repeat the steps and see if this time it works.

@hdhnl

This comment has been minimized.

Copy link

@hdhnl hdhnl commented Sep 17, 2021

@hdhnl, a huge THANK YOU for sumarizing the Debian setup! That's great! I will update the tutorial to give more specific instructions for Debian.

@tdcosta100 It’s my pleasure.
Glad to help.

@anujgoyaljnu

This comment has been minimized.

Copy link

@anujgoyaljnu anujgoyaljnu commented Sep 17, 2021

@anujgoyaljnu, could you please try the modified command below?

journalctl -b -t /usr/libexec/gdm-x-session -t /usr/bin/Xorg --no-pager
Also, I updated the tutorial. You can repeat the steps and see if this time it works.

I tried to incorporate the changes that @hdhnl suggested. I also did what you suggested to @MrRendroc. And then I ran the three commands that you'd asked me to. Still, nothing changed.
image

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 18, 2021

@anujgoyaljnu, can I suppose you didn't restart your WSL instance? If so, please enter genie -u in Debian shell, and after that, in Start Menu you enter wsl --shutdown, and after that you start your Debian shell again.

If it still not working, try the following steps:

  1. Uninstall dotnet-runtime-5.0 and systemd-genie, and install them again, this time using the new Debian-specific instructions.
  2. Reset your Debian WSL (at Start Menu, go to Debian app configuration, and press the "Reset" button. Then you follow the entire tutorial again.

There is something strange with your WSL installation, probably genie is not starting correctly due to faulting units. You need to wait for genie to start completely, and show you if there are any startup errors. Probably you will have to disable some units with systemd before everything works fine.

@MrRendroc

This comment has been minimized.

Copy link

@MrRendroc MrRendroc commented Sep 18, 2021

I switched to Ubuntu and KDE Plasma.
I thought that Ubuntu would be easier, and it was in most cases, but tasksel bombed out on me a couple of times installing Kubuntu-Desktop (something to do with mlocate not ignoring /mnt, and muon didn't install).
To get KDE Plasma to work I had to switch to lightdm (not gdm3 or sddm, which I think was the default for Kubuntu-Desktop).

I still have genie -s hanging the first time I run it (it waits forever for systemd), but when I interrupt and then run it again it starts up OK.

The last part was turning off JPEG in TigerVNC. Then I finally got my KDE Desktop in WSL2 Ubuntu 20.04.

@anujgoyaljnu

This comment has been minimized.

Copy link

@anujgoyaljnu anujgoyaljnu commented Sep 18, 2021

I reset my WSL and restarted the whole installation procedure for systemd-genie. I installed GNOME and Debian Desktop Environment, and dotnet-runtime-5.0 following the instructions on this page[https://github.com/arkane-systems/genie#installation]. However, when I try to add the wsl-translinux repository, this is what happens.
image

@cerebrate

This comment has been minimized.

Copy link

@cerebrate cerebrate commented Sep 18, 2021

You typoed $(lsb_release -cs) as %(lsb-release -cs) in the second line of the command.

@MrRendroc

This comment has been minimized.

Copy link

@MrRendroc MrRendroc commented Sep 19, 2021

The fix for the genie -s hanging waiting for systemd:
https://githubmemory.com/repo/arkane-systems/genie/issues/122
sudo systemctl disable ssh.service multipathd.service multipathd.socket
sudo systemctl mask systemd-remount-fs.service

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 19, 2021

Guys, you really should read this page.

And to know what units to mask after starting genie for the first time: sudo systemctl list-units --failed. @MrRendroc doesn't need because he already found what was going wrong =P.

@MrRendroc

This comment has been minimized.

Copy link

@MrRendroc MrRendroc commented Sep 19, 2021

Thanks, I read that systemd fix page but I didn't understand what it was talking about until I ran that command you just mentioned sudo systemctl list-units --failed

Also I made a PowerShell script that starts up and shuts down genie/WSL.
It works, but do you think this is a bad idea?

wsl -d Ubuntu genie -i
& 'C:\Program Files (x86)\TigerVNC\vncviewer.exe'
wsl -d ubuntu genie -s
wsl -d ubuntu genie -u
wsl -t ubuntu
wsl --shutdown
wsl -l -v
@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 19, 2021

To my eyes it seems ok, specially because you shut the genie container before terminating WSL instance. But some questions about it:

  • Why wsl -d ubuntu genie -s? You start a genie shell before shutting it down?
  • If you are going to do a wsl --shutdown, then you don't need to terminate your ubuntu distribution first

But you don't really need to change anything, if it's working for you.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 19, 2021

I updated the tutorial to make it more clear about checking the failed systemd units. Thank you, @MrRendroc for pointing that.

@MrRendroc

This comment has been minimized.

Copy link

@MrRendroc MrRendroc commented Sep 19, 2021

Why wsl -d ubuntu genie -s? You start a genie shell before shutting it down?

I'm probably still confused, but the shell is there waiting for me while I run my VNC session.

  • If I properly shutdown from within my GUI desktop, systemd is terminated, this genie shell will be closed and the script continues
  • If my VNC session ends without shutting down, the shell will be waiting for me to run sudo init 0 before continuing the script.

I guess I don't need the genie -u in either case, so I have removed it.

If you are going to do a wsl --shutdown, then you don't need to terminate your ubuntu distribution first

I saw it recommended on some other forum for some reason so I thought it wouldn't hurt.

Actually, it would preferable to only shutdown the distro I'm using for the desktop, and leave any others running. Do you think I could forgo the wsl --shutdown instead of getting rid of wsl -t?

@MrRendroc

This comment has been minimized.

Copy link

@MrRendroc MrRendroc commented Sep 19, 2021

I'm just learning PowerShell, but I think this is more elegant:

param([string]$Distro='Ubuntu',[string]$vncviewer='C:\Program Files (x86)\TigerVNC\vncviewer.exe')

wsl -l -v
wsl -d $Distro genie -i
Start-Process -FilePath $vncviewer -Wait
Write-Output "VNC session ended, checking for shutdown."
Start-Sleep -s 1
$systemd = wsl -d $Distro genie -r
Write-Output "systemd is $systemd."
if ( $systemd -ne 'stopped' )
{
    Write-Output "Stopping genie."
    wsl -d $Distro genie -u
}
wsl -t $Distro
wsl --shutdown
wsl -l -v

I would still like to know what you think about using wsl -t instead of wsl --shutdown so I can keep any other WSL distros running?

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Sep 20, 2021

@MrRendroc, it depends on what you are trying to achieve. If you have more than one distro, of course it's far better to use wsl -t, because wsl --shutdown is like pulling the power cord of your distros. That is, if they are not yet prepared for being shut down, they could be damaged, so you must not use it in this scenario. Otherwise, it's very good to do a wsl --shutdown, because you make sure you are not wasting resources running the virtualization infrastructure for running your distros. But wsl --shutdown also terminate all running distros at the moment, so if so, why terminate your distro just before calling a command that will terminate all distros and unload allocated resources? But like you said, doing so doesn't hurt anyone, so if it's more clear to you, then it doesn't have any side effects AND, OF COURSE, doesn't have more than one distro. If you have more than one distro running, you must properly shut down each one before shutting WSL down.

About your concern with VNC Session being ended without ending your genie session first (probably an accidental close?), you can do regular checks with a while (<systemd running>) { Start-Sleep -s 1 }, or even relaunch VNC Viewer until you properly end the session: while (<systemd running>) { Start-Process -FilePath $vncviewer -Wait }. Calling genie -u is an unconditional shutdown, and according to @cerebrate (man, I really like your work with genie) is equivalent to sudo init 0 or sudo systemctl shutdown (or the shutdown menu of your GUI). Use if you want to enforce the shutdown after closing the VNC Viewer. Again, it depends on what you want to achieve. To my eyes, your second script is better than the first, because it does more checks and is more flexible.

@HiDe-Techno-Tips

This comment has been minimized.

Copy link

@HiDe-Techno-Tips HiDe-Techno-Tips commented Oct 19, 2021

Someone please help me:

Did everything as in the guide.

hide@DESKTOP-BUQISCV:~$ genie -s
genie: failed to unmount binfmt_misc filesystem; attempting to continue
Waiting for systemd....!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Timed out waiting for systemd to enter running state.
This may indicate a systemd configuration error.
Attempting to continue.
Failed units will now be displayed (systemctl list-units --failed):
  UNIT            LOAD   ACTIVE SUB    DESCRIPTION
● lightdm.service loaded failed failed Light Display Manager
● lxc-net.service loaded failed failed LXC network bridge setup

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
2 loaded units listed.

hide@DESKTOP-BUQISCV-wsl:~$
@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Oct 23, 2021

Hi, @HiDe-Techno-Tips. That's a very strange error. What distro and version are you using for your setup? Did you try to make the standard setup (Ubuntu 20.04 + GDM3) before trying LightDM, and it worked well?

@HiDe-Techno-Tips

This comment has been minimized.

Copy link

@HiDe-Techno-Tips HiDe-Techno-Tips commented Oct 24, 2021

@tdcosta100, Thanks for responding. I am in Debian 11 and it used to work fine with LightDM and KDE-Plasma in windows 10. I never tried GDM3 or Ubuntu. The error started to show up after updating to Windows 11, however that may not be the exact reason.

@HiDe-Techno-Tips

This comment has been minimized.

Copy link

@HiDe-Techno-Tips HiDe-Techno-Tips commented Oct 24, 2021

@tdcosta100, Heres the output for journalctl -u lightdm:

Oct 24 09:19:23 DESKTOP-BUQISCV-wsl systemd[1]: Starting Light Display Manager...
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: Started Light Display Manager.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Main process exited, code=exited, status=1/FAILURE
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Failed with result 'exit-code'.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Scheduled restart job, restart counter is at 1.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: Stopped Light Display Manager.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: Starting Light Display Manager...
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: Started Light Display Manager.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Main process exited, code=exited, status=1/FAILURE
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Failed with result 'exit-code'.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Scheduled restart job, restart counter is at 2.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: Stopped Light Display Manager.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: Starting Light Display Manager...
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: Started Light Display Manager.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Main process exited, code=exited, status=1/FAILURE
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Failed with result 'exit-code'.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Scheduled restart job, restart counter is at 3.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: Stopped Light Display Manager.
Oct 24 09:19:24 DESKTOP-BUQISCV-wsl systemd[1]: Starting Light Display Manager...
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: Started Light Display Manager.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Main process exited, code=exited, status=1/FAILURE
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Failed with result 'exit-code'.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Scheduled restart job, restart counter is at 4.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: Stopped Light Display Manager.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: Starting Light Display Manager...
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: Started Light Display Manager.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Main process exited, code=exited, status=1/FAILURE
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Failed with result 'exit-code'.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Scheduled restart job, restart counter is at 5.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: Stopped Light Display Manager.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Start request repeated too quickly.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Failed with result 'exit-code'.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: Failed to start Light Display Manager.
Oct 24 09:19:25 DESKTOP-BUQISCV-wsl systemd[1]: lightdm.service: Triggering OnFailure= dependencies.

Heres the lightdm log file from /var/log/lightdm/lightdm.log:

[+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log
[+0.00s] DEBUG: Starting Light Display Manager 1.26.0, UID=0 PID=341
[+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/01_debian.conf
[+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/40-kde-plasma-kf5.conf
[+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
[+0.00s] DEBUG: Using Xephyr for X servers
[+0.00s] DEBUG: Registered seat module local
[+0.00s] DEBUG: Registered seat module xremote
[+0.00s] DEBUG: Registered seat module unity
[+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager
[+0.01s] DEBUG: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ‘gio-vfs’
[+0.01s] DEBUG: Monitoring logind for seats
[+0.01s] DEBUG: New seat added from logind: seat0
[+0.01s] DEBUG: Seat seat0: Loading properties from config section Seat:*
[+0.01s] DEBUG: Seat seat0 has property CanMultiSession=no
[+0.01s] DEBUG: Seat seat0: Starting
[+0.01s] DEBUG: Seat seat0: Creating greeter session
[+0.02s] DEBUG: Seat seat0: Creating display server of type x
[+0.02s] DEBUG: Using VT 7
[+0.02s] DEBUG: Seat seat0: Starting local X display on VT 7
[+0.02s] DEBUG: XServer 0: Logging to /var/log/lightdm/x-0.log
[+0.02s] DEBUG: XServer 0: Writing X server authority to /var/run/lightdm/root/:0
[+0.02s] DEBUG: XServer 0: Launching X Server
[+0.02s] DEBUG: Launching process 362: /usr/bin/Xephyr :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
[+0.02s] DEBUG: XServer 0: Waiting for ready signal from X server :0
[+0.02s] DEBUG: Acquired bus name org.freedesktop.DisplayManager
[+0.02s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat0
[+0.03s] DEBUG: Loading users from org.freedesktop.Accounts
[+0.03s] DEBUG: User /org/freedesktop/Accounts/User1000 added
[+0.04s] DEBUG: Process 362 exited with return value 1
[+0.04s] DEBUG: XServer 0: X server stopped
[+0.04s] DEBUG: Releasing VT 7
[+0.04s] DEBUG: XServer 0: Removing X server authority /var/run/lightdm/root/:0
[+0.04s] DEBUG: Seat seat0: Display server stopped
[+0.04s] DEBUG: Seat seat0: Stopping session
[+0.04s] DEBUG: Seat seat0: Session stopped
[+0.04s] DEBUG: Seat seat0: Stopping display server, no sessions require it
[+0.04s] DEBUG: Seat seat0: Stopping; greeter display server failed to start
[+0.04s] DEBUG: Seat seat0: Stopping
[+0.04s] DEBUG: Seat seat0: Stopped
[+0.04s] DEBUG: Required seat has stopped
[+0.04s] DEBUG: Stopping display manager
[+0.04s] DEBUG: Display manager stopped
[+0.04s] DEBUG: Stopping daemon
[+0.04s] DEBUG: Exiting with return value 1

Heres /var/log/lightdm/x-0.log:

Unrecognized option: vt7
use: X [:<display>] [option]
-a #                   default pointer acceleration (factor)
-ac                    disable access control restrictions
-audit int             set audit trail level
-auth file             select authorization file
-br                    create root window with black background
+bs                    enable any backing store support
-bs                    disable any backing store support
-c                     turns off key-click
c #                    key-click volume (0-100)
-cc int                default color visual class
-nocursor              disable the cursor
-core                  generate core dump on fatal error
-displayfd fd          file descriptor to write display number to when ready to connect
-dpi int               screen resolution in dots per inch
-dpms                  disables VESA DPMS monitor control
-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs
-f #                   bell base (0-100)
-fc string             cursor font
-fn string             default font name
-fp string             default font path
-help                  prints message with these options
+iglx                  Allow creating indirect GLX contexts
-iglx                  Prohibit creating indirect GLX contexts (default)
-I                     ignore all remaining arguments
-ld int                limit data space to N Kb
-lf int                limit number of open files to N
-ls int                limit stack space to N Kb
-nolock                disable the locking mechanism
-maxclients n          set maximum number of clients (power of two)
-nolisten string       don't listen on protocol
-listen string         listen on protocol
-noreset               don't reset after last client exists
-background [none]     create root window with no background
-reset                 reset after last client exists
-p #                   screen-saver pattern duration (minutes)
-pn                    accept failure to listen on all ports
-nopn                  reject failure to listen on all ports
-r                     turns off auto-repeat
r                      turns on auto-repeat
-render [default|mono|gray|color] set render color alloc policy
-retro                 start with classic stipple and cursor
-s #                   screen-saver timeout (minutes)
-seat string           seat to run on
-t #                   default pointer threshold (pixels/t)
-terminate             terminate at server reset
-to #                  connection time out
-tst                   disable testing extensions
ttyxx                  server started from init on /dev/ttyxx
v                      video blanking for screen-saver
-v                     screen-saver without video blanking
-wm                    WhenMapped default backing-store
-wr                    create root window with white background
-maxbigreqsize         set maximal bigrequest size
+xinerama              Enable XINERAMA extension
-xinerama              Disable XINERAMA extension
-dumbSched             Disable smart scheduling and threaded input, enable old behavior
-schedInterval int     Set scheduler interval in msec
-sigstop               Enable SIGSTOP based startup
+extension name        Enable extension
-extension name        Disable extension
-query host-name       contact named host for XDMCP
-broadcast             broadcast for XDMCP
-multicast [addr [hops]] IPv6 multicast for XDMCP
-indirect host-name    contact named host for indirect XDMCP
-port port-num         UDP port number to send messages to
-from local-address    specify the local address to connect from
-once                  Terminate server after one session
-class display-class   specify display class to send in manage
-cookie xdm-auth-bits  specify the magic cookie for XDMCP
-displayID display-id  manufacturer display ID for request
[+-]accessx [ timeout [ timeout_mask [ feedback [ options_mask] ] ] ]
                       enable/disable accessx key sequences
-ardelay               set XKB autorepeat delay
-arinterval            set XKB autorepeat interval

TinyX Device Dependent Usage:
-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][+[-]XOFFSET][+[-]YOFFSET][@ROTATION][X][Y][xDEPTH/BPP[xFREQ]]  Specify screen characteristics
-rgba rgb/bgr/vrgb/vbgr/none   Specify subpixel ordering for LCD panels
-mouse driver [,n,,options]    Specify the pointer driver and its options (n is the number of buttons)
-keybd driver [,,options]      Specify the keyboard driver and its options
-xkb-rules       Set default XkbRules value (can be overriden by -keybd options)
-xkb-model       Set default XkbModel value (can be overriden by -keybd options)
-xkb-layout      Set default XkbLayout value (can be overriden by -keybd options)
-xkb-variant     Set default XkbVariant value (can be overriden by -keybd options)
-xkb-options     Set default XkbOptions value (can be overriden by -keybd options)
-zaphod          Disable cursor screen switching
-2button         Emulate 3 button mouse
-3button         Disable 3 button mouse emulation
-rawcoord        Don't transform pointer coordinates on rotation
-dumb            Disable hardware acceleration
-softCursor      Force software cursor
-videoTest       Start the server, pause momentarily and exit
-origin X,Y      Locates the next screen in the the virtual screen (Xinerama)
-switchCmd       Command to execute on vt switch
vtxx             Use virtual terminal xx instead of the next available

Xephyr Option Usage:
-parent <XID>        Use existing window as Xephyr root win
-sw-cursor           Render cursors in software in Xephyr
-fullscreen          Attempt to run Xephyr fullscreen
-output <NAME>       Attempt to run Xephyr fullscreen (restricted to given output geometry)
-grayscale           Simulate 8bit grayscale
-resizeable          Make Xephyr windows resizeable
-glamor              Enable 2D acceleration using glamor
-glamor_gles2        Enable 2D acceleration using glamor (with GLES2 only)
-glamor-skip-present Skip presenting the output when using glamor (for internal testing optimization)
-fakexa              Simulate acceleration using software rendering
-verbosity <level>   Set log verbosity level
-noxv                do not use XV
-name [name]         define the name in the WM_CLASS property
-title [title]       set the window title in the WM_NAME property
-no-host-grab        Disable grabbing the keyboard and mouse.

(EE)
Fatal server error:
(EE) Unrecognized option: vt7
(EE)

I hope you can help me figure this out. Thanks.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Oct 24, 2021

@HiDe-Techno-Tips that's very useful info, thanks. So LightDM is failing, and this is because X is failing. Did you check your Xorg script? Maybe it was replaced by the original version, which of course cannot work correctly with our setup. Note the modified Xorg script does the handling of the vt* option.

@HiDe-Techno-Tips

This comment has been minimized.

Copy link

@HiDe-Techno-Tips HiDe-Techno-Tips commented Oct 25, 2021

@tdcosta100, Is this not right?

hide@DESKTOP-BUQISCV:~$ cat /usr/bin/Xorg
#!/bin/bash
for arg do
  shift
  case $arg in
    # Xvnc doesn't support vtxx argument. So we convert to ttyxx instead
    vt*)
      set -- "$@" "${arg//vt/tty}"
      ;;
    # -keeptty is not supported at all by Xvnc
    -keeptty)
      ;;
    # -novtswitch is not supported at all by Xvnc
    -novtswitch)
      ;;
    # other arguments are kept intact
    *)
      set -- "$@" "$arg"
      ;;
  esac
done

# Here you can change or add options to fit your needs
command=("/usr/bin/Xvnc" "-geometry" "1366x768" "-PasswordFile" "${HOME:-/root}/.vnc/passwd" "$@")

systemd-cat -t /usr/bin/Xorg echo "Starting Xvnc:" "${command[@]}"

exec "${command[@]}"

Thats what it was during the error.

@HiDe-Techno-Tips

This comment has been minimized.

Copy link

@HiDe-Techno-Tips HiDe-Techno-Tips commented Oct 25, 2021

@tdcosta100, Alright, I fixed LightDM. It was caused because LightDM was using /usr/bin/Xephyr and not /usr/bin/Xorg as the Xserver. Don't know why that happened but I fixed it by replacing /usr/bin/Xephyr with the Xorg script in this step. Maybe you should mention in your tutorial that Xorg must be the default X and if it is not we need to replace the default X binary with the same Xorg script.

I am still unable to figure out why lxc-net.service is failing.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Oct 25, 2021

Thank you! I will put your suggestion to the tutorial. I hope you can figure out what is happening with lxc-net.service. Maybe it's related to systemd-genie, or WSL2.

@mohmedaref1

This comment has been minimized.

Copy link

@mohmedaref1 mohmedaref1 commented Nov 15, 2021

i got 5 errors but i managed to fix 4 of them except this one

mohamed@MohamedAref:~$ genie -s
Waiting for systemd....!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Timed out waiting for systemd to enter running state.
This may indicate a systemd configuration error.
Attempting to continue.
Failed units will now be displayed (systemctl list-units --failed):
    UNIT                 LOAD     ACTIVE       SUB               DESCRIPTION
● multipathd.socket     loaded    failed      failed        multipathd control socket

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

1 loaded units listed.
@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Nov 15, 2021

Hi, @mohmedaref1. Please check this page. The best solution is to disable or mask this unit.

@mohmedaref1

This comment has been minimized.

Copy link

@mohmedaref1 mohmedaref1 commented Nov 16, 2021

@tdcosta100 ,
I'm sorry, but how do i do that 😅
i managed to get it to work and i get the login screen

2

.
the problem is once i logged in and try to connect to port 5901 i get a black screen it's the right port but why it's a black screen

1

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Nov 16, 2021

@tdcosta100 , I'm sorry, but how do i do that 😅

sudo systemctl mask multipathd.socket

i managed to get it to work and i get the login screen
...
. the problem is once i logged in and try to connect to port 5901 i get a black screen it's the right port but why it's a black screen

You are almost done with your configuration. But now you have to look your log files to find out what's happening. Check the Troubleshooting section. I cannot tell you what's happening without the clues provided by the logs.

@Sampahcokk-dev

This comment has been minimized.

Copy link

@Sampahcokk-dev Sampahcokk-dev commented Nov 17, 2021

$ genie -s
genie: systemd is not supported under WSL 1.

edit:
nvm its because i use wsl 1

@mohmedaref1

This comment has been minimized.

Copy link

@mohmedaref1 mohmedaref1 commented Nov 18, 2021

hi again
that's the output for

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

-- Logs begin at Thu 2021-11-04 09:28:29 EET, end at Thu 2021-11-18 16:44:01 EET. --
-- No entries --
@mohmedaref1

This comment has been minimized.

Copy link

@mohmedaref1 mohmedaref1 commented Nov 18, 2021

i found the problem i have set up this in the .profile so i could automatically connect to display 0 for the xserver and that was the problem

if grep -q WSL2 /proc/version; then
        # execute in the windows to determine its IP address
        DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0.0
else
        # In WSL1 the DISPLAY can be the localhost address
        if grep -q icrosoft /proc/version; then
                DISPLAY=127.0.0.1:0.0
        fi
fi

i removed it and now it works fine

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Nov 19, 2021

@mohmedaref1, that's great! I'm glad you managed to finally make everything work. Your code appears to be a setup for external XServer (VcXsrv, X410, etc). This interferes with your experience with XVNCServer, so you have to setup a separate configuration in order to make everything to work properly.

@spmolnar

This comment has been minimized.

Copy link

@spmolnar spmolnar commented Dec 2, 2021

I have Debian with the Xfce4 Desktop installed with WSL2on my Windows 10 Laptop. I followed the steps in the setup without any warnings or errors, but now I'm stumped. I've gotten to the "Accessing the VNC Screen" and can't seem to get any further.

If I try lightdm I get:

comp@DESKTOP-AMVKD7B:~$ sudo lightdm
[sudo] password for comp:

** (lightdm:155): WARNING **: 15:17:16.462: Failed to get system bus: Could not connect: No such file or directory
Failed to get D-Bus connection

So I turned to the troubleshooting section.

comp@DESKTOP-AMVKD7B:~$ journalctl -b -t /usr/libexec/gdm-x-session -t /usr/bin/Xorg --no-pager
-- Journal begins at Thu 2021-12-02 11:41:28 EST, ends at Thu 2021-12-02 11:51:28 EST. --
Dec 02 11:41:28 DESKTOP-AMVKD7B-wsl /usr/bin/Xorg[189]: Starting Xvnc: /usr/bin/Xvnc -geometry 1024x768 -PasswordFile /root/.vnc/passwd :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp tty7

comp@DESKTOP-AMVKD7B:/var/log/lightdm$ sudo cat x-0.log
Failed to create stream fd: No such file or directory

Xvnc TigerVNC 1.11.0 - built 2021-03-22 21:21
Copyright (C) 1999-2020 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12010000, The X.Org Foundation

Thu Dec 2 11:56:29 2021
vncext: VNC extension running!
vncext: Listening for VNC connections on all interface(s), port 5900
vncext: created VNC server for screen 0

I installed the TightVCN Viewer, which connect, but only gives me a black screen.

Quite frankly, I am beyond my depth. Assistance will be much appreciated.

Thanks in advancd.

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Dec 2, 2021

Hi, @spmolnar.

By your x-0.log, your X server is running ok. You might check your lightdm.log to see if anything is going wrong. You should connect with the password you set at Creating VNC Server passwords section. If your can connect, but screen is black, XVNC is ok but something else is not being loaded correctly. Could you please post your lightdm.log content, so we can figure out what's happening?

@spmolnar

This comment has been minimized.

Copy link

@spmolnar spmolnar commented Dec 3, 2021

I was reasonably sure that the problem was with the lightdm. Here is the log you requested.

comp@DESKTOP-AMVKD7B:/var/log/lightdm$ sudo cat lightdm.log
[+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log
[+0.00s] DEBUG: Starting Light Display Manager 1.26.0, UID=0 PID=155
[+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/01_debian.conf
[+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
[+0.00s] DEBUG: Registered seat module local
[+0.00s] DEBUG: Registered seat module xremote
[+0.00s] DEBUG: Registered seat module unity
[+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager
[+0.00s] DEBUG: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ‘gio-vfs’
[+0.00s] WARNING: Failed to get system bus: Could not connect: No such file or directory
[+0.00s] DEBUG: Adding default seat
[+0.00s] DEBUG: Seat seat0: Loading properties from config section Seat:*
[+0.00s] DEBUG: Seat seat0: Starting
[+0.00s] DEBUG: Seat seat0: Creating greeter session
[+0.00s] DEBUG: Seat seat0: Creating display server of type x
[+0.01s] DEBUG: Using VT 7
[+0.01s] DEBUG: Seat seat0: Starting local X display on VT 7
[+0.01s] DEBUG: XServer 2: Logging to /var/log/lightdm/x-2.log
[+0.01s] DEBUG: XServer 2: Writing X server authority to /var/run/lightdm/root/:2
[+0.01s] DEBUG: XServer 2: Launching X Server
[+0.01s] DEBUG: Launching process 159: /usr/bin/X :2 -seat seat0 -auth /var/run/lightdm/root/:2 -nolisten tcp vt7 -novtswitch
[+0.01s] DEBUG: XServer 2: Waiting for ready signal from X server :2
comp@DESKTOP-AMVKD7B:/var/log/lightdm$

@tdcosta100

This comment has been minimized.

Copy link
Owner Author

@tdcosta100 tdcosta100 commented Dec 3, 2021

Hmm yes, there is something wrong. Some questions to help the issue clarification:

  1. Do you init your genie environment with genie -s or genie -i? I'm asking because in your posts, the commands are entered outside the genie bottle, and this usually brings some trouble.
  2. After initializing genie, do you try to initialize lightdm manually? Because lightdm starts by itself, you don't need to do anything.
  3. When were at the component installation, did you execute those intended explicitly for Debian instead the intended for Ubuntu?
  4. Can you execute sudo tasksel and post a screenshot of the selected features?

If you can, maybe you should reset your Debian distro and try all steps again.

@spmolnar

This comment has been minimized.

Copy link

@spmolnar spmolnar commented Dec 4, 2021

I have uninstalled and reinstalled Debian from the MS Store.

Then I reran the commands in WSL@GUIXvcn-en.

Here are the commands as they were run. There were no error messages. Deviations f from default choices in the script are tabbed. Troubleshooting results are at the end of the log.

sudo apt update && sudo apt upgrade
sudo apt install curl wget
sudo apt install tasksel
sudo tasksel
Debian desktop environment
Xfce
web server
SSH server
laptop

sudo apt install tigervnc-standalone-server
wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
sudo apt install dotnet-runtime-5.0

sudo apt install apt-transport-https
sudo wget -O /etc/apt/trusted.gpg.d/wsl-transdebian.gpg https://arkane-systems.github.io/wsl-transdebian/apt/wsl-transdebian.gpg
sudo chmod a+r /etc/apt/trusted.gpg.d/wsl-transdebian.gpg
source /etc/os-release
cat << EOF | sudo tee /etc/apt/sources.list.d/wsl-transdebian.list
deb https://arkane-systems.github.io/wsl-transdebian/apt/ $VERSION_CODENAME main
deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ $VERSION_CODENAME main
EOF
sudo apt update
sudo apt install systemd-genie

vncpasswd
no to view-only password
sudo -H vncpasswd
no to view-only password

sudo mv /usr/bin/Xorg /usr/bin/Xorg_old
sudo nano /usr/bin/Xorg_new
sudo chmod 0755 /usr/bin/Xorg_new
sudo ln -sf Xorg_new /usr/bin/Xorg

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

systemctl list-units --failed
comp@DESKTOP-AMVKD7B-wsl:~$ systemctl list-units --failed
UNIT LOAD ACTIVE SUB DESCRIPTION
0 loaded units listed.

localhost:5900 - TightVNC Viewer
X Authentication reason: Sorry, loopbck connections are not
  enabled

Troubleshooting

  journalctl -b -t /usr/libexec/gdm-x-session -t /usr/bin/Xorg --no-pager 
  comp@DESKTOP-AMVKD7B-wsl:~$ journalctl -b -t /usr/libexec/gdm-x-session -t /usr/bin/Xorg --no-pager

-- Journal begins at Sat 2021-12-04 08:51:43 EST, ends at Sat 2021-12-04 09:01:43 EST. --
Dec 04 08:51:43 DESKTOP-AMVKD7B-wsl /usr/bin/Xorg[198]: Starting Xvnc: /usr/bin/Xvnc -geometry 1024x768 -PasswordFile /root/.vnc/passwd :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp tty7

comp@DESKTOP-AMVKD7B-wsl:/var/log/lightdm$ sudo cat lightdm.log
[+0.00s] DEBUG: Logging to /var/log/lightdm/lightdm.log
[+0.00s] DEBUG: Starting Light Display Manager 1.26.0, UID=0 PID=153
[+0.00s] DEBUG: Loading configuration dirs from /usr/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /usr/share/lightdm/lightdm.conf.d/01_debian.conf
[+0.00s] DEBUG: Loading configuration dirs from /usr/local/share/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration dirs from /etc/xdg/lightdm/lightdm.conf.d
[+0.00s] DEBUG: Loading configuration from /etc/lightdm/lightdm.conf
[+0.00s] DEBUG: Registered seat module local
[+0.00s] DEBUG: Registered seat module xremote
[+0.00s] DEBUG: Registered seat module unity
[+0.00s] DEBUG: Using D-Bus name org.freedesktop.DisplayManager
[+0.01s] DEBUG: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ‘gio-vfs’
[+0.02s] DEBUG: Monitoring logind for seats
[+0.02s] DEBUG: New seat added from logind: seat0
[+0.02s] DEBUG: Seat seat0: Loading properties from config section Seat:*
[+0.02s] DEBUG: Seat seat0 has property CanMultiSession=no
[+0.02s] DEBUG: Seat seat0: Starting
[+0.02s] DEBUG: Seat seat0: Creating greeter session
[+0.05s] DEBUG: Seat seat0: Creating display server of type x
[+0.05s] DEBUG: Using VT 7
[+0.05s] DEBUG: Seat seat0: Starting local X display on VT 7
[+0.05s] DEBUG: XServer 0: Logging to /var/log/lightdm/x-0.log
[+0.05s] DEBUG: XServer 0: Writing X server authority to /var/run/lightdm/root/:0
[+0.05s] DEBUG: XServer 0: Launching X Server
[+0.05s] DEBUG: Launching process 195: /usr/bin/X :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch
[+0.05s] DEBUG: XServer 0: Waiting for ready signal from X server :0
[+0.05s] WARNING: Could not enumerate user data directory /var/lib/lightdm/data: Error opening directory '/var/lib/lightdm/data': No such file or directory
[+0.05s] DEBUG: Acquired bus name org.freedesktop.DisplayManager
[+0.05s] DEBUG: Registering seat with bus path /org/freedesktop/DisplayManager/Seat0
[+0.37s] DEBUG: Got signal 10 from process 195
[+0.37s] DEBUG: XServer 0: Got signal from X server :0
[+0.37s] DEBUG: XServer 0: Connecting to XServer :0
[+0.38s] DEBUG: Seat seat0: Display server ready, starting session authentication
[+0.38s] DEBUG: Session pid=304: Started with service 'lightdm-greeter', username 'lightdm'
[+0.39s] DEBUG: Session pid=304: Authentication complete with return value 0: Success
[+0.39s] DEBUG: Seat seat0: Session authenticated, running command
[+0.39s] DEBUG: Session pid=304: Running command /usr/sbin/lightdm-gtk-greeter
[+0.39s] WARNING: Error getting user list from org.freedesktop.Accounts: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Accounts was not provided by any .service files
[+0.39s] DEBUG: Loading user config from /etc/lightdm/users.conf
[+0.39s] DEBUG: User comp added
[+0.39s] DEBUG: Creating shared data directory /var/lib/lightdm/data/lightdm
[+0.39s] DEBUG: Session pid=304: Logging to /var/log/lightdm/seat0-greeter.log
[+0.61s] DEBUG: Activating VT 7
[+0.61s] DEBUG: Activating login1 session c1
[+0.62s] DEBUG: Seat seat0 changes active session to c1
[+0.62s] DEBUG: Session c1 is already active
[+0.91s] DEBUG: Greeter connected version=1.26.0 api=1 resettable=false
[+2.24s] DEBUG: Greeter start authentication
[+2.24s] DEBUG: Session pid=431: Started with service 'lightdm', username '(null)'
[+2.25s] DEBUG: Session pid=431: Got 1 message(s) from PAM
[+2.25s] DEBUG: Prompt greeter with 1 message(s)

comp@DESKTOP-AMVKD7B-wsl:/var/log/lightdm$ sudo cat seat0-greeter.log
** Message: 08:51:44.329: Starting lightdm-gtk-greeter 2.0.8 (Nov 4 2020, 16:56:54)
** Message: 08:51:44.330: [Configuration] Reading file: /usr/share/lightdm/lightdm-gtk-greeter.conf.d/01_debian.conf
** Message: 08:51:44.330: [Configuration] Reading file: /etc/lightdm/lightdm-gtk-greeter.conf
Excess arguments.

(lightdm-gtk-greeter:341): Gtk-WARNING **: 08:51:45.897: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 08:52:00.659: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 08:53:00.738: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 08:54:00.825: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 08:55:00.910: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 08:56:00.981: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 08:57:00.065: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 08:58:00.144: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 08:59:00.229: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 09:00:00.315: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 09:01:00.395: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 09:02:00.480: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 09:03:00.561: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 09:04:00.642: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 09:05:00.731: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 09:06:00.809: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

(lightdm-gtk-greeter:341): Gtk-WARNING **: 09:07:00.882: Drawing a gadget with negative dimensions. Did you forget to allocate a size? (node menubar owner GreeterMenuBar)

comp@DESKTOP-AMVKD7B-wsl:/var/log/lightdm$ sudo cat x-0.log

Xvnc TigerVNC 1.11.0 - built 2021-03-22 21:21
Copyright (C) 1999-2020 TigerVNC Team and many others (see README.rst)
See https://www.tigervnc.org for information on TigerVNC.
Underlying X server release 12010000, The X.Org Foundation

Sat Dec 4 08:51:43 2021
vncext: VNC extension running!
vncext: Listening for VNC connections on all interface(s), port 5900
vncext: created VNC server for screen 0

comp@DESKTOP-AMVKD7B-wsl:/var/log/lightdm$ sudo /usr/sbin/lightdm

** (lightdm:545): WARNING **: 09:11:19.500: Error getting user list from org.freedesktop.Accounts: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Accounts was not provided by any .service files
Failed to use bus name org.freedesktop.DisplayManager, do you have appropriate permissions?

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