xanmod-kernel-WSL2
xanmod-kernel-WSL2 copied to clipboard
[TODO] Distribute Kernel Modules & Headers as VHD
Latest WSL2 6.6.y kernel update provides instructions for bundle kernel module files into a VHD. But they don't give any details about how to use the generated modules.vhdx. I'm expecting WSL2 team will give us some options in .wslconfig and it will just work out of box.
If so, we can easily implement kernel update with modules via scoop. Users don't have to update kernel module files manually for each distro & each release, which is nice. We don't have to build everything into the kernel then.
Also it's not difficult to bundle kernel headers as a VHD too, it will be more convenient for people who somehow need original kernel headers (e.g. to develop kernel drivers on WSL2).
I do find some instructions to mount VHDX manually via PowerShell/WSL commands, but this requires per-distro setup (e.g.,
fstab, partition mounting).
Upstream: https://github.com/microsoft/WSL/issues/12586
I still prefer to have everything built-in in order to get fully covered LTO and CFI, but bundled headers are very useful indeed.
Incidentally, Fuchsia Clang will soon be built with PGO, which is expected to reduce kernel build times by 20%, which alleviates the need to modularize the kernel for build time reasons..
I'm thinking to add those less often used features as modules, something like https://github.com/Locietta/xanmod-kernel-WSL2/issues/99. I'm not sure whether there are enough such features though.
Latest WSL2 6.6.y kernel update provides instructions for bundle kernel module files into a VHD. But they don't give any details about how to use the generated
modules.vhdx. I'm expecting WSL2 team will give us some options in.wslconfigand it will just work out of box.If so, we can easily implement kernel update with modules via scoop. Users don't have to update kernel module files manually for each distro & each release, which is nice. We don't have to build everything into the kernel then.
Also it's not difficult to bundle kernel headers as a VHD too, it will be more convenient for people who somehow need original kernel headers (e.g. to develop kernel drivers on WSL2).
I do find some instructions to mount VHDX manually via PowerShell/WSL commands, but this requires per-distro setup (e.g.,
fstab, partition mounting).Upstream: microsoft/WSL#12586
In .wslconfig like this:
kernel=C:\\.wsl\\6.13.6-microsoft-standard-WSL2-bzImage
kernelModules=C:\\.wsl\\6.13.6-microsoft-standard-WSL2-modules.vhdx
Remember for scoop paths important
- https://github.com/microsoft/WSL/issues/12819#issuecomment-2799961131
I still prefer to have everything built-in in order to get fully covered LTO and CFI, but bundled headers are very useful indeed.
This.
Hi, if you are still considering adding support for VHDX images in kernel modules, please check out my repository. It might be helpful.
For gui use, wsl settings app has a vendor tab to select and add kernel module vhd.
Heads-up: this is now supported upstream. The WSL docs list a .wslconfig key kernelModules that points to a modules VHD/VHDX.
# the WSL2 kernel repo ships a script to generate it.
sudo ./Microsoft/scripts/gen_modules_vhdx.sh "$PWD/modules" "$(make -s kernelrelease)" modules.vhdx
# %UserProfile%\.wslconfig
[wsl2]
kernel=C:\\.wsl\\xanmod\\bzImage
kernelModules=C:\\.wsl\\xanmod\\modules.vhdx
the VHDX is auto-mounted under /lib/modules/<kernelrelease>.
uname -r inside WSL exactly matches the release used for modules.vhdx.
Heads-up: this is now supported upstream. The WSL docs list a .wslconfig key
kernelModulesthat points to a modules VHD/VHDX.the WSL2 kernel repo ships a script to generate it.
sudo ./Microsoft/scripts/gen_modules_vhdx.sh "$PWD/modules" "$(make -s kernelrelease)" modules.vhdx
%UserProfile%.wslconfig
[wsl2] kernel=C:\.wsl\xanmod\bzImage kernelModules=C:\.wsl\xanmod\modules.vhdx the VHDX is auto-mounted under
/lib/modules/<kernelrelease>.uname -rinside WSL exactly matches the release used for modules.vhdx.
As I stated on 13th March https://github.com/Locietta/xanmod-kernel-WSL2/issues/114#issuecomment-2722780027
Completed by #144.