WSL2 – Installation Tutorial for Graphical Windows Subsystem on Linux
l-o-o-s-e-d.net
l-o-o-s-e-d.net
I never thought I would see the day I prefer Windows to OSX AND Linux for a development environment, but that day has come.
I am ASTOUNDED by how well WSL2 works, especially when integrated with VSCode.
For a much better terminal experience, I recommend Windows Terminal. Easy to configure, works great.
There is no other way to have a standard Linux distro and Photoshop on the same workstation without some far out hacks.
You get a lot of that on Mac though (well, less so on the gaming front, but Macs have some apps that aren't on Windows too). But that's "real" Linux, so you don't have to spend time installing GNU tooling or fighting with brew.
Dual booting can get annoying, because you have to, well, reboot.
You don't have to worry about hardware. Linux has come a long way, but there's still the random peripherical that doesn't work, or some where the configuration software is Windows only. It's pretty easy to avoid hardware that won't work with Linux, but in this world you don't even have to worry about that. Especially relevant in the desktop space where you have to look at every component.
WSL2 also has some interesting benefits, like being able to install a couple of different distros, or wipe out and start over in a few seconds if you screw things up. It's kind of the docker experience without docker.
In the corporate world, it also means not having to convince your employer to get a Linux install they'll support. The company I work for only allows Windows or Macs. Sure, I've worked at big companies where after some back and forth with IT we could get Linux on the PC machines, but it's nice not even have to go through the hoops.
There's some drawbacks: interop between the WSL2 file system and the Windows one works fantastic, but it's FREAKISHLY SLOW. If you're trying to git clone a big repo or npm install a big library and you're crossing boundaries between the two system, you're not going to be happy (as long as you stay within the WSL world you're fine though).
GUI apps are an issue. It's pretty easy to get most apps working using a Windows compatible X Server, but hardware acceleration is an issue. It looks like it might be possible to get working, but I sure as hell haven't been able to. The team is working on an official way to run GUI apps without going the X Server forwarding path, but it's not there yet. For now it works fine for simple things, like terminals and text editors, but trying to use Google Maps in Firefox is simply not useable (but it does work!).
I'm one of those weird people who actually likes Windows, and for 99% of my development use cases, Windows + WSL2 let's me do everything I need with zero compromise, and without having to reboot all the time. I can have a Windows-only game running with my Linux terminal open to do some development while I'm waiting for a group in my favorite MMO. Docker + WSL2 is great too.
I would like to emphasize the fact that I can get a windows machine and run WSL on it, and not get a bunch of eye-rolls from my IT director.
Additionally: Linux laptops are pretty OK, but Windows power profiles and power management make battery life on a windows machine MUCH better.
Incompatible hardware/software are definitely a real problem that probably affect a large enough percentage of people unfortunately.
Rebooting still means you can't do both things at once. And even if its instant, losing all my state is annoying. Sure, a proper window manager can restore state, and a good tab manager will preserve those too, but its a freagin pain in the ass. Plus the pre-boot sequence is slower than the actual OS booting, so I still consider that a pain.
Maybe I'm petty (to each their own), but rebooting once a week would drive me nuts, nevermind once a day.
If you are going to use Windows for work alongside gaming, wouldn't game launching being so convenient affect your focus?
Also, if you even think about compilation/rendering, if those are supposed to take long enough to complete so as to let you game long enough, wouldn't the game also use some of the system resources, maybe just enough to make the work even longer to complete?
And I'm not building 10 million lines of C++ on the side. For moderate sized apps (<100k LoC) in higher level languages (JS, Java, Python), building and/or running the code is mostly unaffected. While actually going through the code with grep or ag, cloning repos, reviewing PRs, making a commit, those aren't super CPU intensive.
And well, my gaming machine is so far beyond the macbook pros my employer provides, it's still going to be faster by a factor, game or not.
Lastly, even if there was a significant perf impact, being able to close the game and immediately fire up a terminal is still a lot better context switching experience than having to go through a reboot cycle.
Does that include all the phone-home stuff and ads as well?
I only run Windows (10) on a work laptop, and I'm guessing it's the 'Enterprise' edition, so all of that is not present. I've heard that there's a lot of intrusive garbage in the home-oriented editions: is that accurate?
(I sysadmin, so dog food Linux on my workstation.)
Edit: why the downvotes? As someone who runs an Helpdesk/IT-managed Windows laptop I have no idea what the state of the consumer Windows sphere is. The parent lists many good things: are there any bad things worth mentioning?
The phone home stuff is likely still there though.
Xbox app can be uninstalled, but not Xbox Game Bar? Bing on the Start menu search which for some reason I can't disable because there isn't any straightforward option for that.
When I try to download an app from Windows Store, the instant I press 'GET' button a dialogue window asking me to log into my MS account is opened upon closing which I can proceed to download the app.
I have the new Windows terminal setup to open the WSL2 Linux bash shell by default (and have it set so I can optionally use git bash if I need a shell in the Windows world).
Though a great way to use WSL2 is with Docker, which will leverage it for Linux environments instead of using a virtual machine (which it would do if WSL2 wasn't there). It's quite nice.
So instead I can run IntelliJ under WSL2? Nope, not until there's a performant X server. Ok, so under Windows, pointed at my Linux filesystem? Wouldn't there be dos2unix file format issues there? And it sounds like it's painfully slow for now until they fix the networking.
But this is somehow better than having to "brew install" a few things? I'm very eager to try this out, but I think WSL3 might be a better starting point.
What would the dos2unix issues be? Intellij on Windows can deal with and preserve all three line ending types, so it's not clear what the issue would be.
Can't say I've noticed any significant issues on performance. It does complain about filesystem case sensitivity (every time!), but it works pretty well overall.
I assume you'll have debugger issues if IntelliJ sees a different OS than you want your apps seeing.
That will depend on the size of the project. If you're dealing with tens of thousands of files, yeah. In JS-land the problem comes around node_modules folder. BUt a few hundreds or even thousands of files would be okay. Reads are actually quite fast (using ack/ag from Linux to search Windows isn't bad), it's writes that are awful.
Also there won't need to be a performant X Server. The solution they're working on is using a seemless RDP window, where everything works (including drag and drop between the Linux app and Windows)
Do they expose hardware perf counters in the VM? I.e. can you run instruction profilers?
Quite surprisingly, VcXsrv works very well as well out of the box. No additional configuration to what's mentioned in the article has been needed. Running a full GUI is a bit over the top but being able to run Linux GUI apps is sometimes a must.
This setup is all I've been asking for a long time and is worth trying to anyone who devs on Linux but wants to run windows as everyday OS.
All I've got trying to run docker was:
System has not been booted with systemd as init system (PID 1). Can't operate.
And it is right, WSL2 uses it's own init system that basically launches bash.There are some oddness with things like `--net=host` as the daemon is running in effectively another VM, but for standard Docker workflows it's been fine.
time docker run -d nginx 0c65064fc675427f0d49b837f368b6d17c3b42b2aa21bf80222baeb7ed20ed2b
real 0m1.556s user 0m0.018s sys 0m0.068s
sudo service docker start
.. voila
A difference between WSL and standard Linux is that is doesn't have a startup service manager, so you need to start services manually.
It will be a big step forward from the various X server options & is looking very promising.
Personally I am really liking WSL2- it has replaced an always on Linux VM for me (well, it is an always on Linux VM for me).
Here's a question I've been dying to ask someone who admits this is just a VM: What makes it better than running VirtualBox or VMWare Workstation, and having a nice GUI to control the various elements of the virtualization settings?
A VM has always felt a little cumbersome, even with all of the integrations working correctly.
https://docs.microsoft.com/en-us/windows/wsl/compare-version...
- easy integration with the Windows filesystem (it's automounted into the WSL env)
- Using VS Code to work with files in the WSL2 env. works out of the box (just type `code .` in a WSL windows)
- It's very quick to spin up new WSL2 instances. you can just use `--import` and it'll bring in a tarball to create your new instance. You can even export a Docker image and use that as a WSL instance base filesystem which is handy.
- Docker for Windows works pretty well for most usecases and you get one shared Docker instance across all your WSL setups.
Sure I could do all that with discrete managed VMs but this is easier
TBH for throwaway Kubernetes cluster in WSL, I'd recommend kind (https://github.com/kubernetes-sigs/kind) it works just fine with WSL/Docker for Windows.
One interesting thing is that if you have WSL2 turned on, then Windows runs virtualized as well -- it's just the 'root partition' under Hyper-V.
When it comes to user friendliness and things "just working", it's easily the worst choice you could make.
I completely agree on WSL1 but once I switched to WSL2 I haven't seen anything that doesn't "just work".
I'm just not seeing a good reason to stay Linux-native and I've been Linux-native for 10+ years now.
Apparently the integration Microsoft is working on uses RDP but with some magic or whatever to avoid tcp overhead? Maybe shared memory?
I hope it turns out performant cause the x11 method is like a party trick at best.
https://www.reddit.com/r/bashonubuntuonwindows/comments/gyk8...
The WSL2 Linux VM runs on Hyper-V, BESIDE windows, not on top of it. So the VM is fast and i/o is fast.
VSCode has a WSL2 plugin which enables it to operate in client/server mode with server running in Linux and client on Windows (seamless to end user). The setup works really well.
I've tried the GUI approach described in this post but there's a noticeable latency in GUI apps running in the VM. Microsoft has announced a new approach they're trying out so let's see how that plays out.
I'm not sure what he's trying to say here. unix based operating systems are gaining market share, so microsoft is adding support to stay relevant? The main problem is that most of the growth is coming from mobile/embedded devices, where the platform is so walled off to the user that it really doesn't matter whether the kernel is unix-like or not.
Well...
https://docs.microsoft.com/en-us/windows/wsl/install-win10#s...
If you can't just use the latest Windows 10 version, you really need to pay attention to version, build and minor-build.
This isn't mentioned in the blog post but if you use VcXsrv you can have it start up automatically by putting its config in your start up folder.
That's what I've been doing here for the last year or so: https://github.com/nickjj/dotfiles/blob/master/c/Users/Nick/...
If anyone prefers video about 6 months ago I recorded https://www.youtube.com/watch?v=idW-an99TAM which is about a 30 minute drive by of setting up WSL 2 + Docker + VcXsrv and a bunch of other tools that are handy on Windows for web development.
The only issue is with WSL I'm limited to console apps, so if I want to build an OpenGL or Vulkan or GUI project, I have to use Visual Studio or VSCode if I want a good development experience, and even then, it's not quite as comfy.
I can only hope that with better GUI support comes some kind of GPU passthrough, but a woman can only hope.
Until the native WSL 2 GUI support launches you can use some workarounds like Xpra or X2Go - see https://dev.to/derkoe/development-environment-in-wsl2-137l
Yeah, totally considering how hostile MS gaming division is towards Linux gaming and Vulkan adoption.
And with that money contribute back to the wheel that drives world economy.
We aren't in the 1960's any longer, though the music was nice.