Quickstart
Get your favorite Linux distro running in WSL in minutes:
- Export a container image as a rootfs tarball.
- Import it into WSL and remove leftovers.
- Set your new distro as the default.
# Export Fedora image
sudo docker run -t --name export-fedora fedora ls /
sudo docker export export-fedora > /mnt/c/fedora-rootfs.tar
# Import and clean up
wsl --import Fedora C:\Fedora C:\fedora-rootfs.tar
Remove-Item C:\fedora-rootfs.tar # in PowerShell
wsl --unregister Ubuntu
wsl --set-default FedoraYou can skip steps 1 and 2 by asking one of your friends who already has Docker or Podman running to export the distro for you.
Prerequisites
- WSL2 enabled on Windows (run
wsl --install). - Docker Engine installed in your WSL distro (needed only for export).
There are a ton of guides on the internet but here's one to avoid jumping to another article if you haven't installed it yet.
Windows + S> typeTurn Windows features- Open
Turn Windows features on or off - Enable
Virtual Machine PlatformandWindows Subsystem for Linux>OK> Restart Windows + X>TerminalorPowerShellwsl --updatewsl --installand follow the instructions
Follow this guide to install Docker Engine on Ubuntu. No need for the post-installation steps since we only need them to extract the Fedora image from the Docker image.
Exporting the distro
Pull and export any image (here Fedora):
sudo docker run -t --name export-fedora fedora ls /Save the container fs to a tarball:
sudo docker export export-fedora > /mnt/c/fedora-rootfs.tarImporting into WSL
Run in PowerShell:
wsl --import Fedora C:\Fedora C:\fedora-rootfs.tar
Remove-Item C:\fedora-rootfs.tar
wsl --unregister UbuntuAfterwards you can remove the .tar file and the old distro
Remove-Item C:\fedora-rootfs.tar
wsl --unregister UbuntuNow you should see Fedora in your WSL distros list.
At this point, you should see the Fedora distro in the WSL distro list.

Post-installation tweaks
Set default distro for WSL
powershellwsl --set-default FedoraPath fixes
Upon starting using thewslcommand, you might see a bunch ofERROR: UtilTranslatePathListmessages. This happens because Fedora wasn't shut down "the-wsl-way" in the second step. Just terminate it from Windows and relaunch it.powershellwsl --terminate Fedora wslIn the future you should avoid shutting down WSL from the inside, use
wsl --shutdowninstead.Update & install additional packages
Update and add essentials:
dnf update && \
dnf install wget curl sudo git passwd ncurses dnf-utils nano> You may remove those you know and don't need.
Add user & set password
bashuseradd -G wheel yourusername passwd yourusernameSet default user in
wsl.conf& enablesystemdModify thewsl.conffile using a text editorbashsudo nano /etc/wsl.confPaste the following contents
bash[boot] systemd = true [user] default = yourusernameOmit the
systemdpart if your distro doesn't use systemd.then restart WSL
powershellwsl --shutdown wsl
Enabling GUI (WSLg)
We are creating two systemd services to automatically generate two symlink files on startup for the X11 socket.
/tmp/.X11-unix->/mnt/wslg/.X11-unixFirst create the service filebashsudo nano /usr/lib/systemd/system/wslg-tmp-x11.servicePaste the following contents
[Unit] Description=Recreate WSLg X display file link after /tmp mounted ConditionPathIsDirectory=/mnt/wslg/.X11-unix Requires=tmp.mount After=tmp.mount Before=systemd-tmpfiles-setup.service [Service] Type=oneshot ExecStart=/bin/chmod +t /mnt/wslg/.X11-unix ExecStart=-/bin/rmdir /tmp/.X11-unix ExecStart=/bin/ln -sf /mnt/wslg/.X11-unix /tmp/.X11-unix ExecStart=/bin/mount -m -o bind /mnt/wslg/.X11-unix /tmp/.X11-unix [Install] WantedBy=default.target$XDG_RUNTIME_DIR->/mnt/wslg/runtime-dirCreate the service filebashsudo nano /usr/lib/systemd/user/wslg-runtime-dir.servicePaste the following contents
[Unit] Description=Recreate WSLg sockets files in $XDG_RUNTIME_DIR ConditionPathIsDirectory=/mnt/wslg/runtime-dir [Service] Type=oneshot ExecStart=/bin/sh -c "ln -fs /mnt/wslg/runtime-dir/* "%t [Install] WantedBy=default.target
Finally, enable the services
sudo systemctl enable wslg-tmp-x11
sudo systemctl --global enable wslg-runtime-dirEverything else, X11 or Wayland-related, should be included in the dependency list of the GUI application you're installing.
Advanced: backup & restore
Taskbar Shortcut
If you're using Windows Terminal (btw you should), you can create a shortcut to open the WSL distro in Windows Terminal and pin it to the taskbar.
- Right-click on desktop >
New>Shortcut - Paste the following path
%userprofile%\AppData\Local\Microsoft\WindowsApps\wt.exe -p Fedora Next> enterFedora>Finish- Hold
Altand double click on the shortcut to open itsPropertiespanel - Select
Change Icon...and use this fedora.ico - Drag the shortcut onto the taskbar

Best practices for backup & restore
Find and remove unnecessary files and directories with
ncdu(v2.5 and above)sudo /path/to/ncdu -t8 --exclude /mnt /Shrink the WSL2
.vhdxdiskIdentify the
ext4.vhdxfile from the location you specified during the import process OR inregeditatComputer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\
the
ext4.vhdxshould be in theBasePathfolder.Launch
diskpartusing Terminal, PowerShell or Command Promptcmddiskpartand execute the following commands line by line
cmdselect vdisk file="path\to\ext4.vhdx" attach vdisk readonly compact vdisk detach vdisk exitTo backup, copy the whole
ext4.vhdxfile to another location or usePowerShellwsl --export --vhd <Distribution Name> <FileName>To restore, use
PowerShellwsl --import --vhd <Distribution Name> <InstallLocation> <FileName>
References
- Import any Linux distribution to use with WSL | Microsoft
- Using Fedora 33 with Microsoft’s WSL2 | Fedora Magazine
- How to set default user for manually installed WSL distro? | superuser
- Multiple UtilTranslatePathList errors when restarting Ubuntu on WSL after a shutdown | AskUbuntu
- Advanced settings configuration in WSL | Microsoft
- Basic commands for WSL | Microsoft
- libGLESv2.so.2: cannot open shared object file: No such file or directory | Qt Forum
- Diagnosing "cannot open display" type issues with WSLg | GitHub - wslg
- viruscamp/wslg-links | Recreate WSLg sockets after
/tmpand$XDG_RUNTIME_DIRmounted