Social Network

Twitter

Tag: linux

As of Windows 10 Anniversary Update, there was the inclusion of an awesome new tool that allowed users to have their very own Bash terminal on Windows without needing to run a Linux image in a hypervisor. This new tool was called the Windows Subsystem for Linux, which shipped with it’s own copy of a Canonical sanctioned variant of Ubuntu 14.04. The differences between it and a normal Ubuntu installation to any experienced Linux user would probably identify a couple of things that stuck out as being different. First item up is that the Kernel details listed Microsoft, second item up is that a lot of the linux utilities would either not return the right information, or just outright fail. Ansible for example is one such tool that I use and didn’t work under this new subsystem because semiphores were not entirely supported yet.

What Microsoft did was essentially create their own kernel in what they call a “pico-process”, which is essentially a proxy between Linux kernel calls to the Windows kernel’s implementations (or using bridges for things that didn’t quite match up. This environment, even with the terminal window on the screen, doesn’t use up any system resources – until a command is executed. It’s pretty cool and as of this blog post, entirely negated the use VirtualBox for me to run Fedora locally to get a fully functional Bash terminal.

As of Windows 10 Creators Update, the proxy-kernel has been updated and pretty much supports everything I could imagine wanting to run now, without any issues. Along with the kernel updates was an update to the Ubuntu image that you could use, which is now Ubuntu 16.04. The one thing I don’t like about the whole thing is this lock-in to using Ubuntu, when I’m pretty much a fanboy of the RedHat ecosystem – from RHEL, CentOS, Amazon Linux, and to Fedora. But now there’s a way to not only use this subsystem with a different Linux distribution, you can use it with multiple distributions.

Getting Updated Ubuntu Image – Suggested way

This will literally nuke everything you have in the existing Ubuntu environment. Be sure to backup everything you care about NOW, before running the following command.

Close any existing Bash terminal windows you may have open

Execute the following two commands

C:\> lxrun /uninstall /full /y
C:\> lxrun /install

Ensure that you enter in the username and password of choice after the last command that you’ll use going forward with that environment.

Getting Updated Ubuntu Image – Easy way

This will keep everything you have in place and do an in-place upgrade, but Microsoft doesn’t suggest it. It would be a good idea to backup things anyways even though you should theoretically be safe here.

$ sudo do-release-upgrade

I guess if you’re fine with Ubuntu, then you’re done. Have fun, see you again in another year when I decide to blog again.

If you’re not fine with Ubuntu like I am, then we have some more work to do…

Another Distribution – Downloading

The README for the GitHub project we just cloned shows the following images and tags are available as of August 18th:

This will only download a Docker repository image of a distribution you’re interested in. It does not install it, that’s another step. You can run this multiple times for the distributions you’re interested in, if you choose.

Install Python3 in your Windows environment (not inside the Linux subsystem) and include it in your PATH.

Open a command or PowerShell Prompt

Execute the following command

git clone https://github.com/RoliSoft/WSL-Distribution-Switcher.git

Move into the git directory

Rename the hook_postinstall_all.sample.sh file to hook_postinstall_all.sh

Execute the following command using the appropriate tags defined above

python get-prebuilt.py [docker_image_identifier]:[image_version]

Another Distribution – Installing

Now we’re going to switch into the distribution we want and just downloaded.

Close any existing Bash terminal windows you may have open

Execute the following command

python install.py [docker_image_identifier]:[image_version]

Open the Bash terminal by launching the “Bash on Ubuntu on Windows” link in the start menu again

Execute the following command:

dnf --version

Another Distribution – Switching

You can repeat the download and install steps multiple times, for each distribution you’re interested in. The last install ran makes the subsystem of that distribution, but each install performed on the machine stays, and it makes a note of each installation performed. Which makes this next step much awesome and so wow.

$ python switch.py
usage: ./switch.py image[:tag]
The following distributions are currently installed:
- amazonlinux:latest
- fedora:latest
- ubuntu:trusty
To switch back to the default distribution, specify ubuntu:trusty as the argument.

The downside is that you aren’t able to have multiple distributions active at the same time, but switching like this is still pretty awesome.

Well, now that I’ve shared that information, I’m going to go clear up 80gb of disk space by removing VirtualBox and it’s assorted images.

For more information, see the blog post from Microsoft here and the README of the project you just blindly cloned to your machine and arbitrarily ran commands from because a blog post referenced it.