Despite problems, making WSL2 Work

This should have been easy – enable Windows Subsystem for Linux 2 on Windows 10, and install a version of Linux. However, I ran into a few problems. This post is a collection of the things that I had to do (and where I found the information) in case I ever need to do it again.

In my case, WSL2 had been installed and initialised earlier but I decided to reset the Ubuntu installation and reinstall fresh so that I had a clean setup. I went to Windows Apps & Features and searched for Ubuntu and clicked on Uninstall.

Then, I went to the command line and followed these steps:

wsl --set-default-version 2
wsl --install -d Ubuntu

This failed on the second step with an error similar to this:

Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370102
Error: 0x80370102 The virtual machine could not be started because a required feature is not installed.

I did not expect this because I thought Virtualisation was turned on – then, I remembered that Lenovo had replaced my motherboard a few months ago, and the BIOS settings must have changed at that time.

So, I needed to do the following:

  • Restart the computer, interrupt the startup to enter the BIOS settings; go to Security and then Enable Intel Virtualisation
  • Next, go to Turn Windows Features on and off – enable the Hyper-V, Windows Hypervisor Platform and Virtual Machine Platform

Reference Link:×80370102

Good! We can make progress now.

The next problem came up while installing Ubuntu. During the installation, it died with an error like this:

WslRegisterDistribution failed with error: 0xc03a001a
Error: 0xc03a001a The requested operation could not be completed due to a virtual disk system
limitation.  Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.

OK – deep breath! My entire disk is compressed. So, I needed to disable compression for the folder where the files will be stored. After some searching around, this is what you need to do:

  • We need to find the Ubuntu directory. This is in the profile folder at: %USERPROFILE%\AppData\Local\Packages under a folder with a name that starts with CanonicalGroupLimited and has a bunch of other characters. Go into that folder and head to the “LocalState”. Right click and go to: Properties, Advanced, deselect “Compress contents”. Apply to this folder and/ or subfolders and files.
  • Now, try installing Ubuntu again – it should work.

Reference Link:

Once installed, I was able to get into the console and happily type some Linux commands – joy!

Naturally, the next thing I needed to do was to make sure that I can access the network so that I could run commands like sudo apt-get update and sudo apt-get upgrade but I ran into the next problem here. Everything failed with errors such as Temporary failure resolving '' basically meaning that either their network or mine was down.

So, check if you can do something like:

  • ping – I got an error that the name could not be resolved.
  • ping – I got an error saying connect: Network is unreachable

OK, networking was not working. This took me on a long trip through a number of things and I have to admit that while one thing fixed it, I don’t know which ones actually contributed to the solution, so read the notes below.

1. First, the recommendation was to prevent WSL2 from regenerating the hosts and resolv.conf file on each restart. When installing Ubuntu 22.04 LTS, you get asked this question during the installation. If you do not get the option, you need to do the following.

$ sudo touch /etc/wsl.conf
$ sudo nano /etc/wsl.conf

Add the following lines to wsl.conf

generatehosts = false
generateresolvconf = false

It’s recommended to restart WSL2 from a Powershell/ CMD window by doing wsl --shutdown at this stage.

Once restarted, the next thing to do is to add a resolv.conf by doing this:

$ sudo unlink /etc/resolv.conf
    # you may see an error - that's fine
$ sudo rm /etc/resolv.conf
    # you may see an error - that's fine
$ sudo touch /etc/resolv.conf
$ sudo nano /etc/resolv.conf

Now add this to the file:


This will point to the Cloudflare nameserver to resolve addresses.

You might as well restart WSL2 one more time.

So, check if you can do something like:

  • ping – I got an error that the name could not be resolved.
  • ping – I got an error saying connect: Network is unreachable

Time to try again! If you’re lucky, it should work now. If you’re [like] me, it would not work yet.

Note: there are problems with when you’re using a VPN and the solution might be different in those cases.

Take a look at this for more details and for more help:

  • – this has a lot of conversation and you might find something else that helps you

2. Here are a couple of other things that I did:

  • Based on one of the posts, from the Device Manager, I removed any Network adapter called Hyper-V Virtual Switch Extension Adapter – I feel that this was one that was not needed.

3. Ok, back on track – still not working. Here is the last thing I did and it made it all work for me.

One of the posts mentioned that you could consider disabling swap (I did not do that) or to set %TEMP% (usually C:\AppData\Local\Temp) to not being compressed (remember my file system is all compressed). So, I went to that folder and for the Ubuntu folder earlier, I disable the compression for that folder also.

Reference Link:

This worked! I can now use the network from my Ubuntu installation in WSL2.

I noted these down because I will surely forget what I did… in case I need it again. I hope that one of these things works for you if you are facing this problem. As always, if you have something to add, please leave a comment and I’ll add it in.

comments powered by Disqus