WSL: Difference between revisions
Jump to navigation
Jump to search
Line 19: | Line 19: | ||
wsl --list --online | wsl --list --online | ||
Online list as of 2025.07.04: | |||
<pre> | <pre> | ||
C:\> wsl --list --online | C:\> wsl --list --online | ||
The following is a list of valid distributions that can be installed. | The following is a list of valid distributions that can be installed. | ||
Install using 'wsl --install | Install using 'wsl.exe --install <Distro>'. | ||
NAME FRIENDLY NAME | NAME FRIENDLY NAME | ||
AlmaLinux-8 AlmaLinux OS 8 | |||
AlmaLinux-9 AlmaLinux OS 9 | |||
AlmaLinux-Kitten-10 AlmaLinux OS Kitten 10 | |||
AlmaLinux-10 AlmaLinux OS 10 | |||
Debian Debian GNU/Linux | |||
FedoraLinux-42 Fedora Linux 42 | |||
SUSE-Linux-Enterprise-15-SP6 SUSE Linux Enterprise 15 SP6 | |||
SUSE-Linux-Enterprise-15-SP7 SUSE Linux Enterprise 15 SP7 | |||
Ubuntu Ubuntu | Ubuntu Ubuntu | ||
Ubuntu-24.04 Ubuntu 24.04 LTS | |||
archlinux Arch Linux | |||
kali-linux Kali Linux Rolling | kali-linux Kali Linux Rolling | ||
openSUSE-Tumbleweed openSUSE Tumbleweed | |||
openSUSE-Leap-15.6 openSUSE Leap 15.6 | |||
Ubuntu-18.04 Ubuntu 18.04 LTS | Ubuntu-18.04 Ubuntu 18.04 LTS | ||
Ubuntu-20.04 Ubuntu 20.04 LTS | Ubuntu-20.04 Ubuntu 20.04 LTS | ||
Ubuntu-22.04 Ubuntu 22.04 LTS | Ubuntu-22.04 Ubuntu 22.04 LTS | ||
OracleLinux_7_9 Oracle Linux 7.9 | OracleLinux_7_9 Oracle Linux 7.9 | ||
OracleLinux_8_7 Oracle Linux 8.7 | OracleLinux_8_7 Oracle Linux 8.7 | ||
OracleLinux_9_1 Oracle Linux 9.1 | OracleLinux_9_1 Oracle Linux 9.1 | ||
</pre> | </pre> | ||
Revision as of 04:22, 5 July 2025
Windows Subsystem for Linux
NOTE: THERE IS TOO MUCH RAM OVERHEAD FOR WSL, DON'T ENABLE, UNLESS YOU HAVE A TON OF RAM!
Enable
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Disable
Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
List Available Install Options
wsl --list --online
Online list as of 2025.07.04:
C:\> wsl --list --online The following is a list of valid distributions that can be installed. Install using 'wsl.exe --install <Distro>'. NAME FRIENDLY NAME AlmaLinux-8 AlmaLinux OS 8 AlmaLinux-9 AlmaLinux OS 9 AlmaLinux-Kitten-10 AlmaLinux OS Kitten 10 AlmaLinux-10 AlmaLinux OS 10 Debian Debian GNU/Linux FedoraLinux-42 Fedora Linux 42 SUSE-Linux-Enterprise-15-SP6 SUSE Linux Enterprise 15 SP6 SUSE-Linux-Enterprise-15-SP7 SUSE Linux Enterprise 15 SP7 Ubuntu Ubuntu Ubuntu-24.04 Ubuntu 24.04 LTS archlinux Arch Linux kali-linux Kali Linux Rolling openSUSE-Tumbleweed openSUSE Tumbleweed openSUSE-Leap-15.6 openSUSE Leap 15.6 Ubuntu-18.04 Ubuntu 18.04 LTS Ubuntu-20.04 Ubuntu 20.04 LTS Ubuntu-22.04 Ubuntu 22.04 LTS OracleLinux_7_9 Oracle Linux 7.9 OracleLinux_8_7 Oracle Linux 8.7 OracleLinux_9_1 Oracle Linux 9.1
Install Ubuntu
wsl --install -d Ubuntu-24.04
wsl --install -d Ubuntu-22.04
wsl --install -d Ubuntu-20.04
wsl --install -d Debian
wsl --install -d ubuntu
Give the installation a non-default name (useful for having more than one copy of said distribution installed)
wsl --install -d Debian --name MyDebian
ref [1]
Basic Commands for WSL
Basic commands for WSL https://learn.microsoft.com/en-us/windows/wsl/basic-commands
List Running
List running
wsl --list --running # or wsl -l --running
List all
wsl --list --all wsl -l --all
Also open File Explorer, and click on the Linux in the Navigation Pane. [1]
Convert WSL and Windows Paths
$ wslpath Usage: -a force result to absolute path format -u translate from a Windows path to a WSL path (default) -w translate from a WSL path to a Windows path -m translate from a WSL path to a Windows path, with '/' instead of '\' EX: wslpath 'c:\users'
Windows path from WSL:
$ wslpath 'c:\users' /mnt/c/users
WSL path from Windows:
$ wslpath -w '/' \\wsl.localhost\Ubuntu\
Set Default User for WSL
Ubunutu:
ubuntu config --default-user root
Ubuntu18:
ubuntu1804 config --default-user root
Set Default User for Windows Subsystem for Linux Distro in Windows 10 | Tutorials https://www.tenforums.com/tutorials/128152-set-default-user-windows-subsystem-linux-distro-windows-10-a.html
Mount VHDX or VHD in WSL
Install Docker Desktop WSL2 on Windows with allocated maximum size (virtual size) less then default 1TB - Docker Desktop for Windows - Docker Community Forums https://forums.docker.com/t/install-docker-desktop-wsl2-on-windows-with-allocated-maximum-size-virtual-size-less-then-default-1tb/135817/8
Is it possible to map a WSL mount into a docker container? Or use an EXT4 VHD with Docker in any other way? : r/docker https://www.reddit.com/r/docker/comments/112b10k/is_it_possible_to_map_a_wsl_mount_into_a_docker/
Moving docker-desktop "distro" vhdx file - Docker Desktop for Windows - Docker Community Forums https://forums.docker.com/t/moving-docker-desktop-distro-vhdx-file/137632/3
WSL2 mount VHDX virtual disk issue with Windows docker Volumes - Stack Overflow https://stackoverflow.com/questions/65548924/wsl2-mount-vhdx-virtual-disk-issue-with-windows-docker-volumes
Get started mounting a Linux disk in WSL 2 | Microsoft Learn https://learn.microsoft.com/en-us/windows/wsl/wsl2-mount-disk
How to Use Dedicated Disks in Wsl - Rouke's Blog https://broersma.dev/how-to-use-dedicated-disks-in-wsl/
best:
WSL2 How-to: Prepare and Attach Virtual Drives (VHD) | by Tony Tannous | Medium https://anthony-f-tannous.medium.com/wsl2-how-to-prepare-and-attach-virtual-drives-vhd-ac17b1fc7a61
Misc:
wsl --mount \\.\PHYSICALDRIVE2 --bare
wsl -d Ubuntu-20.04 --mount --vhd C:\Users\<username>\wsl2-shared.vhdx --bare | out-null wsl -d Ubuntu-20.04
wsl -d Ubuntu-20.04 --mount --vhd $env:USERPROFILE\wsl2-shared.vhdx --bare
Mount VHD:
pwsh.exe -Command "wsl.exe -d Ubuntu-20.04 --mount --vhd C:\Users\<username>\wsl2-shared.vhdx --bare | out-null; wsl.exe -d Ubuntu-20.04"
Inside WSL see mount:
blkid lsblk -o NAME,LABEL,FSTYPE,SIZE,MOUNTPOINT /dev/sdd lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT /dev/sdd sudo parted /dev/sdd print sudo parted -a optimal /dev/sdd mkpart primary ext4 0% 100% parted /dev/sdd mklabel msdos mount -l | grep vhd-part1
Unmount
wsl --unmount \\?\C:\Users\<username>\wsl2-shared.vhdx
NFS
To mount an NFS share in WSL, you will need to mount it with "insecure"
example /etc/exports
/pub *(rw) /pub 10.0.0.101(insecure,rw)
Issues
Update fails with Forbidden (403)
C:\>wsl --update Checking for updates. Forbidden (403). Error code: Wsl/UpdatePackage/0x80190193
Searches online indiate Defender (or other virus scanner may be to blame).
One suggests using --web-download:
wsl --update --web-download
ref: [2]
C:\>wsl --update Checking for updates. The most recent version of Windows Subsystem for Linux is already installed.