Building a Linux Open-Source GIS Environment with Windows: Part 1 - WSL

All the steps to get a barebones Linux GIS Environment set up on Windows

Building a Linux Open-Source GIS Development Environment with Windows

Using:

  • Windows Subsystem for Linux Version 2
  • Windows Powershell

Included:

  • Node.js Dev Environment
  • PostgreSQL/PostGIS
  • PGAdmin4
  • PG_TileServ
  • PG_FeatureServ
  • Jupyter Notebook
  • VSCode

Part 1: Windows Subsystem for Linux

What is WSL?

The Windows Subsustem for Linux (WSL) allows you to run Linux on Windows without the overhead of a VM or (shutter) dual boot. Learn all about it here: https://docs.microsoft.com/en-us/windows/wsl/about

I originally started writing this about how to use VirtualBox to run Debian on your machine, but if your system can support WSL, it is much easier to deal with, and doesn’t destroy your battery life.

How do I get it?

The guide can be found here: https://docs.microsoft.com/en-us/windows/wsl/install-win10

I’m going to walk through the manual install because it’s really not too many steps, and it gives you an idea about what it’s doing.

System Requirements

(Copypasta’ed from the Microsoft website)

To install WSL 2, you must be running Windows 10.

  • For x64 systems: Version 1903 or higher, with Build 18362 or higher.
  • For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
  • Builds lower than 18362 do not support WSL 2. Use the Windows Update Assistant to update your version of Windows.

To check your version and build number, select Windows logo key + R, type winver, select OK.

Security Note

You will be downloading executables from the internet and running them on your computer.

All the commands I have here are copied directly from Microsoft.com and I trust them. Make sure to verify any command before running them on your machine!

These commands require the use of Deployment Image Servicing and Management (DISM.exe) [which] is a command-line tool that can be used to service and prepare Windows images.

Begin the Install!

  1. Open Windows Power Shell as Administrator "Windows Powershell"
  2. Enable the Windows Subsystem for Linux
    dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
    
  3. Enable the Virtual Machine feature thats required for WSL2
    dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
    
  4. Reboot your machine! We have been using commands that end in /norestart to prevent dism.exe from rebooting the machine, but eventually we actually need to reboot it.
  5. Download the Linux Kernel update package:
  6. https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
  7. Run the Linux Kernel Update package "Install Screen"
  8. Find the msi file that you downloaded, and open it
  9. If you see a window with this messaage: This update only applies to machines with the Windows Subsystem for Linux, you will need to Follow the directions here: https://github.com/microsoft/WSL/issues/5035#issuecomment-729914763 "Install Error"
  10. If it all works properly, you should see this screen "WSL Install Screen"
  11. Click next, and it should install quickly.
  12. Enable WSL Version 2
  13. Bring Power Shell back up as an Administrator and run this command: wsl --set-default-version 2
  14. Youll see a kind of cryptic message For information on key differences with WSL 2 please visit https://aka.ms/wsl2 which basically means it worked!
  15. Install a distro of linux
  16. I had originally written this for Debian, but it doesnt really make a difference, and there are more guides for Ubuntu, so Ill continue with Ubuntu 20.04.
  17. Navigate your browser to the MS Store for WSL: https://aka.ms/wslstore "Microsoft Store"
  18. Click Ubuntu and click Get "Install Ubuntu"
  19. When its done, you should see this screen: "Installation Complete"
  20. Set up your install
  21. Go ahead and press that Launch button. "Installing Screen"
  22. It doesnt take that long, and next itll ask you to make an account for yourself. "Make User Account"
  23. At this point, you can also access the linux drive from your host by going to file://wsl$ or from within linux, you can go to /mnt/c/ to get to the hosts C drive. 1. Be aware that the file permissions work different on the two OSes.
  24. You can type exit now, well come back to this later!
  25. Install Windows Terminal (or Windows Terminal Preview)
  26. This is listed as optional on the MS install notes, but I would suggest it, you can get it here: https://docs.microsoft.com/en-us/windows/terminal/get-started
  27. They are doing great work on it right now, so Im a big fan of the preview version, which you can get here: https://github.com/microsoft/terminal/releases
  28. Once you have Windows Terminal installed, you can access the subsystem by simply typing WSL at the command line! (Otherwise, you would choose Ubuntu from the Start Menu).

Next

The next step is to install Docker and docker-compose, read all about that here!