Skip to content

External VM Builds on Linux Subsystem for Windows

Mike Kasprzak edited this page Nov 15, 2017 · 1 revision

The Linux Subsystem for Windows (LSW) is a new Windows 10 feature from Microsoft (more). It replaces clumsier compatibility layer solutions from decades past like Cygwin and MSys with a full Linux compatible kernel running on Windows. As a result, the same Linux binaries and Linux distros you run on your servers or VMs now run natively on Windows via LSW.

Setup is a bit involved. You can find detailed instructions here:

https://msdn.microsoft.com/en-us/commandline/wsl/install-win10

In short, you need:

  • To upgrade Windows 10 to the absolute latest version (and perhaps an hour to do it)
  • To open PowerShell as an Administrator, and execute the following command
    • Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  • To Reboot
  • To open the Windows Store (the one built in to Windows 10), and install Ubuntu

Once finished, you'll have to start up and wait a bit longer for Ubuntu to finish setting itself up. Once it's ready, using it is no different than any other Ubuntu server.

Double Vagrant

To use Dairybox on LSW, you actually need to install Vagrant both inside your LSW Ubuntu installation, and on Windows itself. You need to keep your versions of Vagrant in sync. Say, if you ever upgrade one, you need to upgrade the other.

Downloads are here: https://www.vagrantup.com/downloads.html

Grab the 64bit Windows version for your native install, and right-click copy the 64bit Debian link, and wget it.

# Download
wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb

# Install
sudo apt install vagrant_2.0.1_x86_64.deb

# Or alternatively:
# sudo dpkg -i vagrant_2.0.1_x86_64.deb

You may need to run both versions, or and upgrade their plugins before they'll play nice with each-other.

# if you have problems (i.e. via a prior git-bash install), you might need to expunge and reinstall your plugins
vagrant plugin expunge --reinstall

The final step, you need to enable a flag so Vagrant can access Windows.

# To temporarily enable WSL in Vagrant
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"

# Add permanently enable it any time you start the shell
echo 'export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"' >>~/.bashrc

With that, your Vagrant install is ready to go.

More details: https://www.vagrantup.com/docs/other/wsl.html

Install the dev tools locally

See the Ubuntu instructions here: wiki/External-VM-Builds

Installing Dairybox

With the tools installed and ready to go, you're almost ready to start installing.

There's just one last thing: Where to install it?

For stability, Microsoft strongly discourages you from changing files found inside the Linux filesystem from Windows (see this). Instead, they recommend you change Windows files from Linux.

Create a place to work. I would recommend making a Work folder on your C drive, but you can do whatever you want here.

# Make a directory on the C drive for work (alternatively,
# browse to your C drive, right-click and create a folder)
mkdir /mnt/c/Work

# Create a symlink to it from your home folder, for easy access
ln -s /mnt/c/Work Work

# You can now use ~/Work as a shortcut to the Work folder
cd ~/Work

Now go to that folder and begin the regular installation procedure.

(Link to that here)

You will likely want to create an SSL certificate, for easy commits to your private repo.

(Link to that here)