Triton CLI on Windows Subsystem for Linux (WSL)

Open source developers tend to work on macOS because, for much of the coding that they do, all of the tools they need are available and run more smoothly on macOS than in Windows. Also known as "Bash on Windows", 'Bash on Ubuntu on Windows", "Linux on Windows", Windows Subsystem for Linux (WSL) availability gives developers access to familiar tools but with Windows drives and file interoperability. Triton CLI on WSL is worth exploring as a way to seamlessly access both Linux capabilities and Windows integration on a single desktop.

When we initially discovered WSL, it was in beta testing. WSL graduated to a Windows feature with the Windows 10 Fall Creators Update and it is continuously improving. At the time of writing the first draft of this blog, you needed to be in developer mode and Ubuntu was the only Linux distribution available. Now, you don't need to enable developer mode and there are many Linux distrobutions to choose from.

This post explains how to set up Ubuntu on WSL on Windows 10 Professional and then install Triton CLI.

What is WSL?

WSL is a complete Linux system inside Windows. In WSL, Ubuntu Linux runs directly on top of Windows, it is not a virtual machine or a Linux emulator like Cygwin. WSL runs the same binaries as Ubuntu Linux, but Linux isn't the underlying OS kernel. Instead, WSL has the utilities and software typically available in a Bash shell, performing real-time translation of Linux syscalls into Windows OS syscalls.

Before you begin

Before you begin, ensure that you have a Triton Compute Service environment.

WSL also requires that you are running the 64-bit version of the Windows operating system. You can do this by checking the computer's system information. As a best practice, ensure that you are running the latest version of Windows 10 with the most recent updates. Because WSL is still evolving, you may need to adjust the steps below in accordance with your current configuration.

Step 1: Enabling WSL

To manually enable WSL:

  1. To enable WSL, open an administrative PowerShell window and install the Windows Subsystem.
    <code>Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux</code>
  2. Reboot your machine.

You can also enable WSL via the Control Panel: Programs > Programs and Features > Turn Windows features on or off > Windows Subsystem for Linux. Select the check box and restart your machine.

Now that you have set up the necessary components, you can install the Linux distribution of your choice. If you choose a distribution other than Ubuntu, you’ll need to customize the instructions in this blog.

Step 2: Installing Ubuntu

On Windows, Ubuntu runs only from the C drive, so make sure Ubuntu is installed and stored on the C drive. If you are an intrepid installer and have already deployed the application to a different location, to change the location: Go to Settings > Storage > More Storage Settings: Change where new content is saved and select C Drive here.

To install Ubuntu:

  1. Download and install Ubuntu from the Windows store.You may need to reboot your machine.
  2. From the Start Menu, right-click Ubuntu and click Run as Administrator.

Right after the install completes, you are asked to set a unix username and password as part of the Ubuntu account setup. This request appears only during setup. The username doesn’t have to match your Windows account, and you won’t be allowed to use "admin" as the username. This account is an admin account with sudo privileges.

Step 3: Installing Node.js

The apt tool functions to install software packages in Ubuntu. WSL has the minimal tools you'll need to get started, but we'll need to install a few more items in order to work with Triton. In this step, we update, upgrade, and add essential native Linux compilers to replace the Windows Linux binaries. This ensures a more stable environment for Node.js tools.

Note that most developers familiar with Linux may be more familiar with apt-get. In WSL, apt works without the additional configuration tweaks currently required to run apt-get in a Windows-based environment.

In WSL Ubuntu, apt update downloads and synchronizes the package index files from their sources. This updates the list of available packages. An update must always be performed before upgrading software to ensure you get the latest version. Execute the following:

<code class="language-bash">$ sudo apt update</code>

Upgrading software to the latest is a best practice for a first time install. In general, it may be better to upgrade or patch after the initial installation, depending on your current configuration. In this case, we will install upgrades to ensure to include the build dependencies needed for software such as curl and npm. To upgrade your software, run:

<code class="language-bash">$ sudo apt upgrade</code>

The build-essential package that installs a number of packages commonly used for software development and needed to install Node.js and Triton CLI tools.

To install Linux compilers, run:

<code class="language-bash">$ sudo apt install build-essential</code>

In WSL, the Node Version Manager (NVM) of tool gives you the ability to install and use multiple versions of Node.js. We install NVM to ensure Node detects and runs the Linux binaries added in build-essential. The code example also includes checksum to ensure that the file you are downloading is in fact the version of the file that you expect.

<code class="language-sh">$ curl -L -s -o /tmp/install.sh "https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh" && \echo 'f3c026098b6e2190373e5d8fdaaf27ee99a97b1d976a712d9550b85699c023fe  /tmp/install.sh' | sha256sum -c && \bash /tmp/install.sh</code>

A note about checksum: You can run the curl command without a check, but the best practice is to ensure that the file transfer completes without corruption. You also want to be sure that you've gotten the right file. There have been many attacks where malware is inserted on a server and added to open source tools. A checksum works to prevent this.

After the install completes, exit the terminal, and start a new Ubuntu session. Remember to start Ubuntu as Admin.

Now, install the latest stable version of Node:

<code class="language-sh">$ nvm install stable</code>

When using NVM, you'll need to explicitly specify the Node version you want to use. Running the install command automatically starts Node.js running. But, each time you run Ubuntu, you'll need to specify the version using the command nvm use stable. To simplify the set up, you’ll probably want to add this command to .bashrc.

Step 4: Installing Triton CLI

And that is it! Now, you are ready to install triton. You can head on over to Joyent's getting started documentation and follow the instructions for installing triton, generating SSH Keys, creating profiles, spinning up instances, and more.

Exploring next steps

You can explore more triton methods and resources from Joyent's API reference documentation. You can create containers and virtual machines such as Docker containers, infrastructure containers, or hardware virtual machines. You can add images, create custom images, and so much more.

Additional WSL Resources

For more information on WSL, read:

We want to hear about how you run triton on WSL or if you use triton in another way on your Windows machine. Tweet us @Joyent.



Post written by Carol Cobine