WSL: Initializing WSL 2 with more than 250GB of swap space fails
Environment
Windows build number: 10.0.20150.0
Your Distribution version: (Debian) Linux version 4.19.121-microsoft-WSL2-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Thu May 14 20:25:24 UTC 2020 Whether the issue is on WSL 2 and/or WSL 1: WSL 2
Steps to reproduce
- Create a
.wslconfigfile with the following items.
Note that drive E is an empty drive with around 512GB of free space.
[wsl2]
memory=8GB
swap=256GB
swapFile=E:\\swap.vhdx
-
In PowerShell run,
wsl --shutdown Debian -
Open up wsl and type in
free -m
Expected behavior
free -m should report something similar to this.
total used free shared buff/cache available
Mem: 7972 256 7655 0 59 7556
Swap: 256000 0 256000
Actual behavior
However actually it reports this.
total used free shared buff/cache available
Mem: 7972 256 7655 0 59 7556
Swap: 0 0 0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (1 by maintainers)
Commits related to this issue
- Increasing swap ram Please ftlog stop crashing https://github.com/microsoft/WSL/issues/5476 — committed to LSYS/dotfiles by LSYS 4 years ago
Any update here? When using wsl2 +gpu for ml matrix calc, I bought 128GB(64x4) memory but need 256GB+ more memory. On hard linux machine I can set swap with 512GB(one entire ssd), but cannot set on wsl2?
Workaround for adding more Swap file
.wslconfig
WSL2 will auto create swapfile.vhdx with maximum 250GB in size (preset but not allocated dynamic vhdx disk) For create more swap than 250GB limit use trick below Install WSL2 Preview from Microsoft Store first: https://www.microsoft.com/store/productId/9P9TQF7MRM4R
Your can download .vhdx file below and unzip it for using as Swap file wslswapfile.zip
@therealkenc the inability to assign large amount of virtual memory to WSL2 continues to be an issue on current builds (including Windows 11). I’ve been able to fully reproduce the behavior described by the original author. Can we get this issue reopened?
That is very strange. I’m also running Windows 11 and have it working with a specified swapfile. My working .wslconfig file:
(placed in my %UserProfile%)