Score:-1

Will wsl work with new native ubuntu kernel?

Currently I am under wsl2 in a 21.10 distro, the kernel is 5.10.60.1-microsoft-standard-WSL2.

What will happen if I will go on and install one of the mainline ubuntu kernels there?

muru avatar
us flag
How will you even get WSL to use it?
მამუკა ჯიბლაძე avatar
@muru So it will just crash immediately or what?
muru avatar
us flag
https://falco.org/blog/falco-wsl2-custom-kernel/ shows someone running 5.10 while WSL2 was still on 5.4, so presumably it might work. Try it out for yourself.
us flag
Do you really need it?
მამუკა ჯიბლაძე avatar
@ArchismanPanigrahi Well, since wsl itself has 20.04 as latest available distro, I suppose the microsoft kernel is geared towards it, so I thought a newer kernel would work better for 21.10, no?
us flag
`newer kernel would work better for 21.10` -- Newer kernels have better compatibility with newer hardware. Otherwise, it practically does not matter. And WSL is like a virtual machine, it does not need to interact much with the hardware anyway.
Score:2
vn flag

At the best, you'd get an extremely unoptimized WSL system. At worst, it just won't start.

I did try (half-heartedly) to run the 5.15 kernel under WSL:

  • Downloaded and installed the .deb
  • Copied the vmlinuz-5.15.0-051500-generic over to a directory in my Windows user profile
  • Edited my %userprofile%\.wslconfig to add the appropriate kernel pointer
  • wsl --shutdown

Attempting to start any of my WSL instances (any distribution) failed. No error, just locked up the wsl command until I issued another wsl --shutdown in another PowerShell session.

I say "half-heartedly" because I could go further with this. Looking at the existing WSL kernels, they appear to be uncompressed. So I could have attempted to uncompress the Ubuntu kernel.

But regardless, I just didn't have high-hopes of this paying off (or being very useful).

Note that Microsoft does maintain its own WSL2 kernel repository with the modifications needed to optimize for WSL2. At the very least, the .config is very different than that of the Ubuntu stock kernel configuration. I spent a bit of time scanning a vimdiff of the two out of curiosity, but I'm not an expert in kernel configuration by any means.

Things like virtualization are already enabled in the stock Ubuntu kernel, so that's not an issue. But one things that did stand out to me is that a stock Ubuntu kernel is, of course, expecting physical or even virtual "hardware" that supports power management. WSL does not. There's no "Power on", no "Suspend", etc. If the power management subsystem (ACPI) puts the system to sleep under WSL, there's no "waking it up".

There are a huge number of other differences between the two. I'm sure many of these are optimizations (or even requirements) on the WSL end.

Btw, it appears that there is a slightly newer release of the Microsoft supplied kernel. Last week saw the release of linux-msft-wsl-5.10.74.3. It should be available soon for wsl --update (or via Automatic Windows updates). Or you can download and compile yourself from the provided source.

მამუკა ჯიბლაძე avatar
I am very grateful for your efforts. Now I know I should not try it myself. Still, a possibility remains that if one compiles the kernel from within wsl itself as explained in the [link](https://falco.org/blog/falco-wsl2-custom-kernel/) provided by the comment by @muru above, or say [here](https://sypalo.com/how-to-upgrade-ubuntu), the results will be less disappointing...
მამუკა ჯიბლაძე avatar
Sorry I looked more carefully into my own link, there is no compilation going on there, just installing the `.deb` file as you did
NotTheDr01ds avatar
vn flag
@მამუკაჯიბლაძე Right, the key line in Falco's website is `wget https://raw.githubusercontent.com/microsoft/WSL2-Linux-Kernel/7015d6023d60b29c3be4c6a398bed923b48b4341/Microsoft/config-wsl -O .config`. That pulls the Microsoft-optimized `.config` into the process. Really, the kernel build can be done from pretty much any system, as long as you use the right config combination. Just for clarity, `.config` is the kernel configuration options, whereas `.wslconfig` is the file that tells WSL2 to use a different kernel (and other options).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.