Last active
October 1, 2025 17:06
-
-
Save ryuheechul/46ef054855c78c242157790adaa26fb1 to your computer and use it in GitHub Desktop.
Revisions
-
ryuheechul revised this gist
Apr 12, 2023 . No changes.There are no files selected for viewing
-
ryuheechul revised this gist
Apr 12, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ _I'm not the author the blog post and this gist is a simply a note on my usage based on the original post, https://boxofcables.dev/kvm-optimized-custom-kernel-wsl2-2022/._ _I also changed the code that extract the latest to a concrete linux kernel version._ -
ryuheechul created this gist
Apr 12, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ _I'm not an author the blog post and this gist is a simply a note on my usage based on the original post, https://boxofcables.dev/kvm-optimized-custom-kernel-wsl2-2022/._ _I also changed the code that extract the latest to a concrete linux kernel version._ First start with [openSUSE Tumbleweed distro](https://www.microsoft.com/store/productId/9MSSK2ZXXN11) and commands below can be used to build the custom kernel and set it to be used for WSL2 distros. ```bash # prepare build deps sudo zypper -n up # original from the post sudo bash -c "zypper in -y -t pattern devel_basis && zypper in -y bc openssl openssl-devel dwarves rpm-build libelf-devel aria2 jq" # what I ended up doing instead sudo zypper install -y aria2 make gcc bison flex bc libelf-devel libopenssl-3-devel dwarves # download and unpack kernel source code and cd into it echo 'https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/linux-msft-wsl-6.1.21.1.tar.gz' | aria2c -i - tar -xf *.tar.gz cd WSL2-Linux-Kernel-linux-msft-wsl-6.1.21.1/ # modify config cp Microsoft/config-wsl .config sed -i 's/# CONFIG_KVM_GUEST is not set/CONFIG_KVM_GUEST=y/g' .config sed -i 's/# CONFIG_ARCH_CPUIDLE_HALTPOLL is not set/CONFIG_ARCH_CPUIDLE_HALTPOLL=y/g' .config sed -i 's/# CONFIG_HYPERV_IOMMU is not set/CONFIG_HYPERV_IOMMU=y/g' .config sed -i '/^# CONFIG_PARAVIRT_TIME_ACCOUNTING is not set/a CONFIG_PARAVIRT_CLOCK=y' .config sed -i '/^# CONFIG_CPU_IDLE_GOV_TEO is not set/a CONFIG_CPU_IDLE_GOV_HALTPOLL=y' .config sed -i '/^CONFIG_CPU_IDLE_GOV_HALTPOLL=y/a CONFIG_HALTPOLL_CPUIDLE=y' .config sed -i 's/CONFIG_HAVE_ARCH_KCSAN=y/CONFIG_HAVE_ARCH_KCSAN=n/g' .config sed -i '/^CONFIG_HAVE_ARCH_KCSAN=n/a CONFIG_KCSAN=n' .config # build kernel make -j 8 # move kernel to Windows host powershell.exe /C 'Copy-Item .\arch\x86\boot\bzImage $env:USERPROFILE' # print '$env:USERPROFILE\.wslconfig' just in case it existed before cat /mnt/c/Users/$(powershell.exe '$env:USERNAME')/.wslconfig # set kernel file path to '$env:USERPROFILE\.wslconfig' powershell.exe /C 'Write-Output [wsl2]`nkernel=$env:USERPROFILE\bzImage | % {$_.replace("\","\\")} | Out-File $env:USERPROFILE\.wslconfig -encoding ASCII' # verify the content cat /mnt/c/Users/$(powershell.exe '$env:USERNAME')/.wslconfig ``` And now this built kernel be the kernel for all wsl distros not just for openSUSE one unless the setting gets reversed later.