advnpzn

Back

Increasing Memory in WSL2Blur image

You guys already know what is wsl2, so let’s not waste time. I assume at this point, you already have a distro for your WSL2 ready and don’t know how to increase the RAM/memory.

For this example, I’ll be using Debian 12 (Bookworm).

pfetch output showing Debian system information

Powershell#

Go to your $HOME directory in powershell. If you don’t know what your HOME directory is, just do

echo $HOME
powershell

This would show you the home directory.

After this, we need to create a file called .wslconfig in the $HOME directory. We can do this from PowerShell itself.

notepad.exe .wslconfig
powershell

Notepad#

A new Notepad window might open, in there just type

.wslconfig

[wsl2]
memory=8GB
ini

Now, for the memory= value, your value should be equal to or less than your actual Memory / RAM you have.

Let’s say, I have 16 GB of RAM, then I can give 4 GB, 8GB, 10GB, 16 GB etc.. as long as it is within or equal to 16 GB.

Save the .wslconfig file in your $HOME directory.

Sometimes, it would be saved as .wslconfig.txt, you can rename it easily in PowerShell.

mv .wslconfig.txt .wslconfig
powershell

Restart your WSL2#

After this, if your WSL2 is already running, restart it.

wsl --shutdown
powershell

And now open, any distro you have.

wsl -d Debian
powershell

Now check how much RAM/memory you have 😄

Reference(s)#

Increasing Memory in WSL2
https://advnpzn.github.io/blog/wsl2-increase-memory
Author advnpzn
Published at March 12, 2024
Comment seems to stuck. Try to refresh?✨