Hell has frozen over and pigs are flying out of the gaping, lava-filled chasms from beneath the Earth’s crust.
That’s right, Microsoft has its own Linux distribution.
Before you lose your mind, the Redmond juggernaut isn’t replacing Windows with a superior desktop (although never say never and Goonies never die). Instead, what Microsoft has purpose-built a lightweight Linux distribution for Microsoft’s internal cloud infrastructure and edge products and services. With this version of Linux, Microsoft will be able to enhance its ability to stay current in the Linux-centric cloud native landscape.
Given how enterprise businesses absolutely depend on Linux, this was a smart move on the part of Microsoft. I’d go so far as to say this should have happened years ago. But, lo and behold, the time has come and anyone can now deploy Microsoft’s CBL-Mariner Linux. For those who are curious, CBL stands for Common Base Linux, and the source code is licensed under a mixture of open-source licenses, including the GNU General Public License and the MIT license. You can download the source from the CBL-Mariner GitHub page, but what you won’t find is a handy ISO image to use for installing CLB-Mariner.
Yep, Microsoft hasn’t made it easy for those who want to try out this new cloud native, container-tastic, edge-worthy Linux distribution. In fact, getting CBL-Mariner up and running is kind of a convoluted mess at the moment.
That doesn’t mean it’s impossible. It’s just a matter of running a bunch of commands. And that’s exactly what I’m going to show you. But know this: In the end, you’ll wind up with a vhd file you can then use to spin up a virtual machine (VM). So not only do you have to go through the steps of creating the virtual appliance file, you then have to create the VM. But you’re a cloud native developer, so you’re used to jumping through hoops. To do this, you’ll need a Linux distribution from which to work. I’ll demonstrate on Ubuntu Desktop 21.04.
Let’s make this happen.
Installing the Necessary Dependencies
The first thing to be done is several dependencies must be installed, so log into your Linux machine and open a terminal window. Before you can do anything, you must add the backports repository, which is done with the command:
sudo add-apt-repository ppa:longsleep/golang-backports
Press Enter when prompted.
Next, we need to update apt with the command:
sudo apt-get update
Once the apt update has completed, install all of the necessary dependencies with the command:
sudo apt-get install make tar wget curl rpm qemu-utils golang-1.15-go genisoimage python2-minimal bison gawk -y
Note: If you’re installing on an older version of Ubuntu (such as 18.04), the above command would be:
sudo apt-get install make tar wget curl rpm qemu-utils golang-1.15-go genisoimage python-minimal bison gawk -y
To get faster compression, you can optionally install pigz with the command:
sudo apt-get install pigz -y
You’ll need to create a link for go, with:
sudo ln -vsf /usr/lib/go-1.15/bin/go /usr/bin/go
The final dependency is Docker. Instead of installing the version available from the standard repository, we’ll go with the latest version with the commands:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
You’ll also need to add your user to the docker group (otherwise you’d have to run the docker command with sudo, which can be a security problem). Add your user with the command:
sudo usermod -aG docker $USER
Log out and log back in, so the changes take effect.
Clone and Build the Necessary Toolkit
Clone the CBL-Mariner toolkit source with the command:
git clone https://github.com/microsoft/CBL-Mariner.git
Save the current directory into a stack and change into the newly created CBL-Mariner directory with the command:
Checkout the stable version with:
git checkout 1.0-stable
Build the toolkit with:
sudo make package-toolkit REBUILD_TOOLS=y
Change back into the stored directory with the command:
Clone CBL-Mariner and Extract the Toolkit
Clone the actual CBL-Mariner source with the help of git:
git clone https://github.com/microsoft/CBL-MarinerDemo.git
Save the current directory and change into the new directory with:
Copy the source:
cp ../CBL-Mariner/out/toolkit-*.tar.gz ./
Unpack the toolkit:
tar -xzvf toolkit-*.tar.gz
Building the VHD
The next step will take some time. What we’re going to do now is build the vhd file that will be used for the virtual machine. First, change into the correct directory with the command:
Now you can build the vhd file with the command:
sudo make image CONFIG_FILE=../imageconfigs/demo_vhd.json
Either sit back and watch the output fly by or go do something else until the build completes. This can take anywhere from 10 to 30 minutes, depending on your hardware.
Once the build is complete, you’ll find the vhd file in ~/CBL-MarinerDemo/out/images/demo_vhd/. You can fire up your virtual machine tool of choice and create the virtual guest with that file. After you’ve booted CBL-Mariner, you’ll log in with the username root and the password p@ssw0rd.
And that’s it. You’re now ready to kick the tires of Microsoft’s very own version of Linux. Although you might not want to make this your default cloud-native development platform, you can at least get an idea where Microsoft is headed. I will say that CBL-Linux is already very stable and will soon be a worthy candidate for containers, IoT, edge, and cloud development. Is it there yet? Probably not. But given how new this platform is, what Microsoft has already pulled off is pretty impressive.
The New Stack is a wholly owned subsidiary of Insight Partners. TNS owner Insight Partners is an investor in the following companies: MADE, Docker.