Can images be built using WSL2?

Is it possible to use Windows' own Subsystem for Linux 2 to build OpenWRT images?

I found some discussion on the old forum that refer to WSL1, it seems there were some issues due to the way the file system was handled. Link, if interested

WSL2, OTOH, uses an ext4 hard disk container so those issues should be gone.

The benefit is that WSL2 is supposed to be faster than regular VMs, and less hassle.

Has anybody tried it yet?

Yes. It works fine.

1 Like

Thanks. Are any special options needed or recommended?

The previous thread mentioned limiting threads to 1, for instance.

The only thing I had to do was add

[interop]
appendWindowsPath = false

to /etc/wsl.conf inside whatever distro you're using.

1 Like

Great. How's the performance, BTW?

I normally use VirtualBox for my VMs, just FTR.

Is fast enough for my purposes. Not tried VirtualBox so couldn't compare.

Did you use something else before WSL2, and how did it compare, if you don't mind my asking?

I first used wsl1 and worked fine from the start. Compilation on I/O task (autoconfig task) was slow but all compiled well.
With wsl2 performance are comparable to a native compilation with the confort of use windows while the image compile.
It's like 1 years that is use it and no problem at all.

2 Likes

I did test WSL2 when it came out and it was as fast as setting up a Hyper-V debian box and assigning a vhdx or physical drive to it. That's no surprise, since if you stay on the WSL2 root partition, that's what it is, a tiny hyper-v container.

I switched to VirtualBox, since i can get simple local NAT working, instead of having the default hyper-v switch creeping in every adapter. Than hyper-v is also a L1 hypervisor, so you cant use anything else. Maybe the last point was somehow "fixed" with WSL2?

1 Like

That's very good news, thank you.

Not sure. There are other Windows features that rely on virtualization, though, such as the special Edge Sandboxing mode, whose proper name I can't recall right now, and that, too, is supposed to stop other virtualization software from working - at least while active.

The L1 hypervisor Hyper-v uses is a boot feature, either its turned on or off at boot-time. If i check https://docs.microsoft.com/en-us/windows/wsl/wsl2-faq than it seems Vbox6 can optionally be switched to use the hyper-v hypervisor, but no clue what this means for stability/performance. VMware can't at this point so just be aware of the difference in L1 and L2 hypervisors.

1 Like

Yup, I just noticed. Hadn't used my VBox yet after activating Windows Sandbox.

Apparently, it is possible to add an entry in the boot menu to disable it selectively, so VBox will run unhindered - as documented in this SuperUser answer.

According to the 6.0 changelog, switching to Hyper-V comes with a performance cost.

https://www.virtualbox.org/wiki/Changelog-6.0

OTOH, it doesn't seem to be working at all, for me. First, VBox is supposed to be detecting Hyper-V and switching to it automatically, and it's not happening with my existing Linux VM.

Switching the VM manually to Hyper-V still doesn't work: the Linux VM does appear to start instead of spitting an error right away, but after a while it's VERR_NEM_VM_CREATE_FAILED again.

about the connectivity... it does still use hyper-v
Also if you want to use vm you need to disable hyper-v and the windows defender virtualization feature. Since they made that difficult to use virtualbox and since i need linux just for the compilation tool, i find the command prompt sufficient, to access wsl2 files you can use a specific path in explorer.

Microsoft changed the rules of game - WS2 .0 is available now in all Windows 10 editiona, including Home edition. I would like to install OpenWRT image on one of non-development machine to investigate some connectivity issues between my Win10 2004 dev pre-view and my router. Is there suitable iSO ?

OpenWrt WiKi Page:
https://openwrt.org/docs/guide-developer/build-system/wsl