DEV Community 👩‍💻👨‍💻

Cover image for Custom WSL Distributions

Posted on

Custom WSL Distributions

One thing I've noticed is there isn't many distributions available for WSL (Windows Subsystem for Linux), while for most the small selection of Ubuntu, Kali, SUSE, Debian, Alpine, and Fedora is sufficient, others have chosen to add support for more distributions by the use of installers, the most popular of which is WSLDL which already has a growing selection of distribution support. If neither of these have the distribution you're looking for, then this article is going to explain how to setup your own distribution of choice for WSL.

Step 1. Choosing a Distribution

For this guide we're going to first of course need to choose the distribution we're going to be porting to WSL, unfortunately depending on the route you choose this can get fairly complicated, but fear not as we're going to be going with the easier, and yet still fully working route.

What you're going to want to do is choose a distribution that has a docker container, this is important as in a later step we are going to extract the filesystem from the docker image and use it as our rootfs that is installed into WSL.

Step 2. Preparing for Extraction

After you have chosen your distribution of choice, we're now going to start preparations to extract the filesystem, the first thing we're going to need to do is install Go as the tool we're going to be using to extract it is built using it, assuming you're on Ubuntu on a server or Ubuntu WSL doing this, this can be done with the following

sudo apt install -y golang
Enter fullscreen mode Exit fullscreen mode

After go has finished installing you're going to want to clone this repository and build the executable, this tool will allow us to extract the root filesystem from the docker image into a directory of our choosing.

git clone
cd rootfs_builder && make
Enter fullscreen mode Exit fullscreen mode

After this has finished compiling, you can continue to step 3 and start the extraction process.

Step 3. Extracting the RootFS

To extract the rootfs of the image is now fairly simple, you're going to want to create a config.json file with the following contents:

    "Name": "docker image label here",
    "Spec": {
        "Dest": "/tmp/rootfs",
        "User": "root"
Enter fullscreen mode Exit fullscreen mode

After you have created the configuration file, we can now use the rootfs_builder tool to extract the root filesystem from the image, to do this run the following:

sudo ./rootfs_builder config.json
Enter fullscreen mode Exit fullscreen mode

Once the tool has finished running, you should have the root filesystem of the image inside /tmp/rootfs/rootfs/, the last step we need to do here is compress it using tar, this can be done with the following:

cd /tmp/rootfs/rootfs
sudo tar -zcpf rootfs.tar.gz *
Enter fullscreen mode Exit fullscreen mode

Step 4. Installing the Distribution

For installing the distribution we'll be using WSLDL, start by downloading the latest version of the Launcher.exe executable, rename it to your distribution's name of choice, such as oraclelinux.exe and place your created rootfs.tar.gz file beside it, move them into a directory where you want to install your WSL filesystem, and finish off by running the launcher executable we downloaded and renamed earlier, and.. you're done, the distribution is now installed into WSL and you can configure and setup everything as you need.


The reason I made this post is because I personally really like Oracle Linux, and unfortunately there wasn't any installer or anything to set it up with WSL, so I decided to go my own way and create a installer myself using tools available to me, hope this guide treats you well, and that you have a great holiday for those who celebrate Christmas or any other!

Top comments (3)

rescenic profile image
Muhammad Ridwan Hakim

Could you provide the download link for your Oracle Linux rootfs? Thank you so much for your explanation above.

hanna profile image
Hanna Author
rescenic profile image
Muhammad Ridwan Hakim

Thank you very much ❤️

Update Your DEV Experience Level:


Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. 🛠