If you plan to use Linux shell environment while being forced to use Windows 10 Pro, Windows Subsystem for Linux (WSL) is one solution. After some release cycles and patch fixes, it seems stable enough to satisfy a few Linux admin requirements.
The main reason to use WSL is shared RAM. This way my computer is capable of running the Microsoft Office suite, OpenVPN, Microsoft Teams, huge load of tabs in Chrome, Slack, Rocket, … plus another 20 ssh connections without running out of RAM.
Launching an Ubuntu environment is easily done via Microsoft Store following this instructions. But if you need multiple environments, you will keep crawling the Internet (or continue reading).
As long as Microsoft does not offer a solution, luckily there is – LxRunOffline – which provides options to install new and clone existing environments even with choosing the installation path.
This way, multiple Ubuntu installations will find a home for testing ansible sketches, separating environments for different projects and further more.
At this point, I always recommend using cmder. This is a nice tabbed-style terminal emulator (based on ConEmu). One tab can run Powershell and other tabs can be used to handle connections to WSL – or multiple WSL environments.
After installing LxRunOffline using chocolatey, an apt style installer for Windows, a reboot is required.
A list of downloadable distribution WSL images can be found here: https://github.com/DDoSolitary/LxRunOffline/wiki
For this example Ubuntu server builds can be found here:
Download an image to your download directory (just cd into it) using curl.
curl https://cloud-images.ubuntu.com/releases/server/server/xenial/release-20190212/ubuntu-16.04-server-cloudimg-amd64-root.tar.gz -o ubuntu-16.04-server-cloudimg-amd64-root.tar.gz
Afterwards open a powershell session (or cmd). Running following command will output a few Warning messages about devices that can’t be created. It is safe to ignore them.
The filesystem for the WSL environment will be stored in C:\WSL\ubuntu-1.
The “s” flag will create a shortcut on your desktop for accessing a WSL shell.
LxRunOffline.exe i -n ubuntu-1 -d C:\WSL\ubuntu-1 -f ./ubuntu-16.04-server-cloudimg-amd64-root.tar.gz -s
After unpacking the image, check the result using the Windows built-in wslconfig tool which lists the “ubuntu-1” installation.
C:\Users\User\Downloads λ wslconfig.exe /l Windows Subsystem for Linux Distributions: Ubuntu (Standard) ubuntu-1 foobar install-test Ubuntu-18.04 Ubuntu-14.04 Ubuntu-16.04
This post will just give you an idea how to use WSL for your needs. Don’t expect too much, but WSL performance has become better over the past Windows updates. Some last words to quickly ramp you up:
- The installed WSL environment can be launched using the shortcut on the desktop or from within cmder
- The Windows user directory is available from within the WSL environment: /mnt/c/. Unfortunately file permissions with Windows mounts are still an issue as files are mapped to 777.
- Never modify WSL files from your Windows environment – though a backup can be done. I use 7zip to backup home directories of WSL environments.
- Docker in WSL – that is currently not working, but vagrant is possible to use with a special WSL flag and if the Vagrantfile is stored in a Windows share (/mnt/c/…)
- To run Vagrant, a virtualbox installation is required on the Windows host