Using WSL

WSL files in Windows:


Reduce RAM usage by WSL2

WSL2 can consume huge amounts of RAM and not releasing it, even if it does not execute any task. In order to limit memory consumption by WSL2:

  • create a file with name .wslconfig in your user’s home directory
  • add the following content to the .wslconfig file:

memory=10Gb means that 10Gb of RAM are assigned to the WSL2 VM. WSL2 will not use more than that. swap=0 means that the swap file is not used.

Reference: WSL 2 Settings

With the setting above, WSL2 can still use almost 10Gb of RAM with no active tasks, but never more than 10Gb.

If you run some RAM consuming tasks in WSL2, for example, you test some functionality in the environment created by a set of docker containers, you may experience Out of memory errors, if you use all 10Gb of memory allocated to WSL2.

Resolve git clone .git/config.lock failed: Operation not permitted, fatal: could not set ‘core.filemode’ to ‘false’

The problem is caused by the fact that git is not allowed to use chmod.

As a workaround, execute the git clone command with sudo:

sudo git clone ...

In order to permanenetly solve the issue, add the following lines to the file /etc/wsl.conf:

options = "metadata"

and restart wsl.

References: stackoverflow stackexchange