DEV Community

Cover image for Hello Newbies in Tech! Try This Powerful Tool by Microsoft to use Linux Effortlessly with Windows OS

Hello Newbies in Tech! Try This Powerful Tool by Microsoft to use Linux Effortlessly with Windows OS

Ajeet Yadav on February 04, 2020

Originally published on my blogging site ajeet.dev I am a newbie in tech. I have been using Linux and Windows side by side for quite some time ...
Collapse
 
erebos-manannan profile image
Erebos Manannán

WSL2 is a massive mistake. It is build on Hyper-V, Microsoft's own hypervisor. It causes significant issues of many kinds - not least of which, that it's incompatible with VirtualBox, the hypervisor with which all other systems are compatible with.

Want to boot up a random Linux VM to try out things? Tough, you can't, Hyper-V is preventing Virtualbox from starting, and the Linux ISO won't boot in Hyper-V.

It's also been known to cause performance reductions for gaming, as well as triggering anti-cheat systems, and other such things.

I really tried to like Hyper-V for a while, but I had to give up on it. Still the best way to get most Linux utilities on Windows is Cygwin.

I wrote a bit about the setup I use for these things in dev.to/lietux/developing-like-a-pr...

Collapse
 
joedotnot profile image
joedotnot

This comment is totally alarmist, i've used hyper-v with a few linux ISO and had no problem booting, you just have to read some instructions carefully. e.g. Disable secure boot, Gen 1 vs Gen 2, etc...

Collapse
 
erebos-manannan profile image
Erebos Manannán

Yeah, so because a year later you tested a few ISOs and YOU ran into no issues nobody could ever have had any issues with it?

You just have to read some documentation that is likely nowhere to be found by mere mortals. Gotcha.

Even when it "works" Hyper-V is terribly slow compared to VMware Workstation or VirtualBox for e.g. Docker builds.

Thread Thread
 
laazik profile image
Marek Laasik

Ended up in this thread on a related search on DB speed comparisons under Hyper-V and WSL2. And found it a bit misleading.

The Linux ISO-s have been working on Hyper-V since 2014 (Debian. Redhat. I've run Oracle DB on Oracle Linux on Hyper-V), the fact that you have to turn off secure boot is also well documented, and pretty much the first result in the google search for linux iso not booting on hyper-v gen 2 gives in a preview a solution on how to fix it (by turning off secure boot). Btw. the MacBook Pro has a nasty feature where the CPU has some virtualisation bits left in "UNDEFINED" state, and debugging that was definitely a challenge (really nice hardware though).

As for performance, I can't complain, it's performant enough to boot up a complete dev env with several clusters of elastic, rabbit etc. and the throughput numbers (even for rabbit running in java VM-s inside the Hyper-V container) are very ok. Also docker builds both from command line and VS (which has it's own build system built around Docker, should you want to use it for .NET core, is very fast). Even on laptop systems.

So all in all, running Linux on Hyper-V is reasonable and well working. I do understand the personal dislike of some specific systems, or vendors, that's fine, I personally just don't use them at that point, instead of complaining how bad they are, but that is a matter of personal taste. Though it would be good to not mix up facts and subjective opinions.

Thread Thread
 
erebos-manannan profile image
Erebos Manannán

Well you say that, and then mix up facts and subjective opinions. I don't have an opinion about Hyper-V being bad. I've tested it and unfortunately found it to be very bad, while hoping it wouldn't be.

Thread Thread
 
kikonen profile image
Kari Ikonen

Performance of vmware and virtualbox with WSL2 enabled (aka. hyper-v) is just too poor. Running linux in virtualbox with VB 6.1.18 is slow, it's not unsably slow, thus someone can claim that "it works!", however, it's slower than without WSL2, slowing it down into uncomfortable level.

VMWare, well, commercial solution has also problems, with their latest version, which is claimed to be "hyper-v & WSL2" compatible: communities.vmware.com/t5/VMware-W...
Tried it also myself, and running windows 10 in vmware with WSL2 enabled, is too slow (with virtualbox comically slow, that's reason for trying out vmware); with either case, not usable (i.e. comparable to sticking needles under the fingernails).

Yes. reason for experimenting with wsl2 was attempt of trying to run docker in windows (and so far it seems that I've to abandon it due to these performance problems caused by hyper-v in vmware & virtualbox).

Thread Thread
 
erebos-manannan profile image
Erebos Manannán

I also tried Docker in Windows like that, and ended up with worse Docker performance than by running Docker in VMWare. So there's that too.

Collapse
 
yyech profile image
yyech

Other than the fs performance issue, I also encountered some network problems with wsl2 when accessing a VPN network or even just the host network.

I think the idea of wsl should be integrating Linux to Windows natively. Otherwise, why not just use a VM with a real Linux? But wsl2 is off this principle, as the network is separated as NAT; the fs is separated as ext4; a real Linux kernel might be also running somewhere... Everything are just like VM in wsl2.

Collapse
 
somerb profile image
Somer B. • Edited

Hi Janne,
It seems there are some workarounds about it. At docs.microsoft.com/en-us/windows/w... it says:
Some 3rd party applications cannot work when Hyper-V is in use, which means they will not be able to run when WSL 2 is enabled, such as VMware and VirtualBox. However, recently both VirtualBox and VMware have released versions that support Hyper-V and WSL2! You can learn more about VirtualBox's changes here and VMware's changes here.

Collapse
 
erebos-manannan profile image
Erebos Manannán

It seems that page has been last updated about a year ago. The updates they refer to are things that I've already found to be broken.

6.0.0 from 2018 was supposed to fix VirtualBox with Hyper-V, it doesn't, it's really broken, and the entire VirtualBox community seems to know this as they typically suggest removing Hyper-V as the only solution to getting VirtualBox to work when your computer has Hyper-V enabled.

It seems you're only spreading old marketing propaganda from Microsoft without doing any actual research on it.

Yes, at some point they thought they could make it work, Windows implemented some APIs that were supposed to make it possible, but those have repeatedly broken and VirtualBox has not worked with Hyper-V enabled a little while after the initial successful beta tests.

Thread Thread
 
somerb profile image
Somer B. • Edited

Spreading old marketing propaganda? Easy please..

virtualbox.org/wiki/Changelog:
VirtualBox 6.1.4 (released February 19 2020)
This is a maintenance release. The following items were fixed and/or added:
Windows host: Restore the ability to run VMs through Hyper-V, at the expense of performance

Changelog is VirtualBox's own changelog, their own promise! so how come it is Microsoft's old propaganda? If VirtualBox is broken it is not Microsoft's responsibility but Oracle's.

Thread Thread
 
erebos-manannan profile image
Erebos Manannán

If Microsoft breaks their APIs likely to intentionally break the compatibility with 3rd party virtualization software, how is that Oracle's fault?

And you linked to docs.microsoft.com/en-us/windows/w... a page last updated a year ago. A page which still made invalid claims about "recently both VirtualBox and VMware have released versions that support Hyper-V and WSL2" - out of date propaganda. The links on that page also link to VirtualBox 6.0 changelog - and all versions of VirtualBox 6.0 still fail to work under Hyper-V.

It's interesting that maybe VirtualBox has finally managed to fix the compatibility even without Microsoft's help using their proprietary intentionally broken APIs, but this might not be a long-lived solution and there is no sense in building any of your systems to depend now on Hyper-V since there are no guarantees it will not break again in the future.

Also this is far from the only issue with Hyper-V, though it was the most significant one to my work.

Thread Thread
 
erebos-manannan profile image
Erebos Manannán • Edited

People are also reporting that the performance hit is severe, which is unlikely to be accidental.

Thread Thread
 
macdub profile image
John McDowell

Yeah, I can confirm the performance hit is severe. Had WSL2 setup and VirtualBox 6.1.6 I was able to start my Win7 VM, but since VirtualBox was forced to use Hyper-V the VM never made it past the Win7 start up animation after 10-15 minutes.

Ended up reverting back to WSL1 to get the performance back on my VMs.

Thread Thread
 
erebos-manannan profile image
Erebos Manannán

Oh wow, that's worse than I thought .. I was just considering testing it out in the coming weeks for myself - thanks for saving me the effort!

Collapse
 
ondrejspilkaabb profile image
ondrejspilkaABB • Edited

Janne, it is pitty we can't add disappointment smiles.
Your comment is very inaccurate, subjective and dislike kind of (someone called "alarmist") with a lot of "one man said, people has" .. these are just rumors. You also comment someone is ignoring "facts"...well, if you want to criticize, just provide facts, e.g. performance impact and comparison charts.
Community doesn't care about feelings, if you put such a comment please state the facts together with evidence, otherwise do not hoax people.

  • WSL2 has nothing to do with anticheat
  • of course, any VM running on your PC actively affects performance of games, as both consume CPU cores, memory and IO system - you if wanna play just issue wsl --shutdown
  • yes, WSL2 is built on Hyper-V...what would you expect on Windows? Hyper-V is native MS virtualization platform with best performance you can get out of Windows
  • Hyper-V doesn't prevent VirtualBox, it is virtualization mechanism difference which causes mutual exclusivity of both tools (usually BIOS setting) ... good exlanation here superuser.com/a/1208857
  • Cygwin is definitely good piece of stuff, I've been using it 10 years ago, however uncomparable to WSL2, which is true nix kernel and disro
  • most of the popular nix distros are available via WSL2, if not, you will find then on gitHub (e.g. Alpine), if not, you can run them on Hyper-V (blog.qinnovate.biz/permalink/27bd5...)
  • MS doesn't care too much about VirtualBox or VmWare, obviously, as well as Oracle doesn't care about Windows products...
  • VBox and VmWare on Hyper-V will have performance penalty always - cause different hypervision levels used and middle layer added ... this is JUST usability improvment

Follow WSL2 FAQs docs.microsoft.com/en-us/windows/w...

[EDIT] - not sure what OS you're running and if you are talking about WSL2. I'm Windows11 and Ubuntu on WSL2 and I fairly satisfied.

Collapse
 
erebos-manannan profile image
Erebos Manannán

Say I should put "facts together with evidence" and then spout some utter nonsense. Nice attempt to raise the dead - this thread is from eons ago, but you're still wrong and sound like a fanboy.

Collapse
 
dguhl profile image
D. Guhl

If you have issues booting a Linux ISO with a Hyper-V machine, try to switch "Safe Boot" to "Microsoft UEFI Certification Authority" and enable TPM.

Hyper-V is a hardware abstraction layer, exclusively claiming your processor's virtualization and providing an API for Type-2-virtualizers running on Windows. It's a feature Microsoft sells, true, but on the other hand it provides a layer of management and security for sysops to control when, what and how virtualization on a Windows system takes place in order to comply to ISO certification. After all, the hypervisor runs in ring 0 of the processor and you would like to have a restricted and safe environment to manage such applications with care and caution, especially on Windows...! You can change VirtualBox' para-virtualization to Hyper-V.

I don't defend Microsoft and how it is implementing hardware-accelerated virtualization in Windows, but they have architectural reasons for how they make hardware-accelerated virtualization available in Windows, even though I personally believe to pack Hyper-V with the higher-priced Enterprise and Pro editions while blocking any other access to the processor's hardware accelerated virtualization is some sort of robbery - almost every processor made and sold within the last decade enables some sort of hardware-accelerated virtualization.

Collapse
 
kaodome profile image
KaoDome

It is kind of expected for 3rd party virtualization products not to work when Hyper-V is enabled, after all it's a type 1 hypervisor (native, like Xen or ESXi) and not a type 2 one (hosted, like VirtualBox or VMware Workstation).

When it's enabled the whole OS goes through it, so virtualization extensions aren't exposed and since they're required for some of not all type 2 virtualization offerings they won't work. Nested virtualization can be tricky, but I think there are some solutions out there that implement it (either by exposing virtualization extensions or by virtualizing without hardware assistance (with the performance penalty it entails)).

However, as it was stated before, both VMware Workstation and VirtualBox can now work when Hyper-V is enabled and I'm sure their implementation will continue to improve (at least VMware's being a commercial product and all).

As for WSL2, I find it useful, a great improvement from what SUA used to be and a step into the right direction in regards to WSL (it has to be easier to maintain for sure). I'm still using MSYS2 when it comes to Windows, but I'll certainly give WSL2 a try soon. I hope they keep working on it.

Collapse
 
erebos-manannan profile image
Erebos Manannán

It is expected for them to have issues because of the way it's implemented. Which makes the way it's been implemented bad for everyone, and the fact that e.g. Docker's default Windows installation depends on it pretty distasteful.

No, VirtualBox does not work in an acceptable way. I don't care about VMWare because it's not widespread, affordable, and manageable with vagrant and other such tools, so it may or may not work but it doesn't change my ability to use Hyper-V at all. No it will not keep getting better when Microsoft is actively working against that goal.

This is basically Microsoft trying to kill all other virtualization options in favor of Hyper-V - in a sensible world this should land Microsoft in yet another antitrust lawsuit.

Collapse
 
mavaddat profile image
Mavaddat Javid

If you have Windows Pro or Enterprise, then you can use the Hyper-V manager to set up your own VM's. There is even a "Quick Create" tool to download and install pre-configured disk images, Canonical Multipass is also a nice solution to any hiccup in installing Linux in Hyper-V.

Collapse
 
erebos-manannan profile image
Erebos Manannán

Yes, I used Hyper-V manager to try and boot up some basic Linux images that boot in literally every other environment, they failed to launch a GUI and froze.

If it says "Canonical" it is basically guaranteed to only support Ubuntu.

Collapse
 
ajeet profile image
Ajeet Yadav

Hi Janne,
Bookmarked you post. I will definitely check out the issues you have mentioned.
Windows WSL team is amazing btw 🙂. Hope they fix the issues you mentioned

Collapse
 
erebos-manannan profile image
Erebos Manannán

Well, the issue with WSL is that it's built on Hyper-V - the WSL team has nothing to do with Hyper-V's issues and the only thing they can do to help with that is to choose to not use Hyper-V.

Collapse
 
wolfhoundjesse profile image
Jesse M. Holmes

I was such a huge fan of WSL that I even bought a distro from the Windows Store. I came to Windows from years of Linux/BSD, and I wanted to bridge the gap. I even managed to get Arch on WSL.

Honestly, it has been a long time since I've fired up anything but PowerShell Core in my Windows Terminal. At this point, unless I need to reach for jupyter notebooks again, I'm not sure what I will use WSL for, and it kind of makes me sad.

It's inspiring that you can have Linux in your Windows environment, and you can run PowerShell Core on Linux. We live in an exciting time!

Collapse
 
ajeet profile image
Ajeet Yadav

Hi Jesse,

I did not know that one can purchase any distro and that too optimized for WSL. 😀 Thanks for the info.

And honestly I think, people using MacOs or a Linux will rarely switch to Windows. I think never ever. Windows is for newbies like me 😁 . I use Excel, and a data visualization software Tableau, that's why I need to use Windows.

And I am sure you have heard of Kaggle Kernels and Google Colabs for Jupyter notebooks. I have used in the past but for basic exploratory data analysis. They look promising.

Collapse
 
wolfhoundjesse profile image
Jesse M. Holmes

Ooo, I'm actually fairly new to python and data science, so those are brand new tools for me to check out. Thanks!

Never say never! I made the switch. 😊

Mac users, though … they're probably the toughest sell of all.

Thread Thread
 
ajeet profile image
Ajeet Yadav

Definitely check Kaggle and Google ones. They are extremely useful.

Mac users, though … they're probably the toughest sell of all.

Couldn't agree more 😁

Thread Thread
 
mateiadrielrafael profile image
Matei Adriel • Edited

I use linux for programming but dual boot windows for games, linux is just not as good in terms of gaming performance

Collapse
 
jef profile image
Jef LeCompte

Great article. I also think it's worth mentioning the new Microsoft Terminal project. Works well with WSL.

I'd also like to see some information based around connecting an IDE (like IntelliJ or CLion) to WSL for native code compilation.

Other than that, thanks again for taking the time to write this one up! Great for anyone starting.

Collapse
 
ajeet profile image
Ajeet Yadav

Thank you Jef for your comment 🙂
And yes, the new MS terminal looks cool. I cab create new tabs which is great. I used it a couple of months ago but it lacked the copy paste feature. I just hope they add this functionality.

Collapse
 
ricoet22 profile image
Kamil Pawlak

You don't have to install specified version package from the store, the standard one "Ubuntu" (without anything more) is better than version packages as it downloads the latest LTS version of Ubuntu and allows upgrades to future releases unlike the others.

Collapse
 
ajeet profile image
Ajeet Yadav

Oh i did not know that. Thank you Kamil

Collapse
 
filiplaurentiu profile image
Filip Laurentiu

why we need to run the Ubuntu with administrative privilege ?

Collapse
 
ajeet profile image
Ajeet Yadav

Hi Filip :)

I trust the Ubuntu app (downloaded from app store), that's why I run it as admin. As far as I remember, I could not recall any step that required admin privileges during the installation.

Collapse
 
nijeesh4all profile image
Nijeesh Joshy

great read, one question though. how do you make those cool terminal snapshots ? is it a theme ?

Collapse
 
ajeet profile image
Ajeet Yadav

Hey, Thanks :)

I use this website.

carbon.now.sh/

It is open source: github.com/carbon-app/carbon

Collapse
 
saulonunesdev profile image
Saulo Nunes

Hello @ajeet nice post, do u know if wsl2 supports docker volume and electron js? i droped wsl because of this conflicts on wsl1 and didnt had time to test on wsl2

Collapse
 
ajeet profile image
Ajeet Yadav

Hi Saulo,

I will have to check about docker.
For electron, plz check this guide

gist.github.com/wsargent/072319c21...

Collapse
 
joseluisrnp profile image
José Luis Recio

Hi again Ajeet! Great post, you're doing more easy mix the Windows world and Linux world, greetings

Collapse
 
ajeet profile image
Ajeet Yadav

Thank you 😊 Jose. You are very kind