LoginSignup
3
2

More than 3 years have passed since last update.

WSL2でカスタムカーネルを使う

Last updated at Posted at 2020-03-24

WSL2にてカスタムカーネルを使う方法を書きますた。

Linux 5.xを使う

追記です。
scoopを使っていて、Linux 5.x (next) を使いたいならこれを
(公式カーネルはもう既に5.10までにBumpされています。)

ifscoop
# If you may need
# scoop install git
scoop bucket add github-koumaza https://github.com/koumaza/bucket.git
scoop install wsl2-next
overwrite-in-pwsh
Write-Output (
    "[WSL2]" + "`n" +
    "kernel=C:\\Users\\" + ${env:USERNAME} + "\\scoop\\apps\\wsl2-next\\current\\bzImage"
) > ${env:USERPROFILE}\.wslconfig

For scoop .wslconfig
.wslconfig
[WSL2]
kernel=C:\\Users\\[USERNAME]\\scoop\\apps\\wsl2-next\\current\\bzImage

カーネルのコンパイル (例)

github - microsoft/WSL2-Linux-Kernel

依存関係

Ubuntu

build-essential flex bison libssl-dev libelf-dev

ArchLinux

base-devel flex bison openssl libelf

ソース

ビルド

shell
 make KCONFIG_CONFIG=Microsoft/config-wsl
# or. AutoEnter
 yes '' | make KCONFIG_CONFIG=Microsoft/config-wsl

Windowsでの設定

~/.wslconfigを弄ります。
の前に!uname -acat /proc/versionをしておきましょう。

ホームパスに次のファイルを作ります。
[USERNAME]を置き換えてください。

.wslconfig
[WSL2]
kernel=C:\\Users\\[USERNAME]\\vmlinux

インスタンスを起動している場合はwsl --shutdownをします。
vmlinuxの場所はもちろん自由です。各自好きなところに。
Linux 5.x
image.png

WSL2でぜんぶできるね

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2