WSL2: VM’s in Windows are now Obsolete
In my previous miscellaneous post, I wrote about why I gave up on WSL1 and switched to running ubuntu in a virtual machine. After looking into WSL2 more, I caved and joined the Windows insider program and updated to build 2004, which includes WSL2. I was a little annoyed that more work was needed to update to WSL2 after the install, but it really only took another 5 minutes, so who am I to complain.
The short story is that WSL2 is now a lightweight virtual machine within windows. That means immediate boot times and full system call compatibility. It integrates very nicely with VS Code, but I have found some weird quarks. One complaint with WSL1 was the abstruse file system. That has not changed yet, but ostensibly the filesystem integration has been updated only in the Fast Ring. For now, you still have to deal with being finicky about managing files in WSL2. For example, if you navigate to the ~/usr for in WSL2 and add a file, when you fire up WSL2 and try to access it, you will find it is untouchable. If, instead, you fire up WSL2 and open that same directory, i.e.
> cd ~/usr
> explorer.exe .
you can then add the file and it’ll work totally fine. It’ll even show up in the local system folder that you added it to before. Working within WSL2 still involves some tiptoeing, but I think it’s a worthwhile tradeoff if you don’t want to abandon windows. Only downside is that my laptop now crashes if I try to use it while charging … If I knew I were going to be a data scientist and not a materials engineer when I bought this laptop, I would have gone with a mac instead.
*
update: The crashing problem got fixed eventually. I don’t remember how, but I’m sure it was some driver or maybe the bios update that fixed it.