Running Ubuntu on a Windows System

From Research Computing @ TAMUQ
Jump to navigation Jump to search


The Windows Subsystem for Linux (WSL) is a feature of Windows 10 that enables you to run native Linux command-line tools directly on Windows, alongside your traditional Windows desktop and apps. WSL enables you to run Linux in a Bash shell with your choice of distribution (Ubuntu, Debian, OpenSUSE, Kali, Alpine, etc). Using Bash, you can run command-line Linux tools and apps. With a little extra work, it is even possible to launch and use GUI based applications from this Linux environment on the Windows host. This document will provide instructions to install two open source engineering packages called OOF2 and OOF3D within an Ubuntu distribution running on WSL. The same methodology can be used to install and run other GUI based programs.

Installing WSL

Detailed Microsoft instructions for installing WSL can be found here. We will summarize these steps below.

1) Open Windows PowerShell (as Administrator) and issue this command:

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

2) Enable virtualization by issuing this command in the PowerShell terminal:

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

3) Re-start the windows PC.

4) Download WSL2 from here.

5) Double click to run the downloaded package.

6) Set WSL 2 as your default by issuing the following in the PowerShell terminal:

wsl --set-default-version 2

Installing Ubuntu

In this section, we show you how to install a particular distribution and version of Linux on top of the WSL 2 subsystem. In principle, you could choose to install one of a number of other distributions and versions available on the Microsoft Store as well.

7) Open the Microsoft Store application. Find and install the "Ubuntu 20.04 LTS" Linux distribution. Once installed with the "Get" button, start Ubuntu with the "Launch" button.

8) In the Ubuntu terminal, choose an account username and password for the primary user account.

9) Once the account username and password are established, (a) configure the default Ubuntu software repositories for software updates, and (b) perform an "upgrade" to bring all installed packages up to date. (Note the use of the sudo command below; this command is the equivalent of running something as an Administrator on a Windows system. The use of sudo results in a prompt to the user for the password of the primary user account -- the one you set in step 8 earlier. This password is cached for a few minutes and subsequent invocations of sudo may not prompt you for the password.)

sudo apt-get update
sudo apt-get upgrade

If all you wish to do is to install Ubuntu on a Windows system and to use Ubuntu at the command line (in a bash shell), you may stop following the instructions here.

Installing an X Server on the Windows PC

If the intention is to run a GUI based program from within the Ubuntu terminal, we must first install something called an "X server" on the Windows system. (If only command line (non GUI) programs were to be run within the Ubuntu terminal, there would be no need to install an X server.)

10) Download an X server on the Windows PC from here. Click through the installer screens and accept all defaults.

11) In the Ubuntu terminal, download a package that contains some GUI based programs we will later use to test our setup:

sudo apt-get install x11-apps

12) In order to enable communication between our GUI applications and the X server, we must ensure the Windows firewall is not blocking such traffic. Go to Windows Defender firewall -> Allow an app or feature through Windows Defender firewall -> click Change Settings -> select BOTH entries of "VcXsrv windows server" -> click OK. If VcXsrv is not in the list, then click the "Allow another app" button, then click the "Browse" button and navigate to "C:\Program Files\VcXsrv\vcxsrv.exe", select it and click "Open". Next, click the "Add" button, and finally check all three columns (Domain, Private and Public) for this application and click the OK button.

13) Launch the X server application with the following command in a cmd window:

"C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto

14) In the Ubuntu terminal, launch the xclock program with the following two commands (the first command only directs Ubuntu to talk to the X server correctly -- it only needs to be issued once in an Ubuntu terminal):

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

If a clock window appears on screen, the X server is working correctly. Press Ctrl-C to quit xclock. Your system is now ready to host Ubuntu applications that have a graphical interface. If you wish to install applications other than OOF2 or OOF3D in your Ubuntu environment (covered below), you may stop following the instructions here.

Installing OOF2

Although here we tell you how to build and install one particular application called OOF2 (and later, OOF3D) really you could substitute any other sequence of instructions to build and install any other valid application instead.

15) In the Ubuntu terminal, type the following sequence of commands:

sudo apt-get install python-gtk2-dev libgnomecanvas2-dev libmagick++-dev liblapack-dev bison libcanberra-gtk-module
mkdir oof2-build
cd oof2-build
tar xzf oof2-2.1.19.tar.gz
cd oof2-2.1.19/
sudo python --enable-openmp build 
sudo python --enable-openmp install

16) Launch OOF2 (in the Ubuntu terminal):


Installing OOF3D

17) Install VTK 8 as a prerequisite for OOF3D. In the Ubuntu terminal:

mkdir vtk8-build
cd vtk8-build
tar xzf VTK-8.2.0.tar.gz
cd  VTK-8.2.0/
sudo apt install cmake-curses-gui libtiff-dev mesa-common-dev libgl1-mesa-dev libxt-dev
mkdir build-8.2.0
cd build-8.2.0
ccmake ../../VTK-8.2.0

Inside the interactive ccmake tool, type "c" to configure, and then "t" to get into advanced mode. Now you can set VTK configuration values. Make sure that these variables have these values:


Type "c" to configure again. Type "g" to generate the make file and exit ccmake. Then, in the Ubuntu terminal:

sudo make install

18) Compile and install OOF3D:

mkdir oof3-build
cd oof3-build/
sudo apt-get install python-gtk2-dev liblapack-dev bison
tar xzf oof3d-3.2.3.tar.gz
cd oof3d-3.2.3
sudo python build --3D
sudo python install --3D

19) Launch OOF3D:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

On Subsequent Logins to your Windows Account

After the initial installation of WSL, Ubuntu, VcXsrv, OOF2 and OOF3D on your Windows system, you will of course eventually log out of your Windows account, shutting everything down. The next time you log in, here is the sequence of commands required to launch OOF2 (or OOF3D) once again:

1) Launch the X server application with the following command in a cmd window:

"C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto

2) Find and start your Ubuntu terminal from the Windows Start menu.

3) Enable correct communication between your Ubuntu terminal and the X server you started in step 1. Type this in the Ubuntu terminal:

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

4) Launch OOF2 from the Ubuntu terminal: