How do I use Windows 10 WSL with Fedora?
Solution 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
- 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 and that you will be using Fedora 24
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
- su -
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.