How do I use Windows 10 WSL with Fedora?

3

1

After posting this message in the wrong community and having my request denied to move it to the Superuser community, I though I just re-post it here myself.

I basically put down this question because I have an answer that does not (yet) have a question but I still want to share it (I don't have a blog space (yet))

So, the question is: How do I use Fedora with Windows 10 WSL (Anniversary update) in stead of Ubuntu?

Johan Godfried

Posted 2016-09-21T08:15:34.467

Reputation: 151

Answers

1

This answer assumes a minimal understanding of Linux (Fedora) and a basic understanding of using the windows Run command dialog (opened via the WIN-R key combination)

My starting point was this article by Seth Jennings: https://www.variantweb.net/blog/running-fedora-on-windows-10-using-wsl/

However, I ran into some challenges that were related to symlinks and started playing around. Which resulted in the description you can find below.

I think it should not be very hard to adapt these steps to use other flavors of Linux but you will have to experiment with those. If you do have a successful installation, please let us know in the comments, including any deviations required.

I start with a clean Ubuntu installation. I anything goes wrong, you can always restart with reinstalling Ubuntu

Installing a fresh instance of Ubuntu

  • Press WIN-R and type cmd
    • 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

Download the Fedora Docker image

Prepare Fedora in the Ubuntu instance

  • Press WIN-R and type 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

      If you choose a different version than Fedora 24, you might want to change f24 below accordingly

    • 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

Replace Ubuntu with Fedora

  • Open your favorite Windows file explorer to %LOCALAPPDATA%\lxss\rootfs
    • 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

      If you ever want to move back to Ubuntu, simply revers these steps (rename the directories and symlinks to add the .f24 suffix and remove the .ubuntu suffix (IN THAT ORDER)) Or you can simply reinstall the Ubuntu instance

Run update and install sudo and openssh clients

  • Press WIN-R and type bash
    • su -

      Enter root password you set above

    • dnf update -y
    • dnf install -y sudo openssh-clients
    • exit
    • exit

Cleanup

  • Either via a Windows file explorer (%LOCALAPPDATA%\lxss\rootfs) or through the bash instance (cd /), remove the directories f24 and *.ubuntu

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

And a final after thought: You could replace %LOCALAPPDATA%\lxss\bash.ico with a nice Fedora logo to replace the Ubuntu logo, just keep the filename the same.

Johan Godfried

Posted 2016-09-21T08:15:34.467

Reputation: 151

Cygwin/X: http://x.cygwin.com/ VcXsrv: https://sourceforge.net/projects/vcxsrv/

– Johan Godfried – 2016-09-23T05:57:30.473

1This will "soon" not be necessary anymore, since MS announced Ubuntu, Suse and Fedora for WSL downloadable from Windows Store at the Build conference 2017. I googled to find which insider build is required to get access to it, and found this guide. Yet to find an official date for the required insider build. Should be posted as another answer once it's known. – Eivind Gussiås Løkseth – 2017-05-25T09:34:02.757

fedora link should be https://kojipkgs.fedoraproject.org/pub/fedora/linux/releases/25/Docker/x86_64/images/

– Nick Dong – 2017-06-02T12:28:04.293

Fedora 27 image can be found here: https://kojipkgs.fedoraproject.org/pub/fedora/linux/releases/27/Docker/x86_64/images/

– Johan Godfried – 2018-04-07T08:09:30.480