.wslconfig ignored, can't get a swap file

I’m having trouble to configure Docker for Windows to use a separate SWAP-File. I was searching online for so long already and start to get crazy.

I searched for so long and probably don’t remember everything that I have tried. Here is what I’ve done so far:
creating .wslconfig in c:/Users/spice/ with this content:

[wsl2]
memory=44GB
swap=256GB
swapfile=C:\\temp\\wsl-swap.vhdx
localhostForwarding=true

Encoding of the file is UTF-8 and there are no spaces at the end of lines.

wsl-instances:
imagen

I’m running Win10 Pro:
imagen
imagen

Anybody has an idea what I’m missing?

1 Like

Is there an already-existing temp directory at the root of your C drive that has open permissions for everyone to read/write to?

How are you certain it isn’t being created/used? Is the file not present at that path?

1 Like

Exactly that. Temp-folder and swap-file did not exist.

OMG! No, there wasn’t a temp directory. I just created the temp folder and now the wsl-swap.vhxd was created. I remember that I was thinking about it before, but I was completely convinced that the directory would be created automatically.

So now I got the swap-file but it still did not work.

So I googled again and found a bug report suggesting that 256GB is too much and will not work. And indeed, lowering the swap size helps. I played around to find the maximum size and on my machine it’s 250GB (definition in .wslconfig):


So, 250GB works, 251GB does not work.
Oh, I just realize now that 250GB in the .wslconfig makes exactly 256k MB (2^8*1000). LOL… coincidence??

1 Like

Troubleshooting reference for others:
How to get memory and swap usage of webodm docker container:

docker ps
docker exec -it webodm-node-odm-1 bash
free -m

make sure to replace webodm-node-odm-1 with the proper name of your container, as shown in the image below.

.
How to apply changes in .wslconfig

  • Stop Docker Desktop (right click on icon → quit docker desktop)
  • wsl --shutdown on command line after docker desktop is terminated
  • modify .wslconfig and save
  • make sure at least 8 seconds passed since shutting down wsl
  • restart Docker Desktop
1 Like

By default, Docker/WSL2 vhdx will be dynamically expanding 250GB volumes :wink: You found your magic limit, haha.

That said, you should be able to use the Hyper-V Managment Tools in Windows to tweak the volumes when Docker/WSL2 is offline to further expand them.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.