@@ -28,21 +28,32 @@ Instructions for building an x86_64 WSL2 kernel with an Ubuntu distribution are
2828as follows:
2929
30301 . Install the build dependencies:
31- ` $ sudo apt install build-essential flex bison dwarves libssl-dev libelf-dev cpio `
31+ ` $ sudo apt install build-essential flex bison dwarves libssl-dev libelf-dev cpio qemu-utils `
3232
33332 . Modify WSL2 kernel configs (optional):
3434 ` $ make menuconfig KCONFIG_CONFIG=Microsoft/config-wsl `
3535
36- When using a custom-built kernel, loadable module support is disabled.
37- Configurations set as modules (=m) won’t be available. Set any needed modules
38- to built-in (=y) before building your custom kernel.
36+ 3 . Build the kernel using the WSL2 kernel configuration and put the modules in a ` modules `
37+ folder under the current working directory:
38+ ` $ make KCONFIG_CONFIG=Microsoft/config-wsl MODLIB="$PWD/modules" `
3939
40- If you prefer the old configuration before WSL introduced loadable module
41- support, you can use the old config file from the linux-msft-wsl-5.15.y branch
42- to build your v6.6 WSL2 kernel.
40+ 4 . Calculate the modules size (plus 1024 bytes for slack):
41+ ` modules_size=$(du -s "$PWD/modules" | awk '{print $1;}'); modules_size=$((modules_size + 1024)); `
4342
44- 3 . Build the kernel using the WSL2 kernel configuration:
45- ` $ make KCONFIG_CONFIG=Microsoft/config-wsl `
43+ 5 . Create a blank image file for the modules:
44+ ` dd if=/dev/zero of="$PWD/modules.img" bs=1 count=$modules_size `
45+
46+ 6 . Setup filesystem and mount img file:
47+ ` lo_dev=$(losetup --find --show "$PWD/modules.img"); mkfs -t ext4 $lo_dev; sudo mount $lo_dev "$PWD/modules_img" `
48+
49+ 7 . Copy over the modules, unmount the img now that we're done with it:
50+ ` cp -r "$PWD/modules" "$PWD/modules_img"; sudo umount "$PWD/modules_img" `
51+
52+ 8 . Convert the img to VHDX:
53+ ` qemu-img convert -O VHDX "$PWD/modules.img" "$PWD/modules.vhdx" `
54+
55+ 9 . Clean up:
56+ ` rm modules.img # optionally $PWD/modules dir too `
4657
4758# Install Instructions
4859
0 commit comments