-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lookup bridge kernel module in /sys/module/ to enable running on WSL2 #17305
Comments
Hello @jeteve, today could be your lucky day!Yesterday I completed a survey on how to do this with minimal steps and/or interventions and I've already tested it in 2 different environments using WSL2 with Ubuntu 22.04.2 vanilla. Enabling bridge and br_netfilter modules in vanilla WSL2 (Ubuntu-22.04)1. Downloading the necessary requirementssudo apt install build-essential flex bison dwarves libssl-dev libelf-dev bc libncurses-dev unzip 2. Set variable with kernel versionex: WSL_RELEASE=linux-msft-wsl-5.15.90.1WSL_RELEASE="linux-msft-wsl-$(echo $(uname -r) | cut -d"-" -f1)" 3. Download the source code of your kernel version used by wsl2curl -LO https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/${WSL_RELEASE}.zip 4. Unzip the source codeunzip ${WSL_RELEASE}.zip 5. Load your WSL2 kernel configuration file (Kconfig)cd WSL2-Linux-Kernel-${WSL_RELEASE}
zcat /proc/config.gz > .config 6. Prepare the modulesmake prepare modules_prepare -j $(nproc) 7. By default, the modules are already enabled in the ".config", I suggest checking them when opening the config menuModules must be enabled with "*" (built-in)make menuconfig Settings locations in menuconfig
8. Compile the modulesmake modules -j $(nproc) 9. Activate the modulessudo make modules_install -j $(nproc) 10. Restart wsl2:a. In CMD or PowerShell: wsl --shutdown b. Reopen wsl2 Have fun! |
Thanks a lot for the answer! The thing is this bridge module is already built in the MS provided kernel:
It seems to be a bit overkill to rebuild a kernel from scratch when a lookup in this place would allow detecting this built-in bridge module. |
@jeteve, Sharing is multiplying! I've seen that too.
Resultados de tradução In this process, the only thing I use (apparently), is the reconstruction of the modules' folder and files structure, which is not found by default. Structure of folders and files recreated in the process. Another method that I didn't find so elegant but works perfectly, is to copy the folder structure and files (mentioned above) from a corrected WSL2 and put it in another one that doesn't have this structure, (tests in another one that used the same kernel version) , it only excludes the build and source folders from the copy. Vanilla WSL2, apenas com a pasta modules importada. I'm curious to know how you solved this problem too, in case you care to share. 🖖Live Long and Prosper! |
@hardkeo to run in WSL, I've just did that:
And then the current version of nomad just detects the bridge module :) |
@jeteve thanks for sharing! Much simpler. sudo mkdir -p /lib/modules/$(uname -r)
echo -e "kernel/net/bridge/bridge.ko\nkernel/net/bridge/br_netfilter.ko" | sudo tee /lib/modules/$(uname -r)/modules.builtin |
Proposal
To find out if the host linux system is capable of bridge networking, the client fingerprinting looks up in /proc/modules , /lib/modules//modules.builtin and in /lib/modules/<kernel/modules.dep.
Sadly none of those places are populated in WSL2 (tested using ubuntu WSL2) in Windows, even though the WSL2 kernel provided by MS has many modules built-in (including the bridge module).
Use-cases
End goal: run nomad on WSL2 with bridge networking capability.
Attempted Solutions
Add a lookup into /sys/module/ . To attempt detecting the availability of the bridge kernel module.
A branch with this solution is provided against this issue
References
See https://www.kernel.org/doc/Documentation/ABI/stable/sysfs-module
The text was updated successfully, but these errors were encountered: