How to install & upgrade Windows Subsystem for Linux 2.0

avatar

Yesterday I made a post talking about Windows Subsystem for Linux 2.0 and the improvements over 1.0.

This post will go over how to install Windows Subsystem for Linux 2.0 if you don't have it installed already and how to upgrade if you have WSL 1.0 already installed.

Installing WSL 2.0

Update to Windows version 2004

You first need to make sure you have Windows 10 build version 2004 or greater. You can check your build by going to system.

If you do not already have 2004 and you do not see any updates under Windows Update, you can force the install by using Microsoft Windows Update Assistance. The upgrade will take around an hour.

Install Subsystem for Linux

In the start menu launch the program and features settings by typing in features

You want to select both Windows Subsystem for Linux & Virtual Machine Platform


Once these finish installing, you will be asked to reboot.

Install the kernel update

Seeing as Microsoft now uses a real Linux kernel with WSL 2.0, you need to install the kernel update patch.

Microsoft is using a real Linux kernel and no longer running a translation layer for system calls.

Update your distribution

If you already have Linux installed for WSL 1.0, you can update it to 2.0 so it can take advantage of all the new features using the commands:

wsl -l -v

This will list out all your Linux installs.

You can then update them by name.

wsl --set-version Ubuntu 2

I recommend setting the default version to 2.0 for future installs.

wsl --set-default-version 2

Depending on how much you have used your Linux distribution, the conversion to 2.0 can take a little time.

Install a Linux distribution

If this is a new install of WSL, you can download your choice of Linux from the Microsoft Store.

Do a search for Linux in the Microsoft Store and this should bring up most of the options available.

I recommend Ubuntu 20.04 but you can choose any of the other options.

Once installed, it will prompt you to create a user.

Install Windows Terminal

I also recommend installing Windows Terminal. It is a beta product from Microsoft that allows you to easily launch Powershell, CMD, and Bash from the same terminal.

It also allows you to quickly start your Linux distribution, I typically will just use my SSH client but Linux is not started when Windows is started. So you need to initially start it and optionally SSH.

At this point, you are all set and can start using & developing Linux native applications within Windows.

WSL 2.0 is not a virtual machine (even though it does use a tiny virtual machine to bootstrap it). WSL is a full-blown Linux distribution running native Linux applications.

The performance of WSL 2.0 is amazing compared to WSL 1.0, in most cases, it is near-native speed now.

My next post will cover a cool feature that allows you to use WSL 2.0 to develop on Windows much easier than you thought possible.


Securely chat with me on Keybase

Why you should vote me as witness



0
0
0.000
22 comments
avatar

Does it only work on Windows Pro or also on Windows Home?

0
0
0.000
avatar

In theory it would probably work. I haven't tested it but the way WSL works I wouldn’t recommend it.

There is no init system with WSL so you need to use Windows scheduler to start applications.

WSL also doesn’t stay running as well as a dedicated machine. Recently they added the ability to run background tasks even when closing shell but I wouldn’t use it for a service that needs to stay running. Especially when you spend 6hrs to 4 days to do a replay just to get it synced up.

0
0
0.000
avatar
(Edited)

I had to use "wsl -l --all" to list all Linux installations... "wsl -l -v" didn't work.

Also, to upgrade, I had to use "wsl --upgrade Ubuntu-18.04"

0
0
0.000
avatar

It should be minus L minus V for list and version.

The name is whatever your installation name is from the above command. That’s why I suggested listing the installations.

0
0
0.000
avatar

Arguments to manage Windows Subsystem for Linux:

--export <DistributionName> <FileName>
    Exports the distribution to a tar file.
    The filename can be - for standard output.

--import <DistributionName> <InstallLocation> <FileName>
    Imports the specified tar file as a new distribution.
    The filename can be - for standard input.

--list, -l [Options]
    Lists distributions.

    Options:
        --all
            List all distributions, including distributions that are currently
            being installed or uninstalled.

        --running
            List only distributions that are currently running.

-setdefault, -s <DistributionName>
    Sets the distribution as the default.

--terminate, -t <DistributionName>
    Terminates the distribution.

--unregister <DistributionName>
    Unregisters the distribution.

--upgrade <DistributionName>
    Upgrades the distribution to the WslFs file system format.

--help
    Display usage information.
0
0
0.000
avatar

That's strange as wsl -l -v works for me.

2D29D1E74A77472AB93883A393190871.jpeg

0
0
0.000
avatar

Looks like they forgot to update some files in the 2004 update... I had to revert to older version of WSL and then reinstall updates to get "-l -v" to work... After the update to WSL 2.0, clock runs backwards inside Ubuntu... lol... maybe they add a fix for that too...

warning: Clock skew detected.

0
0
0.000
avatar
(Edited)

I did notice there are some known issues with 2004.

See if you can install chrony to keep track of your clock.

sudo apt install chrony

To be honest, I am not happy with version 2004 at all.

0
0
0.000
avatar

Chrony didn't help... I reverted back to WSL 1... Maybe all the issues will be eventually fixed, but as I need to build applications on daily basis, I can't take risks even if the drift is just fractions of a second right after starting the session.

0
0
0.000
avatar

That's odd, I didn't see that in the known issues. Most of the known issues were very obscure.

0
0
0.000
avatar

I used to be beta tester for Microsoft, so I know a few things about how to break things... WSL 2 doesn't like saving files to NTFS mount. I use NTFS mounts so I can do builds from same source tree for both Windows and Ubuntu...

0
0
0.000
avatar

Great, thanks for sharing. However, I'm more interested on the opposite...What software you reccomend to install for running windows apps on a linux distro?

0
0
0.000
avatar

I don't typically do that, but I would recommend running a Windows Virtual Machine, but if you want to install directly then WINE is probably the best option. I would do what I could to replace Windows apps with native Linux ones if at all possible.

If it is games, there is a new game project that is gaining success, forget the name but shouldn't be too hard to find.

0
0
0.000
avatar

It looks like your post got attacked by an army of angry vikings!

0
0
0.000
avatar

Just two, minimalpris and his 490 account bot army, and about 8-10 from lokiyngling.

0
0
0.000
avatar

WSL sorta reminds me of LSL. Who remembers Leisure Suit Larry???? 😍

0
0
0.000