WSL2 kernel with zswap.
Tested on:
- Ubuntu 22.04 with kernel 5.15.153.1-microsoft-standard-WSL2 (kernel 5.x)
- Ubuntu with kernel 6.x-microsoft-standard-WSL2 (kernel 6.x)
# Download and review the script first
curl -O https://raw.githubusercontent.com/dhanar10/wsl2-kernel-zswap/main/build.sh
less build.sh
# After reviewing, run it
bash build.shcurl https://raw.githubusercontent.com/dhanar10/wsl2-kernel-zswap/main/build.sh | bashThe script automatically detects your kernel version and:
- For kernel 5.x: builds the kernel with CONFIG_FRONTSWAP support
- For kernel 6.x: builds the kernel without CONFIG_FRONTSWAP (removed in 6.x) and generates a modules.vhdx file containing kernel modules
After building, copy arch/x86/boot/bzImage to your Windows C: drive and configure .wslconfig:
[wsl2]
kernel=C:\\bzImage
Then restart WSL: wsl --shutdown
After building:
- Copy
arch/x86/boot/bzImageto/mnt/c/bzImage - Copy
modules.vhdxto/mnt/c/modules.vhdx - Configure
.wslconfigin your Windows user directory:[wsl2] kernel=C:\\bzImage kernelModules=C:\\modules.vhdx - Restart WSL:
wsl --shutdown
After restarting WSL, verify zswap is enabled:
cat /sys/module/zswap/parameters/enabled
# Should output: Y
cat /sys/module/zswap/parameters/compressor
# Should output: zstd