Fedora in WSL

Microsoft’s Windows System for Linux is coming along nicely and they are adding features that makes it easy to sideload your favorite distro. The best distro images to sideload are docker or server images due to the size — you really don’t want to do a full desktop sideload since most of the features won’t be very useful in WSL. I’ve written the following cheat sheet for installing Fedora in WSL but it can be adapted to many distros.

  1. Download the docker core tarball from https://hub.docker.com/_/fedora 
  2. Unzip the tarball — need the *.tar (use 7zip)
  3. Create a new WSL via import 
    1. wsl.exe –import <name> <install_location> <filename> 
    2. wsl.exe –import Fedora “d:\WSL\distro\Fedora” fedora.tar 
  4. Get the list of distros to make sure it installed correctly 
    1. wsl –list 
  5. Go into the newly created distro 
    1. wsl –distribution Fedora 
    2. It will be a base image logged into as root 
  6. Update /etc/dnf/dnf.conf to defaultyes=true (if you want)
  7. Perform the system upgrade 
    1. dnf up 
  8. If you get an rpm database error: rm /var/lib/rpm/.rpm.lock 
  9. Install the preferred programs 
    1. dnf  in passwd file which emacs-nox git zsh cracklib-dicts bind-utils iputils
  10. Add the base user 
    1. adduser -m -d /home/username -u 1000 -U -G wheel -s /bin/zsh username
  11. Change the user’s password 
    1. passwd username
  12. Modify the Windows Terminal settings: 
{ 
    "$schema": "https://aka.ms/terminal-profiles-schema", 
    "defaultProfile": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", 
    "profiles": 
    { 
        "defaults": 
        { 
            // Put settings here that you want to apply to all profiles 
            "hidden": false, 
            "cursorColor":"#FFFFFF", 
            "cursorShape":"bar", 
            "fontFace":"Consolas", 
            "fontSize":11, 
            "historySize":9001 
    }, 
        "list": 
        [ 
            { 
                // Make changes here to the cmd.exe profile 
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}", 
                "name": "cmd", 
                "commandline": "cmd.exe" 
            }, 
            { 
                // Make changes here to the powershell.exe profile 
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", 
                "name": "Windows PowerShell", 
                "commandline": "powershell.exe" 
            }, 
            { 
                "guid": "{aa8efdb5-3cbe-50b2-a332-9203dc1ee217}", 
                "name": "Fedora", 
                "source": "Windows.Terminal.Wsl", 
                "commandline":"wsl.exe ~ -d Fedora -u munky", 
                "icon": "D:/WSL/Icons/fedora.png" 
            }, 
            { 
                "guid": "{46ca431a-3a87-5fb3-83cd-11ececc031d2}", 
                "name": "kali-linux", 
                "source": "Windows.Terminal.Wsl", 
                "icon": "D:/WSL/Icons/kali.png" 
            }, 
            { 
                "guid": "{0110db4a-cf7b-5647-9a03-7232d80cd09e}", 
                "name": "openSUSE-Leap-15-1", 
                "source": "Windows.Terminal.Wsl", 
                "icon": "D:/WSL/Icons/sles.png" 
            }, 
            { 
                "guid": "{2c4de342-38b7-51cf-b940-2309a097f518}", 
                "name": "Ubuntu", 
                "source": "Windows.Terminal.Wsl", 
                "icon": "D:/WSL/Icons/ubuntu.png" 
            }, 
            { 
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}", 
                "name": "Azure Cloud Shell", 
                "source": "Windows.Terminal.Azure" 
            } 
        ] 
    }, 

    // Add custom color schemes to this array 
    "schemes": [], 

    // Add any keybinding overrides to this array. 
    // To unbind a default keybinding, set the command to "unbound" 
    "keybindings": [] 
} 
  1. Set up basic  .zshrc 
autoload -U compinit 
compinit 
 
#allow tab completion in the middle of a word 
setopt COMPLETE_IN_WORD 
 
## keep background processes at full speed 
#setopt NOBGNICE 

## restart running processes on exit 
#setopt HUP 
 
## history 
setopt APPEND_HISTORY 

## for sharing history between zsh processes 
setopt INC_APPEND_HISTORY 
setopt SHARE_HISTORY 

## never ever beep ever 
setopt NO_BEEP 

## automatically decide when to page a list of completions 
#LISTMAX=0 
 
## disable mail checking 
MAILCHECK=0 
 
# autoload -U colors 
#colors 

# -------------------------------------------------------------- 
# set the prompt 
# -------------------------------------------------------------- 

PROMPT=' 
%F{033}%n@fedora %F{240}%~ 
%F{15}[%!] %D{%I:%M%P} >> ' 

# -------------------------------------------------------------- 
# aliases 
# -------------------------------------------------------------- 

# refresh the shell settings 
alias refresh="source ~/.zshrc" 

# listing aliases 
alias ll='ls -Flash' 
alias la='ls -A' 
alias l='ls -CF' 

# df sorting aliases 
alias dff='df -h | grep -v ^none | ( read header ; echo "$header" ; sort -k 1)' 
alias dfm='df -h | grep -v ^none | ( read header ; echo "$header" ; sort -k 6)' 
alias dfu='df -h | grep -v ^none | ( read header ; echo "$header" ; sort -rk 5)' 
 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s