Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2 "boards" wsl2-x86/wsl2-arm64 with current (6.1.y) and edge (6.6.y) kernels with Microsoft patches #5978

Conversation

rpardini
Copy link
Member

WSL2 "boards" wsl2-x86/wsl2-arm64 with current (6.1.y) and edge (6.6.y) kernels with Microsoft patches

…6.6.y) kernels with Microsoft patches

> tl,dr: add 4 small-ish UEFI-like kernels, with Microsoft patches & fixes, for use with Microsoft WSL2 on x86/arm64 and 6.1.y/6.6.y

- the boards are UEFI derivatives, using a common `microsoft` vendor include to modify
  - `KERNELPATCHDIR`/`LINUXFAMILY` (for now, we don't want those patches in regular UEFI builds / .debs)
  - disable `EXTRAWIFI` (kernel is for a VM, will never have wifi so doesn't need any drivers)
  - `LINUXCONFIG`, so we can use Microsoft's own monolithic kernel, required for WSL2 (their initrd is a mistery)
- really, what we're mostly interested right now are the kernels (in the future we might have an "Armbian" WSL2 app in the Microsoft Store)
  - `current` `6.1.y`:
    - rebased from https://github.com/microsoft/WSL2-Linux-Kernel/tree/linux-msft-wsl-6.1.y onto real 6.1.y
    - using Microsoft's `.config` exactly (monolithic, there are no `=m`'s)
  - `edge` `6.6.y`:
    - also from https://github.com/microsoft/WSL2-Linux-Kernel/tree/linux-msft-wsl-6.1.y but rebased onto 6.6.y
    - using updated Microsoft's `.config` (monolithic, there are no `=m`'s)
    - dropped 2 of 6.1.y's patches that were actually upstreamed in the meantime:
      - `mm-page_reporting-Add-checks-for-page_reporting_order-param` - mainlined in https://lore.kernel.org/all/1664517699-1085-2-git-send-email-shradhagupta@linux.microsoft.com/
      - `hv_balloon-Add-support-for-configurable-order-free-page-reporting` - mainlined in https://lore.kernel.org/all/1664517699-1085-3-git-send-email-shradhagupta@linux.microsoft.com/
    - drop the `arm64: hyperv: Enable Hyper-V synthetic clocks/timers` patch, since it causes asm breakage on 6.6.y
      - a shame, but I tried and can't fix it myself - @kelleymh ?
    - add my own patch to fix:
      - `1709-drivers-hv-dxgkrnl-restore-uuid_le_cmp-removed-from-upstream-in-f5b3c341a.patch` due to https://lore.kernel.org/all/20230202145412.87569-1-andriy.shevchenko@linux.intel.com/ landing in 6.6
      - `1710-drivers-hv-dxgkrnl-adapt-dxg_remove_vmbus-to-96ec29396-s-reality-void-return.patch` to adapt to
        https://lore.kernel.org/all/TYCP286MB2323A93C55526E4DF239D3ACCAFA9@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
… kernel

- previous commit introduces Armbian wsl2 kernels, might as well detect them
@github-actions github-actions bot added size/large PR with 250 lines or more Hardware Hardware related - kernel, u-boot, patches and removed size/large PR with 250 lines or more labels Nov 26, 2023
@rpardini
Copy link
Member Author

Instructions for testing Armbian kernels on WSL2

  • Install Windows on physical hardware or VM with nested virtualization (I tested with Win11)
  • elevated Powershell: wsl --install --no-distribution
  • reboot. not optional.
  • install the Debian app from Microsoft Store https://apps.microsoft.com/detail/debian/9MSVKQC78PK6
  • open Debian in Windows Terminal, wait, create user, note value of uname -a
  • sudo apt install linux-base (Armbian kernel should depend on this, but I guess Ubuntu is different)
  • add my Armbian testing repo (not wsl2-specific):
    sudo wget --output-document=/usr/share/keyrings/armbian-next.gpg https://apt-test.next.armbian.com/armbian-next.gpg
    cat << EOD | sudo tee /etc/apt/sources.list.d/armbian-next.list
    deb [signed-by=/usr/share/keyrings/armbian-next.gpg] http://apt-test.next.armbian.com armbian main
    deb [signed-by=/usr/share/keyrings/armbian-next.gpg] http://apt-test.next.armbian.com armbian-$(lsb_release -cs) main
    EOD
    sudo apt update && sudo apt list --upgradable | grep  -i armbian 
  • install the Armbian wsl2 kernel you want:
    • sudo apt install linux-image-current-wsl2-x86: for x86/x64, 6.1.y; recommended
    • sudo apt install linux-image-edge-wsl2-x86: for x86/x64, 6.6.y; recommended
    • sudo apt install linux-image-current-wsl2-arm64: for arm64, 6.1.y; recommended
    • sudo apt install linux-image-edge-wsl2-arm64: for arm64, 6.6.y; missing HYPERV_TIMER patch
  • determine your home directory in Windows
    • In Windows cmd.exe: echo %USERPROFILE% (in my case it's C:\Users\rpardini)
  • copy kernel images outside WSL2 into Windows home directory
    • sudo cp -v /boot/vmlinuz-* /mnt/c/Users/rpardini/
  • list kernels in your home directory
    • ls /mnt/c/Users/rpardini/vmlinuz-* (mine is /mnt/c/Users/rpardini/vmlinuz-6.6.2-edge-wsl2-x86)
  • edit WSL2 config file in your home directory
    • sudo nano /mnt/c/Users/rpardini/.wslconfig
    • Add/change to point to the new kernel, note the escaped backslashes and the C: reference
      [wsl2]
      kernel=C:\\Users\\rpardini\\vmlinuz-6.6.2-edge-wsl2-x86
  • elevated Powershell: wsl -l -v and see your running Debian
  • elevated Powershell: wsl --shutdown to shut down the hidden HyperV/HSC virtual machine and force new kernel boot
  • open Debian in Windows Terminal, wait, note value of uname -a
  • you can switch current/edge if you install both, but you must change .wslconfig and wsl --shutdown every time

@rpardini rpardini marked this pull request as ready for review November 26, 2023 17:22
@rpardini rpardini requested review from a team and igorpecovnik as code owners November 26, 2023 17:22
@igorpecovnik igorpecovnik added Needs review Seeking for review 02 Milestone: First quarter release Ready to merge Reviewed, tested and ready for merge 11 Milestone: Fourth quarter release and removed 02 Milestone: First quarter release Needs review Seeking for review labels Nov 26, 2023
Copy link
Member

@igorpecovnik igorpecovnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good & can't break anything.

@igorpecovnik igorpecovnik merged commit 91a3607 into armbian:main Nov 27, 2023
18 of 20 checks passed
@fensoft
Copy link

fensoft commented Feb 4, 2024

i'm using this kernel on my wsl2 to build armbian itself (microsoft's default one seems to have a bug with /dev/loop0 not creating /dev/loop0p?)

@Jubei-VA
Copy link

Jubei-VA commented Apr 21, 2024

Instructions for testing Armbian kernels on WSL2

* Install Windows on physical hardware or VM with nested virtualization (I tested with Win11)

* **elevated Powershell**: `wsl --install --no-distribution`

* reboot. not optional.

* install the Debian app from Microsoft Store https://apps.microsoft.com/detail/debian/9MSVKQC78PK6

* open Debian in Windows Terminal, wait, create user, note value of `uname -a`

* `sudo apt install linux-base` (Armbian kernel should depend on this, but I guess Ubuntu is different)

* add my Armbian testing repo (not wsl2-specific):
  ```shell
  sudo wget --output-document=/usr/share/keyrings/armbian-next.gpg https://apt-test.next.armbian.com/armbian-next.gpg
  cat << EOD | sudo tee /etc/apt/sources.list.d/armbian-next.list
  deb [signed-by=/usr/share/keyrings/armbian-next.gpg] http://apt-test.next.armbian.com armbian main
  deb [signed-by=/usr/share/keyrings/armbian-next.gpg] http://apt-test.next.armbian.com armbian-$(lsb_release -cs) main
  EOD
  sudo apt update && sudo apt list --upgradable | grep  -i armbian 
  ```

* install the Armbian wsl2 kernel you want:
  
  * `sudo apt install linux-image-current-wsl2-x86`: for x86/x64, 6.1.y; recommended
  * `sudo apt install linux-image-edge-wsl2-x86`: for x86/x64, 6.6.y; recommended
  * `sudo apt install linux-image-current-wsl2-arm64`: for arm64, 6.1.y; recommended
  * `sudo apt install linux-image-edge-wsl2-arm64`: for arm64, 6.6.y; missing HYPERV_TIMER patch

* determine your home directory in Windows
  
  * In Windows cmd.exe: `echo %USERPROFILE%` (in my case it's `C:\Users\rpardini`)

* copy kernel images outside WSL2 into Windows home directory
  
  * `sudo cp -v /boot/vmlinuz-* /mnt/c/Users/rpardini/`

* list kernels in your home directory
  
  * `ls  /mnt/c/Users/rpardini/vmlinuz-*` (mine is `/mnt/c/Users/rpardini/vmlinuz-6.6.2-edge-wsl2-x86`)

* edit WSL2 config file in your home directory
  
  * `sudo nano /mnt/c/Users/rpardini/.wslconfig`
  * Add/change to point to the new kernel, note the escaped backslashes and the C: reference
    ```ini
    [wsl2]
    kernel=C:\\Users\\rpardini\\vmlinuz-6.6.2-edge-wsl2-x86
    ```

* **elevated Powershell**: `wsl -l -v` and see your running Debian

* **elevated Powershell**: `wsl --shutdown` to shut down the hidden HyperV/HSC virtual machine and force new kernel boot

* open Debian in Windows Terminal, wait, note value of `uname -a`

* you can switch current/edge if you install both, but you must change .wslconfig and wsl --shutdown every time

Thanks! This fixes the issue with:
loop0 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.
On the default wsl2 kernel. I went with the 6.1 kernel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
11 Milestone: Fourth quarter release Hardware Hardware related - kernel, u-boot, patches Ready to merge Reviewed, tested and ready for merge
Development

Successfully merging this pull request may close these issues.

None yet

4 participants