Live data from Hacker News

WSL Manager

github.com

31–40 of 65 posts

Re: WSL Manager

#31

This is great and all... Except I’ve long given up on WSL. I really tried to make WSL work for many things, only to find the entire experience (reliability, performance, and beyond) was simply better in every way without Windows. No matter what you do, there will always be some weird platform detection or line termination that pops up somewhere. And if it isn’t that, it’s degraded performance or kernel-level incompat…

> (reliability, performance, and beyond) Considering it's just a headless linux vm with some integration with the host, I don't understand what reliability, performance or beyond it could possibly introduce beyond what any VM solution provides? There are few gotchas with WSL. I hate how by default it includes your Windows path in your default linux path out of the box. It's easy to turn off and my init scripts for an…

USB forwarding to WSL is built in to the WSL kernel, but you do need to install a thing on the windows side. After that, there are a number of GUIs to manage your usb devices or you can use the shell. Switching a usb devices from windows to WSL basically unplugs it from windows and plugs it into WSL.

I need it to access ssh keys from my yubikey. It’s painless if you just set it up to automatically forward the device on startup.

Re: WSL Manager

#32

Earlier quoted context omitted.

You said - "A bit more overhead since they now run as a VM instead of a container" To which osigurdson seemed to be noting that WSL2 itself is a VM (meaning if you launch 1 or 100 WSL2 instances, a single Linux VM will be spun up), and when you run docker, it runs using exactly that same VM (optionally, though it's the default now to just use WSL2's backend). Can you clarify what you meant by "A bit more overhead"? R…

For a single container the difference depends on your exact setup. I typically run docker in the same WSL instance as my other wsl stuff, so starting a single docker container adds 0 additional VMs, while starting the container as a wsl instance will add one VM. If you use the "docker for windows" package you may be adding a VM just for running docker, depending on your setup. Once you start the second container the…

"Running $N containers as separate WSL instances runs $N VMs and $N linux kernels."

But it doesn't, and this is what I'm disagreeing with.

If you instantiate WSL2, it launches a Linux VM. A single Linux VM. If you then run Docker with WSL2 integration (the default and hugely recommended), it uses that Linux VM as its VM as well, so you're still at 1 VM.

If you run 100 WSL2 instances, they will all use that single Linux VM, each doing namespacing for isolation with their own filesystems. If you run 100 Docker instances, they will all use that single Linux VM.

If you run 100 WSL instances, and 100 Docker instances (assuming, again, WSL2 integration which is the default), they will all be using that single Linux VM.

Re: WSL Manager

#33

Earlier quoted context omitted.

I ssh directly into WSL but for setting it up (auto-start, recovery, etc.) I ssh into PowerShell (which I hate). A TUI would go a long way there because no one wants to learn PowerShell.

You can use wsl.exe from powershell to manage wsl.

FWIW I started reverse engineering the WSL2 API -- it's not terribly complicated to do most tasks without the CLI (which is clunky IMO, as it had a number of times where it changed in backwards/forwards incompatible ways)

https://crates.io/crates/wsl-api

Re: WSL Manager

#34
this is great and I have a feature request: A "refresh VM" feature that exports your home dir + packages into a new VM instance.

I've tried Optimize-VHD but renewing the VM this way frees up disk and speeds up the VM as well. None of the WSL settings for sparse disk / disk shrinking seem to work well.

Here's what I usually do

   $ tar -czf /mnt/c/Temp/home-backup.tgz $HOME
   $ apt list --installed > /mnt/c/Temp/packages.txt
delete the VM, create a new one, reverse the process.

   $ tar -cxf /mnt/c/Temp/home-backup.tgz -C $HOME
   $ apt update
   $ cat /mnt/c/Temp/packages.txt | xargs apt install

Re: WSL Manager

#35

This is great and all... Except I’ve long given up on WSL. I really tried to make WSL work for many things, only to find the entire experience (reliability, performance, and beyond) was simply better in every way without Windows. No matter what you do, there will always be some weird platform detection or line termination that pops up somewhere. And if it isn’t that, it’s degraded performance or kernel-level incompat…

maybe it was WSL1 ? WSL2 IO is excellent as long as you stay within the FS. And with VS Code WSL support , all IO & commands are remoted into WSL so there are no Windows/Linux compatibility issues.

Re: WSL Manager

#36

This is great and all... Except I’ve long given up on WSL. I really tried to make WSL work for many things, only to find the entire experience (reliability, performance, and beyond) was simply better in every way without Windows. No matter what you do, there will always be some weird platform detection or line termination that pops up somewhere. And if it isn’t that, it’s degraded performance or kernel-level incompat…

So there’s a good number of comments, I’ll try to address them:

- Yes, these issues persist with WSL2.

- WSL2 allows mounting between the system/subsystem, but there is considerable overhead.

- Using WSL for remote workspaces from the host is very much a mixed bag.

- Attempting to use WSL entirely with graphical applications has very limited/poor support.

- If you wish for VM acceleration, you have to use Hyper-V, not all toolchains work with Hyper-V and this heavily restricts the host machine.

- If you wish to do anything that crosses the subsystem and the host, line delimiters and platform detection are very error prone.

- If you accidentally misconfigure WSL2 (which is quite easy to do) the WSL userspace can have substantial access to the host files, often beyond what may be initially apparent.

- Of compatibility issues, non-standard socket implementations have caused a lot of incompatibilities with software for me.

Re: WSL Manager

#37

Earlier quoted context omitted.

For a single container the difference depends on your exact setup. I typically run docker in the same WSL instance as my other wsl stuff, so starting a single docker container adds 0 additional VMs, while starting the container as a wsl instance will add one VM. If you use the "docker for windows" package you may be adding a VM just for running docker, depending on your setup. Once you start the second container the…

"Running $N containers as separate WSL instances runs $N VMs and $N linux kernels." But it doesn't, and this is what I'm disagreeing with. If you instantiate WSL2, it launches a Linux VM. A single Linux VM. If you then run Docker with WSL2 integration (the default and hugely recommended), it uses that Linux VM as its VM as well, so you're still at 1 VM. If you run 100 WSL2 instances, they will all use that single Lin…

Every time you run `wsl --install ` you are creating a new VM. Every time you run `wsl --unregister ` your are removing a VM.

It is these two operations at the heart of OP's app.

Re: WSL Manager

#38
post #37

Earlier quoted context omitted.

"Running $N containers as separate WSL instances runs $N VMs and $N linux kernels." But it doesn't, and this is what I'm disagreeing with. If you instantiate WSL2, it launches a Linux VM. A single Linux VM. If you then run Docker with WSL2 integration (the default and hugely recommended), it uses that Linux VM as its VM as well, so you're still at 1 VM. If you run 100 WSL2 instances, they will all use that single Lin…

Every time you run `wsl --install ` you are creating a new VM. Every time you run `wsl --unregister ` your are removing a VM. It is these two operations at the heart of OP's app.

Okay, are you guys using wrong terminology? Are you talking about a filesystem image as a "VM", because that would not be correct. A "Virtual HD" (VHD) is not a VM. Do you think a WSL2 distro instance is a "VM" because it's persistent? Did you know Docker containers can be persistent as well, people just choose as a best practice not to use it like that? Does that make them magical VMs?

WSL2 has a single VM running as the process vmmem (or vmmemWSL in the newest versions). This is the single Linux kernel that will be shared by every WSL2 instance. It will also be the instance that hosts Docker containers as well. I mean, I'm just echoing myself and apologies for the repetition, but this is just easily confirmed, utter factual truth.

A rootfs is not a VM. WSL2 and containers have different nuances about their filesystem and isolation (WSL2 instances is aware of other instances, for instance, as a design aspect, and WSL2 persists rootfs changes while docker as a best practices does not), but they're more alike than different. And they share little in common with something like VirtualBox or vmware, which actually isolate every such system as VMs.

Again, sigh, if you install 10 WSL2 "distros", you will have 10 rootfs overlays on your drive, and 10 persistence VHD files. When you run these the VM they all run under in the shared vmmem instance, which is the single utility Linux VM.

Re: WSL Manager

#39
post #37

Earlier quoted context omitted.

Every time you run `wsl --install ` you are creating a new VM. Every time you run `wsl --unregister ` your are removing a VM. It is these two operations at the heart of OP's app.

Okay, are you guys using wrong terminology? Are you talking about a filesystem image as a "VM", because that would not be correct. A "Virtual HD" (VHD) is not a VM. Do you think a WSL2 distro instance is a "VM" because it's persistent? Did you know Docker containers can be persistent as well, people just choose as a best practice not to use it like that? Does that make them magical VMs? WSL2 has a single VM running a…

Is there a way to visualize this on a running system or some documentation that describes it? I'm not familiar with the plumbing here but did try to find some documentation.

Re: WSL Manager

#40
post #39

Earlier quoted context omitted.

Okay, are you guys using wrong terminology? Are you talking about a filesystem image as a "VM", because that would not be correct. A "Virtual HD" (VHD) is not a VM. Do you think a WSL2 distro instance is a "VM" because it's persistent? Did you know Docker containers can be persistent as well, people just choose as a best practice not to use it like that? Does that make them magical VMs? WSL2 has a single VM running a…

Is there a way to visualize this on a running system or some documentation that describes it? I'm not familiar with the plumbing here but did try to find some documentation.

I've done a lot of in-depth WSL2 work, so I'm just aware of its particulars, but to cite some documentation-

https://learn.microsoft.com/en-us/windows/wsl/about

"WSL 2 uses virtualization technology to run a Linux kernel inside of a lightweight utility virtual machine (VM). Linux distributions run as isolated containers inside of the WSL 2 managed VM. Linux distributions running via WSL 2 will share the same network namespace, device tree (other than /dev/pts), CPU/Kernel/Memory/Swap, /init binary, but have their own PID namespace, Mount namespace, User namespace, Cgroup namespace, and init process."

(under "What is WSL2"?)

https://www.docker.com/blog/new-docker-desktop-wsl2-backend/

"WSL 2 runs all distros in the same utility VM, sharing the same Kernel."

If you run multiple distros take a look at the process manager and find the single vmmem or vmmemWSL (newer versions have the latter). That single instance is all of the instances, and all of the docker containers you might be running as well, each with namespace isolation (with WSL2 having intentional bridging between them for convenience). Visualise it by doing something intensive in any of them and seeing the single process react, because that's the single utility VM responsible for all of them. Further while starting up the first WSL2 instance or Docker container is expensive, requiring the initialisation of all of the resources for the utility VM and the memory to support it, subsequent iterations are much less expensive.

Post reply on HN