OpenStreetMap

Windows Subsystem for Linux

Posted by SomeoneElse on 25 January 2023 in English. Last updated on 30 March 2023.

This isn’t directly related to OSM, but many times in “software” or “development” OSM channels someone has asked “how do I do X … on Windows 10?”.

The reason that’s often a question is that, for historical reasons, much of the OSM software used to do things has been developed on Linux. That’s great for people working on Linux themselves, and the Apple Macintosh users can normally jury-rig something to run that software too.

Windows users can do the same too, by installing “Windows Subsystem for Linux”. Within Windows, search for “Windows Features”:

In Windows Features, tick the box for WSL and click OK:

Windows will want to restart

After the reboot, search for “Ubuntu”:

As noted in the comments, you may need to add “Ubuntu 22.04.1 LTS” from the Microsoft App Store here. When I deleted and reinstalled WSL and Ubuntu to create these notes, I didn’t need to - but it may be that a Microsoft uninstall didn’t do a clean uninstall. Plus ça Change, eh? :)

Ubuntu will install:

and will then prompt for a userid and password:

After that type “lsb_release -a” at the prompt to see the version installed:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:        22.04
Codename:       jammy

Apply any pending updates:

sudo apt update
sudo apt upgrade

(this will take a while the first time)

and you can then head over to e.g. https://switch2osm.org/serving-tiles/ to do whatever it was you wanted to do.

Discussion

Comment from stephan75 on 27 January 2023 at 15:50

Very very interesting!

What are the minimum hardware and software requirements to follow your steps?

After rebooting the here-in-use Win10 system, I cannot find any “ubuntu” item or option. Is it via Microsoft windows app store or similar?

Comment from SomeoneElse on 27 January 2023 at 15:59

There are various “Ubuntu” options in the Windows app store. From memory, it used to be needed to download “Ubuntu” from there, but it looked like it it might have been removed, hence the notes above.

Go into powershell, and type “wsl -l -v”.

If that does not list anything, install “Ubuntu” from the Microsoft App Store. If you get a choice of 20.04 and 22.04, choose 22.04 because more OSM tools are built-in there.

Comment from mboeringa on 29 January 2023 at 13:29

Nice to see this lesser known option on Windows to run Linux via WSL pointed out.

Maybe it is good though to also include the option to run Ubuntu in a Windows “Hyper-V” virtual machine, especially for those who are more user interface oriented rather than command line:

https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v

Hyper-V is a cost-less option by default available on the Pro, Education and Workstation editions of Windows, but not Home.

This wasn’t the case a few years ago, but Microsoft added an Ubuntu virtual machine as one the default options for guest systems in Hyper-V.

I have been happily running such an Ubuntu virtual machine with osm2pgsql and PostgreSQL / PostGIS for the last two years now on a Windows 10 host system, and it has proven both rock solid and performant.

Log in to leave a comment