WSL Conf
cat /etc/wsl.conf.bak
[boot]
systemd=true
[user]
default = username
[automount]
enabled = true
#mountFsTab = true
root = /mnt/
Memory
Get-Content "$HOME\.wslconfig"
- Run in PowerShell
@'
[wsl2]
memory=10GB
swap=16GB
'@ | Set-Content "$HOME\.wslconfig" -Encoding ascii
or
@'
[wsl2]
memory=6GB
swap=16GB
[experimental]
autoMemoryReclaim=dropcache
'@ | Set-Content "$HOME\.wslconfig" -Encoding ascii
WSL.conf issues
If the WSL Distro fails to boot, it generally is due to WSL.conf issues.
- Locate the Linux VHD disk image in PowerShell
Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\* |
Select-Object DistributionName, BasePath
output
DistributionName BasePath
---------------- --------
Kali D:\Linux\KaliLinux
docker-desktop \\?\D:\Docker\wsl\DockerDesktopWSL\main
Arch \\?\D:\Linux\ArchRescue
- Shutdown WSL and mount the linux VHD
wsl --shutdown
wsl --mount "D:\Linux\ArchRescue\ext4.vhdx" --vhd --bare
- Launch the working Linux distro
wsl -d Kali
- Inside the owrking distro, create a directory to mount the target VHD and mount it
sudo mkdir -p /mnt/arch_root
sudo mount /dev/sdd /mnt/arch_root
- Make the changes or the backup to the
wsl.conffile.
sudo mv /mnt/arch_root/etc/wsl.conf /mnt/arch_root/etc/wsl.conf.bak
- Inside the working distro, umount the VHD and exit
sudo umount /mnt/arch_root
exit
- Back to Windows host powershell, umount the VHD on WSL
wsl --unmount "D:\Linux\ArchRescue\ext4.vhdx"
wsl --shutdown
- Try to enter the buggy WSL distro
wsl -d ArchRescue