Skip to content

Load kernel modules - #524

Open
terlar wants to merge 2 commits into
nix-community:mainfrom
terlar:load-kernel-modules
Open

Load kernel modules#524
terlar wants to merge 2 commits into
nix-community:mainfrom
terlar:load-kernel-modules

Conversation

@terlar

@terlar terlar commented Jul 31, 2024

Copy link
Copy Markdown
Contributor

WSL now supports kernel modules and come with a bunch configured as m and can be loaded this way. For example vhci-hcd used by usbip has changed from y to m and hence need to be explicitly loaded.

dorssel/usbipd-win#995
microsoft/WSL#11789 (comment)

Unfortunately we cannot use boot.kernelModules since it is gated behind boot.kernel.enable.

@terlar
terlar force-pushed the load-kernel-modules branch from 02b50d1 to 94010f2 Compare July 31, 2024 05:35
Comment thread modules/wsl-distro.nix
The set of kernel modules to be loaded in the second stage of
the boot process via systemd-modules-load.service.
'';
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we reuse boot.kernelModules here?

@terlar terlar Aug 25, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is gated behind boot.kernel.enable which we don't want to enable.

Another option is to have something like a boolean wsl.loadKernelModules. That will write the file with the value based on boot.kernelModules. What do you prefer?

@K900

K900 commented Aug 25, 2024

Copy link
Copy Markdown
Contributor

Wait, how does this even work. Isn't our modprobe looking in the wrong path for this?

@nzbr

nzbr commented Aug 25, 2024

Copy link
Copy Markdown
Member

Just wanted to ask this, because if I run insmod vhci-hcd it does not find the module file

  root@pulsar
ZS /home/nzbr> insmod vhci-hcd
insmod: ERROR: could not load module vhci-hcd: No such file or directory

@K900

K900 commented Aug 25, 2024

Copy link
Copy Markdown
Contributor

You want modprobe.

@terlar

terlar commented Aug 25, 2024

Copy link
Copy Markdown
Contributor Author

@K900

K900 commented Aug 25, 2024

Copy link
Copy Markdown
Contributor

But how does it know where to find the WSL modules

@terlar

terlar commented Aug 25, 2024

Copy link
Copy Markdown
Contributor Author

It is bundled with the kernel as loadable modules as I understand it and this change happened in the latest WSL kernel release (6.6). See release notes

@nzbr

nzbr commented Aug 25, 2024

Copy link
Copy Markdown
Member

You want modprobe.

It seems that modprobe does not report if it failed though. It'll just run through but then lsmod will still show that no modules are loaded

@K900

K900 commented Aug 25, 2024

Copy link
Copy Markdown
Contributor

WSL also rolled back to 5.15 for now. I really want to see a test at this point to actually verify it does what it says.

@nzbr

nzbr commented Aug 25, 2024

Copy link
Copy Markdown
Member

Ah, i have 5.15, that might be why this doesn't work

@terlar

terlar commented Aug 26, 2024

Copy link
Copy Markdown
Contributor Author

Yes, that is a bit confusing, just discovered they reverted to the older kernel again now when I was looking into it. I have tested this on WSL with the 6.6 kernel and verified it works. But I guess we might as well wait looking into it since the latest WSL went back to the older kernel.

@nzbr nzbr added enhancement New feature or request blocked Something else has to happen before work on this can continue labels Aug 26, 2024
@Stinjul

Stinjul commented Jun 5, 2025

Copy link
Copy Markdown

WSL 2.5.7 switched to the 6.6 kernel, can this PR get merged now?

@nzbr
nzbr force-pushed the main branch 12 times, most recently from 0fa96ff to d34d941 Compare July 11, 2025 02:04
@nzbr
nzbr force-pushed the main branch 3 times, most recently from cc18cce to fd04040 Compare August 13, 2025 23:30
@inschrift-spruch-raum

Copy link
Copy Markdown
Contributor

The kernel upgrade seems to have stabilized. Should we proceed with it?

WSL now supports kernel modules and come with a bunch configured as `m`
and can be loaded this way. For example `vhci-hcd` used by usbip has
changed from `y` to `m` and hence need to be explicitly loaded.
@terlar
terlar force-pushed the load-kernel-modules branch from 94010f2 to 36d780d Compare January 15, 2026 20:45
@terlar

terlar commented Jan 15, 2026

Copy link
Copy Markdown
Contributor Author

I rebased it to make sure it is ready with the latest things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Something else has to happen before work on this can continue enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants