Installing WSL - KineticTheory/Linux-HPC-Env GitHub Wiki
- WSL2 should be provided with Windows 11. No need to install it.
- Update with
wsl --update
- Install a new distro:
wsl -o --all
, thenwsl install [Distro]
Update instance with apt-get
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt-get install -y net-tools git pkg-config
sudo apt-get install -y build-essential gcc gfortran unzip libtool mesa-common-dev
sudo apt-get install -y keychain autoconf autopoint finger
# newer versions of spack may require these tools to bootstrap itself
sudo apt-get install -y libssl-dev cmake bison libpython3-dev libcurl4-openssl-dev gettext libgettextpo-dev
# needed for cairo (x11)
sudo apt-get install -y libx11-dev libxcb-randr0-dev libxcb-xtest0-dev libxcb-xinerama0-dev libxcb-shape0-dev
sudo apt-get install -y libxcb-xkb-dev libcairo2-dev librsvg2-dev librsvg2-bin
sudo apt-get install -y libjbig-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev liblzma-dev libtiff-dev libtiffxx5 gnutls-dev gnutls-bin
# Convenience tools that KT uses.
sudo apt-get install -y gitk emacs-nox golang-go meld
# Latex and autodoc support
sudo apt install -y graphviz libgd-dev texlive-latex-extra texlive-extra-utils
# spack support
sudo apt-get install -y bzip2 ca-certificates g++ gcc gfortran git gzip lsb-release patch python3 tar unzip xz-utils zstd
- Fix broken install of meld:
sudo apt-get install --reinstall meld gnome-icon-theme
General help pages
- https://learn.microsoft.com/en-us/windows/wsl/troubleshooting
- https://learn.microsoft.com/en-us/windows/wsl/wsl-config
No network access from WSL session
There are many things that can cause this problem. The most robust work-around right now is using the wsl-vpnkit.
-
Fix proxy issue for Git
git config --global url."https://".insteadOf git://
- setup ssh-keys
- First time setup
git clone [email protected]:spack/spack/ && cd spack
source share/spack/setup-env.sh
spack compiler add
# Tell spack about packages that are already installed. Creates ~/.spack/packages.yaml
spack external find
- Build normal dev tools
spack install lmod cmake numdiff ack htop gsl random123 openblas eospac lcov mscgen doxygen
spack install openmpi
spack install parmetis caliper libquo
- Error:
Logon failure: the user has not been granted the requested logon type at this computer
- Fixed by:
gpupdate /force
- While the above has always fixed the problem for me, another user reports that this command can help:
Restart-Services vmcompute
- Fixed by:
- Configure WSL2 properties by creating
%USERPROFILE%/.wslconfig
:- Advanced properties. Maybe try settings for networking and dns?
- Example:
[wsl2]
Memory = 4GB
Processors = 2
- Firewall blocking dns/networking
- SEP might be blocking the NAT communication. https://knowledge.broadcom.com/external/article/221329/endpoint-protection-firewall-blocks-netw.html. Diagnose SEP issues by stopping SEP:
C:\Program Files\Symantec\Symantec Endpoint Protection\14.3.9681.7000.105\Bin64\Smc.exe -stop
. - WSL2 features (2024) that should help https://learn.microsoft.com/en-us/windows/wsl/networking
- I have had success in fixing NAT/firewall issues by using the wsl-vpnkit.
- SEP might be blocking the NAT communication. https://knowledge.broadcom.com/external/article/221329/endpoint-protection-firewall-blocks-netw.html. Diagnose SEP issues by stopping SEP:
- Free up memory in windows when WSL uses too much:
wsl --shutdown
- Install CascadiaCodePL.ttf to Linux
- Copy
CascadiaCodePL.ttf
to$HOME/.fonts
and then runfc-cache -f -v
- Use Gnome-Terminal settings to select the new font.
- Copy
- Powerline prompt
- Install go:
sudo apt install golang-go
- Install powerline-go:
go install github.com/justjanne/powerline-go@latest
(might need to set proxy first). - Add this to
.bashrc
- Install go:
GOPATH=$HOME/go
function _update_ps1() {
PS1="$($GOPATH/bin/powerline-go -error $?)"
}
if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
- Ref: details and github site
- For this to work correctly, you will need to setup Pageant from putty-cac so that your ssh-keys and your PIV certificates are held and served up by pageant.
- You will need a helper tool to can import ssh information from Pageant to WSL2's ssh-agent.
- In your WSL2 session:
mkdir $HOME/bin && cd $_ && wget https://github.com/BlackReloaded/wsl2-ssh-pageant/releases/download/v1.3.0/wsl2-ssh-pageant.exe && chmod +x *.exe
sudo apt-get install socat iproute2
- Instead of running ssh-agent or keychain, add the following script-let to
.bash_profile
to import your credentials:
export SSH_AUTH_SOCK="$HOME/.ssh/agent.sock"
if ! [[ $(ss -a | grep -q "$SSH_AUTH_SOCK") ]]; then
rm -f "$SSH_AUTH_SOCK"
if [[ -x "$HOME/bin/wsl2-ssh-pageant.exe" ]]; then
(setsid nohup socat UNIX-LISTEN:"$SSH_AUTH_SOCK,fork" \
EXEC:"$HOME/bin/wsl2-ssh-pageant.exe" >/dev/null 2>&1 &)
else
echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable or not found."
fi
fi
- Find the name of the WSL image:
$ wsl --list`
`Ubuntu-24.04`
- Export the image to a backup location:
$ mkdir f:\WSL2-backups
$ wsl --export Ubuntu-24.04 F:\WSL2-backups\Ubuntu-24.04.tar
- Unregister the same distribution to remove it from the C: drive:
wsl --unregister Ubuntu-24.04
- Import the distribution from the backup location:
$ mkdir F:\WSL2-images
$ wsl --import Ubuntu-24.04 F:\WSL2-images\Ubuntu-24.04\ F:\WSL2-backups\Ubuntu-24.04.tar
- By default Ubuntu will use root as the default user, to switch back to previous user go to the Ubuntu App Folder run command to set default user
$ cd %userprofile%\AppData\Local\Microsoft\WindowsApps
$ ubuntu2404.exe config --default-user <username>
Previous: Custom Software Settings