Skip to content

Instantly share code, notes, and snippets.

@hkboujrida
Created August 8, 2023 17:33
Show Gist options
  • Save hkboujrida/6475b86aa8265905171c4efa87882d59 to your computer and use it in GitHub Desktop.
Save hkboujrida/6475b86aa8265905171c4efa87882d59 to your computer and use it in GitHub Desktop.
build wsl2 kernel
#!/bin/bash
WSL_COMMIT_REF=linux-msft-wsl-5.15.90.4
apt update && apt install -y git build-essential flex bison libssl-dev libelf-dev bc dwarves
mkdir src
cd src
git init
git remote add origin https://github.com/microsoft/WSL2-Linux-Kernel.git
git config --local gc.auto 0
git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +${WSL_COMMIT_REF}:refs/remotes/origin/build/linux-msft-wsl-5.15.y
git checkout --progress --force -B build/linux-msft-wsl-5.15.y refs/remotes/origin/build/linux-msft-wsl-5.15.y
# adds support for clientIP-based session affinity
sed -i 's/# CONFIG_NETFILTER_XT_MATCH_RECENT is not set/CONFIG_NETFILTER_XT_MATCH_RECENT=y/' Microsoft/config-wsl
# required modules for Cilium
sed -i 's/# CONFIG_NETFILTER_XT_TARGET_CT is not set/CONFIG_NETFILTER_XT_TARGET_CT=y/' Microsoft/config-wsl
sed -i 's/# CONFIG_NETFILTER_XT_TARGET_TPROXY is not set/CONFIG_NETFILTER_XT_TARGET_TPROXY=y/' Microsoft/config-wsl
# build the kernel
make -j2 KCONFIG_CONFIG=Microsoft/config-wsl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment