How to enable modules in WSL2?

Stephanie 0 Reputation points
2023-11-15T20:17:15.72+00:00

Hello Microsoft Community, 

I am using WSL2 to run Linux on my laptop which has windows OS (windows 11). The laptop is the x64-based Acer Swift Edge 16 which features an AMD Ryzen™ 7 7840U-processor. 

I am trying to enable the following kernel modules by running the following commands in WSL2: sudo modprobe overlay followed by sudo modprobe br_netfilter. However, I receive the following outputs when running both of them:

            *modprobe: FATAL: Module overlay not found in directory /lib/modules/$(uname -r)*

            *modprobe: FATAL: Module br_netfilter not found in directory /lib/modules/$(uname -r)*

When I check the directory /lib/modules, there are no modules, it is empty. How can I add these modules in the correct way and enable them on WSL2? I have tried to find the answer to this myself but have come up short after several hours of searching; would appreciate your expert feedback.

Thank you in advance for reading my question and for any help to point me in the right direction!

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,988 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. André van den Berg 81 Reputation points MVP
    2023-11-20T09:18:55.19+00:00

    It seems that you are trying to load kernel modules that are not available in the default WSL2 kernel. The WSL2 kernel is a custom Linux kernel from Microsoft that contains all of its drivers compiled in. While it has support for modules, it does not ship with any, as you can see from the configuration file<sup>1</sup>.

    If you want to enable the overlay and br_netfilter modules, you will need to build your own WSL2 kernel from the source code<sup>2</sup>. You can follow the instructions in the README file<sup>3</sup> to download and compile the kernel using the WSL2 configuration. You will also need to install some build dependencies<sup>4</sup>. After building the kernel, you can install the modules with sudo make modules_install and then load them with sudo modprobe.

    Alternatively, you can try using a pre-built WSL2 kernel that has the modules enabled, such as the one from this GitHub repository<sup>5</sup>. You can download the latest release and follow the installation steps in the README file<sup>6</sup>. However, please note that this is not an official Microsoft kernel and it may not be compatible with your WSL2 version or settings.

    I hope this helps you to enable the kernel modules you need. If you have any other questions, please feel free to ask. 😊

    0 comments No comments