Ubuntu 20.04 and WSL 1


WSL, the binary translation layer which we now call WSL 1, has served us well. WSL 1 has given us nearly-complete Linux syscall support and is a stable and mature platform. WSL 1 will continue to be an excellent option for WSL users. WSL 1 has a smaller resource footprint on low-spec devices and has simplified networking. Many enterprise and institutional users will be on a WSL 1-only build of Windows 10 for several more months or in some cases years after WSL 2 is released. WSL 1 is part of Windows 10 Enterprise LTSC and Windows Server 2019 which will be supported until 2024. We can expect WSL 1 to get critical fixes even as the WSL team at Microsoft turns their focus to WSL 2.

Issue 4989

An example of the WSL team continuing to service WSL 1 for now is a patch for issue 4989. Issue 4989 arises from a patch in glibc 2.31 that implements a nanosleep() library call in a more UNIX-like manner based on CLOCK_REALTIME. Emulating UNIX system clocks on an NT kernel is tricky. WSL 1 implemented the most popular clock-based system calls, but not all of them, and did not build CLOCK_REALTIME support into nanosleep. But because this is such a fundamental change in glibc the WSL team is very graciously implementing support for CLOCK_REALTIME in nanosleep in WSL 1 and will be backporting it in updates to existing builds. This is a challenging task that will take some time. In contrast, other more obscure system clock calls, like the one raised in issue 4973, will likely not see implementation in WSL 1.

What does this mean for Ubuntu on WSL?

The upcoming Ubuntu 20.04 implements glibc 2.31. Unless you are on Insider you have not gotten the fix for issue 4989 yet and likely will not for a couple months. Without the fix things tend to break on Ubuntu 20.04 on WSL 1, sometimes even in the upgrade process to Ubuntu 20.04. For example htop doesn’t work on Ubuntu 20.04 on unpatched WSL 1.

You can check your Windows 10 build from WSL with: $ winver.exe

What is the plan?

For WSL 1 users, I recommend you sit tight on Ubuntu 18.04 for now. The patch for issue 4989 will take some time to be backported. Ubuntu 18.04 is an LTS release, short for long-term servicing, and is supported through 2023 so you will continue to get security patches and backports from Canonical in the meantime.

For WSL 2 users, you are free to upgrade to Ubuntu 20.04 when it drops, or even early to help us test.

WSL 2 is currently only available on Windows Insider Slow and Fast rings. WSL 2 will be landing in the release branch of Windows 10 with Windows 2004 in the next few weeks.

For WSL 1 users upgrading to WSL 2, such as when 2004 becomes available outside Insiders, you should convert your Ubuntu 18.04 image to WSL 2 first with:

$ wsl.exe --set-version Ubuntu 2

and then upgrade to Ubuntu 20.04.

tl;dr If you are using WSL 1 don’t upgrade to Ubuntu 20.04 quite yet, wait until an update fixes an issue or upgrade to WSL 2 when it is released.

Okay, what if I want to upgrade WSL 1 to Ubuntu 20.04 anyways?

Before you upgrade, you can block libc6 from being upgraded:

$ sudo apt-mark hold libc6

1 Like

If upgrading from bionic to focal, holding libc6 by itself won’t work because of dependencies requiring a newer version.

rafaeldtinoco has a ppa with a patched version of the newer libc available. Post. Install this and then hold libc6, and the upgrade should be successful.

Regarding the broken focal upgrade, do not follow pagerc’s instructions. You will trash your wsl entirely. Post

Update: it’s not as straightforward as I’d thought.

The ppa contains packages for focal and have dependency issues with bionic. Further, focal has newer versions of the packages than provided in the ppa.

The following worked for me, but may not be the best approach, and I can’t guarantee it won’t grenade your install:

wget https://launchpad.net/~rafaeldtinoco/+archive/ubuntu/lp1871129/+files/libc6_2.31-0ubuntu8+lp1871129~1_amd64.deb
Since focal has newer versions than the packages in the ppa, and we’re only interested in libc6, just download the package directly. Can’t install it yet because of dependency issues, but will need it after the next step.

do-release-upgrade -d
It’ll break because of libc6 as expected.

dpkg --install libc6_2.31-0ubuntu8+lp1871129~1_amd64.deb
apt-mark hold libc6
apt --fix-broken install
apt full-upgrade

@matlock: I ran out of replies on your post How You Can Help Test Ubuntu 20.04 LTS on WSL because I’m a new user, and couldn’t edit my replies, so I thought I post it here because it’s related.

As mentioned in my reply, wsl.exe --export Ubuntu ubuntu-backup.tar.gz won’t actually compress to a tar.gz,- you’d need to pipe to gzip wsl.exe --export Ubuntu -| gzip > ubuntu-backup.tar.gz. (notize the ‘-’ at the end)
But I had a lot of problems importing it directly through tar -xOzf ubuntu-backup.tar.gz| wsl.exe --import UbuntuFocal C:\UbuntuFocal ubuntu-backup.tar.gz - so I resorted to 7zip to do the export/import thing:

wsl.exe --export Ubuntu - | 7z a -si ubuntu-backup.tar.7z

7z x -so ubuntu-backup.tar.7z | wsl --import UbuntuFocal C:\UbuntuFocal -

The uncompressed tar of a ubuntu dist is quite large so this saves a bit of wear and tear on our precious ssd’s :slight_smile:

Sorry to hijack, but I thought it was relevant in our common quest to mitigate the u20.04/wsl1 bug.

Before upgrading to WSL 2 remember that this will break IPv6 connectivity, until WSL 2 implements IPv6.