Why I switched from WSL to VirtualBox?

  • I am an avid Linux user and like most of the Linux community, I love to use command line to get things done.
  • Our corporate production servers run on Centos, but we use Visual Studio to code/unit test on Windows. Hence I always needed a dedicated Linux server to compile/test/debug/run Linux apps at ease and at the same time I needed a Windows system as well.

This is where WSL came in, When WSL was announced I got really excited to have both the worlds in one Computer. I realized that within few months I got so unproductive using it.

Here the problems I found while using WSL1.

Issues with WSL1

  1. I use a Remote SSH extension in VSCode to talk to WSL on HOST windows. This slows down the whole PC. I have to restart VSCode to make it little better but then , WSL and VSCode hogs up so much of Windows resources.
  2. The I/O is damn slow, it takes huge time to build/compile any C++ applications using gcc 5.0+. And for sure it affects my Windows apps too.
  3. Cannot run Docker on WSL. I use the DOCKER_HOST env variable to point to HOST docker server to pull/push, its not the same though. Docker server needs to be started in Windows, that is even though I am not doing anything with Docker in Windows.
  4. Cannot move/rename files in VSCode doing Remote SSH to WSL. Pretty sure this is addressed in WSL2 (will get to WSL2 in a min).
    https://code.visualstudio.com/docs/remote/wsl#_i-see-eaccess-permission-denied-error-trying-to-rename-a-folder-in-the-open-workspace-in-wsl-1
  5. If I have to use the same WSL in multiple computers. For ex, I have an updated WSL with many dev tools and its dependencies installed overtime. I cannot just export that WSL to another place and get it up and running. The perfect use case of this is, your PC crashed and some how you could boot into it (safe mode) and you cannot export the WSL. Mind you I have tried it, its an adventure to say the least.

Most of the issues above are solved in WSL2. But here are the other issues that I faced.

Issues with WSL2

  1. Moving to WSL2 introduced another major problem using Hyper-V. There is a DNS resolution issue. This is non-issue for people using WSL2 on their personal computer. But on an high secured office network this is a show-stopper. There is a discussion on this and many people have suggested and some one has a gist to resolve it. For me none of them worked. Wasted couple of days to get it up and running. https://gist.github.com/coltenkrauter/608cfe02319ce60facd76373249b8ca6
  2. Slowness still remains, may be its just my setup i.e. VSCode + RemoteWSL2. This definitely hogs up resources. I can come up with benchmarks (wonder if it’s really worth to spend time on that).

I gave up because the issue mentioned in point 1 is a deal breaker for me.

Introducing VirtualBox.

  1. Sounds like a bad idea when you plan on running a VM in your PC. Right? I know what you mean! VM’s Guest OS needs dedicated CPU/RAM. But just read on, I have a 24 core/64GB RAM desktop/laptop, I have allocated 4 core/16GB RAM dedicated to Centos VM. No slowness , I can run ansible playbooks, docker containers, C++ builds with GCC, all working without any hiccups. Please note I am starting Guest OS in headless mode and I think this is the trick.
  2. Import/Exporting a VM is not at all an issue. I can even run multiple Guest OS starting/stopping at will. I can save the existing Guest OS which is <windows home folder>/VirtualBox/VMs/centos.vdi (Your path could be different) file and run that same Guest OS in another computer and I don’t have to install everything from scratch. I can save snapshots, if at all I mess up the Guest OS, I just go back to the last successful saved state.
  3. I did encounter an issue with VirtualBox. Guest OS network cannot talk to Host, I resolved it by using two Adapters as shown below. Also note that for better network speeds use Para virtualized network.

4. Docker containers run little slow, I can live with that or I can bump up the CPU allotted to VM and drop down the CPUs after I complete/push my docker builds.

5. The last but not the least, my original setup of VSCode + Remote SSH works without slowing down the Host PC. This is a game changer for me, try it out yourself.

Final thoughts

  • Everybody’s development needs are different and hence the development environment. My setup is VSCode + WSL + Remote SSH + Docker + Kubernetes(recently) slows down HOST computer. And I have spent many days resolving network issues, I/O slowness and mainly using Dockers.
  • Switching to VirtualBox gives me a full fledged Linux server and at the same time I can make use of the same updated VirtualBox image from multiple computers without re-inventing the wheel. If you want to be productive , I would strongly urge you to try this option out.
  • For naysayers and critics, I am not against Microsoft/WSL . It’s an amazing product. For my setup it didn’t work efficiently. It may work out great for many others out there.

Engineer in Computer Science from Bangalore University. Working as a Software Engineer for two decades. I have experience in wide range of skills viz. C++/Linux