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.
- Download the docker core tarball from https://hub.docker.com/_/fedora
- Unzip the tarball — need the *.tar (use 7zip)
- Create a new WSL via import
- wsl.exe –import <name> <install_location> <filename>
- wsl.exe –import Fedora “d:\WSL\distro\Fedora” fedora.tar
- Get the list of distros to make sure it installed correctly
- wsl –list
- Go into the newly created distro
- wsl –distribution Fedora
- It will be a base image logged into as root
- Update /etc/dnf/dnf.conf to defaultyes=true (if you want)
- Perform the system upgrade
- dnf up
- If you get an rpm database error: rm /var/lib/rpm/.rpm.lock
- Install the preferred programs
- dnf in passwd file which emacs-nox git zsh cracklib-dicts bind-utils iputils
- Add the base user
- adduser -m -d /home/username -u 1000 -U -G wheel -s /bin/zsh username
- Change the user’s password
- passwd username
- 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": []
}
- 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)'