Running Fedora on Windows 10 using WSL

Getting a Fedora root filesystem

Option 1: Trust me and download the rootfs tarball

Includes dnf hacks and exclude rules for hacked packages in dnf.conf (hopefully not needed for too long)
https://drive.google.com/file/d/0B2x_P2FaPipUUjRuSkF4c01WOG8/view

Option 2: Build the rootfs tar yourself from Koji

Download the docker image for Fedora 23
http://koji.fedoraproject.org/koji/tasks?owner=ausil&state=closed&view=flat&method=createImage&order=-id

In this example the latest version was 20160408.

Become root, to maintain permissions on the untarred files, and do the following

tar xfp Fedora-Docker-Base-23-20160408.x86_64.tar.gz
cd dad7397f64776b5ac85b0bdbf5d511bc0a434b363309570bb2cf3082f382aaec
mkdir rootfs
cd rootfs
tar xfp ../layer.tar
tar chf rootfs.tar etc/ usr/ var/ bin lib lib64 sbin

Installing bash (Ubuntu) in Windows 10

  • Start -> Search for “developer settings” -> Select “Developer Mode”
  • Start -> Search for “windows features” -> Check “Windows Subsystem for Linux (Beta)”
  • Reboot
  • Open a command prompt (Start -> Search for “cmd”)
  • Run “bash”
  • Select “y” to install bash

Bootstrapping Fedora

  • Copy the rootfs.tar(.gz) to the Windows desktop for your user (method unspecified)
  • Within the bash shell (at /mnt/c/User/Your User)

    cd Desktop
    cp rootfs.tar* ~
    cd
    tar xfp rootfs.tar*
    exit

Now the select directories of the fedora root filesystem are in the root’s home directory

The next step is to overwrite the select directories in the rootfs.

  • Open a file manager in Windows (Start -> “file”)
  • Go to C:\Users\Your User\AppData\Local\lxss\rootfs
  • Delete etc usr var bin lib lib64 sbin
  • Go to C:\Users\Your User\AppData\Local\lxss\root
  • Cut etc usr var bin lib lib64 sbin
  • Go back to C:\Users\Your User\AppData\Local\lxss\rootfs
  • Paste

Now we have effectively bootstrapped a Fedora userspace

Open a command prompt, type bash and now you are in a Fedora enviroment (run dnf if you don’t believe me)

Patching (if you chose option 2)

The lxscore.sys syscall translation driver supports many linux syscalls, but not all.  There are also some programs that access things in /sys, /proc/,  and /dev that aren’t available in this enviroment.  We have to hack some things in python3 and dnf to work around this.

dnf metadata fetch fails with Error 22: Invalid argument

edit /usr/lib64/python3.4/shutil.py around line 134 (search for “listxattr”)
replace if hasattr(os, 'listxattr'): with if False:

Transaction check failed, not enough disk space

edit /usr/lib/python3.4/site-packages/dnf/rpm/transaction.py around line 108 (search for “DISKSPACE”)
remove if conf.get('diskspacecheck') == 0: and reduce indent for self.ts.setProbFilter(rpm.RPMPROB_FILTER_DISKSPACE)

Prevent hacks from being removed on dnf update

edit /etc/dnf/dnf.conf
add exclude=python3-libs python3-dnf to [main] section

16 thoughts on “Running Fedora on Windows 10 using WSL”

    1. No, the change to python3-libs (the listxattr) isn’t upstream appropriate. The dnf bug where diskspacecheck has no effect can be upstreamed. I have a bug open here and a PR open here

  1. Thanks! This is very cool. I tried the exact same method with the Arch Linux base image, and was able to log into bash properly. However, I can’t install anything with pacman as it “could not determine filesystem mount points”.

  2. I kept getting an error:

    Error: 0x8007054f

    when trying to start bash after copying in the files. It turns out for me there was a prompt about some “existing files” already in rootfs when I was doing the paste operation. If I choose to copy over those files then I get the Error from above. If I choose to leave those files in tact (i.e. leave the ones from the ubuntu install) then I sucessfully get a fedora bash prompt.

    1. You will get the error if you use copy&paste because the case problem and the links(perhaps). Use cut&paste to avoid it.

  3. I had some challenges getting Fedora to work but I think I have found a way that works well. My problem was with the copying under Windows, it would not copy symlinks correctly. So I hope this will be helpfull to you

    * cmd
    # Let’s start with a fresh Ubuntu installation (You can always come back here if something goes wrong)
    * lxrun /uninstall /full /y
    * lxrun /install /y
    # Select a username you want to use and replace USERNAME below with that name
    * lxrun /setdefaultuser USERNAME
    > Enter user password

    * open a browser to http://koji.fedoraproject.org/koji/tasks?owner=&state=closed&view=flat&method=createImage&order=-id
    * Select the docker image you want to use
    * download the file Fedora-Docker-Base-??? from the Output section
    (for ease sake, I will assume the file is downloaded to c:\temp)
    (I will also assume, you will be using Fedora 24)

    * bash
    * sudo -i
    * passwd root
    > Enter root password twice
    * usermod -G wheel USERNAME # Replace USERNAME with the name you used in the lxrun command above
    * mkdir /f24
    * cd /f24
    * tar Jxvf /mnt/c/temp/Fedora-Docker-Base???
    (a directory with a hash name will be created, I will call it $DIR)
    * tar xvf $DIR/layer.tar
    * for f in bin etc lib lib64 sbin usr var; do mv $f ../$f.f24; done
    * cd /
    * cp /etc/{passwd,group,shadow,sudoers} /etc.f24
    * edit /etc.f24/sudoers
    * Disable the line that starts with %sudo
    * Add the following line:
    %wheel ALL=(ALL:ALL) NOPASSWD: ALL
    # The NOPASSWD is absolutely needed or sudo will not work
    * exit
    * exit

    * Open your favorite Windows file explorer
    * Add suffix .ubuntu to the directories bin etc lib lib64 sbin usr var
    * Rename the files and directories that end in .f24 to remove the suffix .f24

    * bash
    * su –
    > Enter root password you set above
    * dnf install -y sudo
    * exit
    * exit

    Et voila Fedora 24 on your Windows 10 system

    Many tools are not installed so you have to install them manually (openssh, tar, find, and many more)

    If you want to run graphical stuff you will need an X server, Cygwin/X or VcXsrv (very small) are good tools to use

  4. To the moderator: Some stuff fell away in my comment. If you want the full text, please send me an email and I will send it to you.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.