记录 wsl2 更新内核等等问题

自己手动编译内核:

微软的WSL内核:https://github.com/microsoft/WSL2-Linux-Kernel

Linux内核:https://kernel.org/

bash
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.6.58.tar.xz
tar -xf linux-6.6.58.tar.xz
cd linux-6.6.58

构建方法:

  1. 安装构建依赖
bash
Debian系
sudo apt install build-essential flex bison dwarves libssl-dev libelf-dev 
Arch系
sudo pacman -S base-devel openssl libelf
  1. 使用WSL2内核配置构建内核
plaintext
make KCONFIG_CONFIG=config-wsl的路径 -j$(nproc)

使用方法:

在文件C:\Users\你的用户名\.wslconfig(没有则创建此文件)

加入以下内容:

plaintext
[wsl2]
kernel=C:\\Users\\你的用户名\\vmlinux

相关的坑:

暂时没有找到解决方法,让6.6.58内核与Windows Docker Desktop 同时使用,目前的解决方法是使用5.15的内核

最相关的issue:https://github.com/microsoft/WSL/issues/11742

相关资料:

https://github.com/microsoft/WSL/releases

https://stackoverflow.com/questions/60830914/running-docker-gives-ports-are-not-available-error

https://xtzyj.top/2023/10/05/immich-introduction/

https://pythonspeed.com/articles/docker-connection-refused/

https://superuser.com/questions/1709437/how-can-i-update-the-kernel-in-wsl2-kernel-to-latest-release

https://learn.microsoft.com/en-us/windows/wsl/wsl-config#configuration-setting-for-wslconfig

历史比较老的内核:

https://www.catalog.update.microsoft.com/Search.aspx?q=wsl