Windows Subsystem for Linux: Installing Arbitrary Distributions

As of the latest version of Windows 10 build 16299.19, also known as the “Fall Creator’s Update”, Linux distributions are now available in the Windows Store, and multiple distributions can be installed and run alongside one another. This is great news, but the old way did offer one feature the latest release makes a bit more fragile: the ability to install a custom distribution of one’s own choosing. I’ve seen various ways of doing this with the Fall Creator’s Update published, the most common of which is to install one of the distributions from the App Store and replace its rootfs directory with one of your own. I wanted a more elegant solution. Of particular interest to me are Gentoo and Fedora - note that Fedora will eventually be in the Windows Store officially, but I didn’t want to wait.

The Registry

Linux distributions are now registered in the Windows registry on a per-user basis. This is located at:


You can register your own distribution by creating a .reg file containing the following:

Windows Registry Editor Version 5.00

"KernelCommandLine"="BOOT_IMAGE=/kernel init=/init ro"

Take note of a few things here:

  • The name of the parent key must always be a unique UUID
  • DefaultUid is a hexadecimal representation of the UNIX UID that the subsystem will launch with - make sure you have a user created in your custom Linux environment beforehand.
    • Also note that this user should be able to become root. Add the user to the wheel group and/or preinstall ‘sudo’
  • BasePath is going to be the location of this Linux environment on the host filesystem. This can be placed anywhere as long as it’s specified in this key.
  • Flags set the way it is appears to indicate that a WSL environment has been installed and doesn’t require further bootstrapping. Documentation on this is limited, insights welcome.

Import this .reg file into the registry after customizing it appropriately.

Preparing the Linux filesystem

You’ll need to install one of the Linux distributions from the Windows Store in order to get started. It doesn’t matter which one you choose. Once that’s installed (I won’t cover that setup here, as it’s documented thoroughly elsewhere), become root, and fetch a tarball containing a filesystem for your distribution of choice. In my example we’ll use a Fedora docker image, obtained from Red Hat’s Koji build system. Make a new directory and cd into it. Extract the tarball:

root ~ # mkdir fedora
root ~ # cd fedora
root ~/fedora # tar Jxf /mnt/c/Users/brad/Downloads/Fedora-Docker-Base-27-20171105.n.0.x86_64.tar.xz

This Fedora tarball contains another tarball within it. A directory with a long sequence of letters and numbers will be created. Tab completion is your friend here. Under this directory the second tarball, layer.tar, contains the actual Linux filesystem. Note this situation is unique to Fedora’s Koji tarballs - others such as Gentoo stage3 directly extract to filesystem contents. Extract the inner tarball:

root ~/fedora # cd 5a666bb24354de5795820e875e208518e8ea0a249e57929639cd2c1797e447e9
root ~/fedora/5a666bb24354de5795820e875e208518e8ea0a249e57929639cd2c1797e447e9 # tar xf layer.tar

Since this Fedora image is intended to be used in a docker container, it lacks a few things we’ll need. We’ll want to copy the resolv.conf file from the parent Linux environment into it:

root ~/fedora/5a666bb24354de5795820e875e208518e8ea0a249e57929639cd2c1797e447e9 # cp -v /etc/resolv.conf etc/

Then we’ll want to chroot into the new Fedora filesystem to be able to work on it further:

root ~/fedora/5a666bb24354de5795820e875e208518e8ea0a249e57929639cd2c1797e447e9 # chroot .

Install the passwd package:

root ~/fedora/5a666bb24354de5795820e875e208518e8ea0a249e57929639cd2c1797e447e9 # dnf -y install passwd

Set a password for root:

[root@Odyssey /]# passwd
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

Add a user for yourself, and make sure it’s a member of the wheel group. Note here that I’m specifying a UNIX UID matching that expected by the registry entry above, as well as ensuring the user is a member of the wheel group so it’s permitted to become root as well as use sudo:

[root@Odyssey /]# useradd -u 1000 -m brad
[root@Odyssey /]# passwd brad
Changing password for user brad.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@Odyssey /]# usermod -a -G wheel brad
[root@Odyssey /]# exit
root ~/fedora/5a666bb24354de5795820e875e208518e8ea0a249e57929639cd2c1797e447e9 #

Exit the chroot as depicted in the last two lines above. Recall that in the Registry example above I specified C:\Linux\Fedora as the location for this Linux environment. We’ll need to move it there. You’ll need to close all Linux environment Windows or you’ll have trouble with the following steps. Find the location of the Linux environment you installed from the store:

C:\Users\brad>powershell Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss

Hive: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss

[ snip ]
32df2d9} DistributionName : openSUSE-42
 Version : 1
 BasePath :
 PackageFamilyName : 46932SUSE.openSUSELeap42.2_022rs5jcyhyac
 KernelCommandLine : BOOT_IMAGE=/kernel init=/init ro
 DefaultUid : 1000
 Flags : 7
 DefaultEnvironment : {HOSTTYPE=x86_64, LANG=en_US.UTF-8,

Navigate to the directories we’ve been working in - these are under the BasePath corresponding to the distribution you installed, which in my case is:


Using Explorer, cut (DO NOT copy!) the subdirectory you’ve been working in. Paste it into C:\Linux\Fedora (the BasePath of the Linux environment we defined ourselves) as rootfs. The resulting directory structure should be:


Final Steps

We’ve now defined the custom WSL environment in the registry and preconfigured the Linux filesystem we’ll be using. Optionally, you can now set this WSL environment as default:

C:\ >wslconfig /s Fedora

And enter it:

[brad@Odyssey brad]$

You can also enter a WSL environment by specifying its UUID as you set it in the registry:

C:\Users\brad>wsl {6be8e482-66f8-4475-b570-aa8c2fd35809}
[brad@Odyssey brad]$

Have fun with your new Linux subsystem environment!