Run Windows & Linux simultaneous

Recently I read about the Windows Subsystem for Linux in version 2 where I even did not know about it in version 1.

Photo by Tim Mossholder on Unsplash

As the most people I’m working in my business life on Windows. I’m a fan of all the MS Office tools, but as I’m using Linux on my private system which I don’t want to miss any more, MS Office was not available for my in private life. When I heard about WSL I knew I will need to give it a try and when I finished setting up my system, I was excited like the first time I got in touch with VMWare in the late 90s.

GNOME in Windows

This article (by the way, it is my first:) shall assist you to get Ubuntu running on your Windows host (which is really not a big thing) and get even the GNOME desktop running so you will be able to use the complete world of Linux tools & programs without the need of additional SW installations to simulate hardware.

Get WSL

To get WSL you need to register to ‘Windows Insider’ program. Once you are registered, you can proceed with ‘Start flighting’ which is the second tab on the page you are able to enter.

https://insider.windows.com/en-us/getting-started

Basically it provides you theses steps

  1. Go to Settings > Update & Security > Windows Insider Program on your Windows 10 device. (You must be an administrator on your device to see this setting.)
  2. Select the Get Started button. Under Pick an account to get started, select + to connect the Microsoft account you registered with and continue.
  3. Follow the directions on your screen to choose the experience and channel you’d like to get Insider Preview builds through. (Not sure which channel to choose? Learn more about channels.)
  4. Review the Privacy Statement and program terms, confirm, and choose Restart Now or Restart Later to finish setting up your device.
  5. Once your device restarts, make sure your data settings are set to the right level, so you can receive preview builds.
  6. Once you’ve set your data settings, go to Settings > Update & Security > Windows Update and select the Check for updates button to download the latest Insider Preview build based on the settings you chose. Your device will update like it normally would with a Windows update.
  7. Read our flight blog posts to learn more about what’s in your Insider Preview build.

Now you need to open the settings of the Windows-Insider-Program

You will find it in Settings -> updates and security -> Windows-Insider-Program

German representation of updates and security
German representation of Windows-Insider-Program

WSL settings

Now let’s set some settings. I did the listed commands in a PowerShell with administrator privileges following the instruction found on this link.

Step 1 — Enable the Windows Subsystem for Linux

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Step 2 — Update to WSL 2

You need to run an up to date Windows version so check if you need an update by Settings -> “Update & Security” -> “Check for Update”

Step 3 — Enable Virtual Machine feature

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Step 4 — Download the Linux kernel update package

download & run the update from this side (link is for x64 machines).

Step 5 — Set WSL 2 as your default version

wsl --set-default-version 2

Step 6 — Install your Linux distribution of choice

Install Ubuntu

Open the Microsoft Store and select your favorite Linux distribution.

The upcoming instruction assume that you install Ubuntu 20.04 as I did.

Ubuntu 20.04 running in Windows Subsystem for Linux

Network issues?

Once you have installed it, check if you can use the network. A simple ping google.com should be sufficient. I had problems getting any network traffic and searched the Internet for solutions. Finally the solution I found was to compress the Windows users temp folder. I have no explanation on why it helped, but it worked. So on a command window run

compact /C %temp% /i /Q

Update Ubuntu

Once Ubuntu is running and your network connection is functional you should update it by running

sudo apt-get update && sudo apt-get -y upgrade

GNOME installation & environment variables

Now it’s time for installing the graphics desktop environment GNOME by this one liner

sudo apt install -y ubuntu-desktop gnome

As you will need to redirect the graphics output to the Xserver you are going to install soon, you will need to set two environment variables. A good way to do this is by adding the following lines to the Linux users .bashrc

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk ‘{print $2}’):0

export LIBGL_ALWAYS_INDIRECT=1

Use the editor you like to edit the file e.g. by

nano ~/.bashrc

alternatively you can use these two lines to add them at the end of the file.

echo “export DISPLAY=\$(cat /etc/resolv.conf | grep nameserver | awk ‘{print \$2}’):0” >> ~/.bashrc

export LIBGL_ALWAYS_INDIRECT=1

The difference in the first expression is the escaped $.

XServer installation

Time to install an XServer on Windows. I will refer to two free versions

  1. xlaunch installable through Cygwin
  2. VcXsrv available on SourgeForge

It seems both X servers are based on the same code as they look identical. The only difference I have seen is the default display number which is -1 on VcXsrv and can not be set to that in the Cygwin version.

X server running on Windows

Install one of the above or any other XServer you want to make use of.

Click next till you reach the option to ‘Disable access control’ which you need to enable to allow your Linux system to redirect its output to it. For a list of XServer command line options you might want to refer to its manual page.

disable access control in the extra settings

Finalize the configuration step so the XServer starts waiting for client connections.

…the fail whale is dead

If you will try to start the gnome session now, you will still get error messages reported like

gnome-session-binary[22]: CRITICAL: We failed, but the fail whale is dead. Sorry….

systemd support

To fix this you will need to clone a repository from GitHub.com and run the script it contains. This enables the systemd support Linux needed for GNOME.

Install git and clone the repository needed.

sudo apt-get install -y git

git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git

This will result in getting a folder including three scripts where you will need to run the ubuntu-wsl2-systemd-script.sh

cd ubuntu-wsl2-systemd-script/

./ubuntu-wsl2-systemd-script.sh

You should see a success message at the end. On my system it is in German language and looks like this

ERFOLGREICH: Angegebener Wert wurde gespeichert.

Now it’s time to restart Linux. Open a command window or PowerShell and enter

wsl — shutdown

Re-start it opening it from the Windows start menu.

the GNOME session

The preparations finished. You are ready to run the GNOME desktop environment. Start it by calling

gnome-session &

by adding an ‘&’ you will be able to continue using the Ubuntu shell while running the gnome session in background.

Voila, there it is. The first time you will run through the initial setup :)

Once you have done this you should see the success message like this

Click on ‘Start using Ubuntu’ and enjoy running Windows and Linux desktops in parallel.

how to close it

To close the gnome-session making use of the gnome-session menu ‘Lock Out’ or ‘Power Off’ did not worked for me. I recommend to close the XServer in Windows. A double click on the X icon.

opens the ‘Exit’ dialog as well

openSuse & KDE

For an use of OpenSuse and KDE install openSUSE Leap 15.2 from the Microsoft store.

To get KDE installed run the command

sudo zypper install -t pattern kde kde_plasma

As on Ubuntu you need to

To install the editor nano run the command

sudo zypper install nano

Edit ~/.bashrc and add the statement

export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk ‘{print $2}’):0

On Windows start the XServer as desciped above.

how to start XLaunch

I would like to inform you, that I got connection errors when I opened the XServer by clicking on its icons I pinned to the task bar. It seems doing so runs it with the default settings which do not disable access control so it prevents any host from connecting to the server. For sure there is a way to provide parameters to the pinned XLaunch icon, but I assume WSL will not assign always the same IP address to the Linux installation, so getting the XServer configured to enable only the WSL instance to connect to seems to be a challenge. So prevent pinning the XServer to your task bar and open it via the Windows start menu.

Summary

In this story I hopefully was able to provide you a complete list of needed steps to get Ubuntu & its standard desktop environment running in Windows.

Although the installation process is straight forward till you get a shell running, the main challenge is the get the desktop environment running and redirected to your host.

I hope this article was helpful and would like to thank you for reading it.

Summary

In this story I hopefully was able to provide you a short introduction to ClearML.

I just touched the top of the iceberg and there is a lot more to discover like comparing experiments, and more.

Thank you for reading.

My name is Wasilios Goutas, I’m Dipl. Ing. techn. Informatik (FH) which I studied in my home town Hamburg, Germany. I’m experienced software project manager in the automotive and semiconductor industries. In my private life I’m making use of AI libraries like Keras & Tensorflow to learn more about the technology which will play a significant role in tomorrows world.

Feel free to contact me on LinkedIn.

Dipl. Ing. Technische Informatik, SW Project Manager, Data Scientist

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store