NOTE: If you want the ultimate Linux desktop experience, I highly recommend installing Linux as your main OS. I no longer use Windows (except in a VM) so I will not be maintaining this guide anymore.
Think Xfce looks dated? Want a conventional Ubuntu experience? This tutorial will guide you through installing Ubuntu's default desktop environment, GNOME.
GNOME is one of the more complex — and that means more difficult to run — desktop environments, so for years people couldn't figure out how to run it on WSL 2. On WSL 1 it could only run using very complicated methods that didn't transfer to well WSL 2. Any forlorn attempts to run it on WSL 2 only resulted in a smoldering heap of error messages.
But now you can!
- WSL 2
- Ubuntu 20.04 (other distros not tested)
- An X server for Windows, such as VcXsrv
- Basic knowledege on how to run GUI apps with WSL 2 (not required but highly recommended)
You've been regularly updating your distro, haven't you?
sudo apt update
sudo apt upgrade
Install GNOME: (maybe go eat a snack while it's installing?)
sudo apt install ubuntu-desktop gnome
Open up your ~/.bashrc
:
nano ~/.bashrc
And paste this in at the end and save:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
export LIBGL_ALWAYS_INDIRECT=1
If you try to start GNOME now, you'll get a lot of errors. Something along the lines of this, but a ton more errors:
Unable to init server: Could not connect: Connection refused
(gnome-session-check-accelerated:6054): Gtk-WARNING **: 11:04:51.973: cannot open display: :0
Unable to init server: Could not connect: Connection refused
(gnome-session-check-accelerated:6055): Gtk-WARNING **: 11:04:52.234: cannot open display: :0
gnome-session-binary[6044]: WARNING: software acceleration check failed: Child process exited with code 1
gnome-session-binary[6044]: CRITICAL: We failed, but the fail whale is dead. Sorry....
The trick is to enable systemd
: (note that this does break a lot of stuff such as Visual Studio Code Remote)
git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh
Now shut down WSL 2: (run this in Windows)
wsl --shutdown
First, fire up your X server on Windows. Make sure you let it through your firewall and disable access control.
Now, start up Ubuntu again and start GNOME:
gnome-session
If you don't get any error messages, you should be good. Wait a few seconds for GNOME to start up.
Now you have a great GUI desktop and you won't need any intensive virtual machines anymore!
Profit?
- You can disable the screensaver with
gsettings set org.gnome.desktop.session idle-delay 0
. - You can also try KDE Plamsa using a similar method! Just
sudo apt install kde-plasma-desktop
instead and start it withstartplasma-x11
.
If you can't get this to work, try Xfce.
If you still can't get it to work, you can ask for help on an online forum such as r/bashonubuntuonwindows.
Hello,
I think I'm dabbling in something over my head, but....
Has anyone persued this with Ubuntu and Distrod to provide systemd?
I have seen discussions about genie, but have attempted to use Distrod as a first step.
I am using VcXsrv also.
After successfully installing Distrod and starting VcXsrv, an attempt to start gnome-session yields the following Debug:
rjolbrich@DESKTOP-6OBTGF6:~$ sudo gnome-session --debug
gnome-session-binary[957]: DEBUG(+): Enabling debugging
gnome-session-binary[957]: GLib-DEBUG(+): posix_spawn avoided (fd close requested)
gnome-session-binary[957]: DEBUG(+): Could not make systemd aware of QT_IM_MODULE=ibus environment variable: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
gnome-session-binary[957]: DEBUG(+): Could not make systemd aware of XMODIFIERS=@im=ibus environment variable: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
gnome-session-binary[957]: DEBUG(+): Could not make systemd aware of GNOME_DESKTOP_SESSION_ID=this-is-deprecated environment variable: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
gnome-session-binary[957]: DEBUG(+): Could not make systemd aware of XDG_MENU_PREFIX=gnome- environment variable: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
gnome-session-binary[957]: DEBUG(+): Finding a graphical session for user 0
gnome-session-binary[957]: WARNING: Could not get session id for session. Check that logind is properly installed and pam_systemd is getting used at login.
gnome-session-binary[957]: DEBUG(+): Using systemd for session tracking
gnome-session-binary[957]: GLib-GIO-DEBUG(+): _g_io_module_get_default: Found default implementation dconf (DConfSettingsBackend) for ‘gsettings-backend’
gnome-session-binary[957]: DEBUG(+): GsmManager: setting client store 0x7ff5e800f420
gnome-session-binary[957]: DEBUG(+): Could not make systemd aware of SESSION_MANAGER=local/DESKTOP-6OBTGF6:@/tmp/.ICE-unix/957,unix/DESKTOP-6OBTGF6:/tmp/.ICE-unix/957 environment variable: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
gnome-session-binary[957]: DEBUG(+): GsmXsmpServer: SESSION_MANAGER=local/DESKTOP-6OBTGF6:@/tmp/.ICE-unix/957,unix/DESKTOP-6OBTGF6:/tmp/.ICE-unix/957
gnome-session-binary[957]: DEBUG(+): emitting SessionIsActive
gnome-session-binary[957]: DEBUG(+): fill: *** Getting session 'gnome'
gnome-session-binary[957]: DEBUG(+): fill: *** Looking if /root/.config/gnome-session/sessions/gnome.session is a valid session file
gnome-session-binary[957]: DEBUG(+): Cannot use session '/root/.config/gnome-session/sessions/gnome.session': non-existing or invalid file.
gnome-session-binary[957]: DEBUG(+): fill: *** Looking if /etc/xdg/gnome-session/sessions/gnome.session is a valid session file
gnome-session-binary[957]: DEBUG(+): Cannot use session '/etc/xdg/gnome-session/sessions/gnome.session': non-existing or invalid file.
gnome-session-binary[957]: DEBUG(+): fill: *** Looking if /usr/local/share/gnome-session/sessions/gnome.session is a valid session file
gnome-session-binary[957]: DEBUG(+): Cannot use session '/usr/local/share/gnome-session/sessions/gnome.session': non-existing or invalid file.
gnome-session-binary[957]: DEBUG(+): fill: *** Looking if /usr/share/gnome-session/sessions/gnome.session is a valid session file
gnome-session-binary[957]: DEBUG(+): Cannot use session '/usr/share/gnome-session/sessions/gnome.session': non-existing or invalid file.
gnome-session-binary[957]: CRITICAL: We failed, but the fail whale is dead. Sorry....
rjolbrich@DESKTOP-6OBTGF6:~$
Like I said I may be over my head. Is this a Distrod/systemd problem or a VcXsrv problem?