Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
* [Automatically Start Docker in WSL 2](#automatically-start-docker-in-wsl-2)
* [Releasing RAM Memory from WSL 2](#releasing-ram-memory-from-wsl-2)
* [.wslconfig and wsl.conf Files](#wslconfig-and-wslconf-files)

* [Expanding the WSL 2 Virtual Disk](#expanding-the-wsl-2-virtual-disk)

</details>

Expand Down Expand Up @@ -234,7 +234,7 @@ By default, Windows Terminal will identify the main shells installed on Windows,

We can say that WSL 2 has almost complete access to your machine's resources. By default, it has access to:

* The entire hard drive.
* A 1TB hard disk. A 1TB virtual disk is created to store Linux files (this limit can be expanded, see the Tips and Tricks section).
* Full use of processing resources.
* 50% of the available RAM.
* 25% of the available SWAP (virtual memory).
Expand Down Expand Up @@ -725,7 +725,7 @@ To resolve this, enable the `mirrored` network mode in WSL 2, which makes the WS

```conf
[wsl2]
network=mirrored
networkingMode=mirrored
```

This option will only work after restarting WSL with the command `wsl --shutdown`.
Expand Down Expand Up @@ -761,17 +761,15 @@ command = service docker start

### Releasing RAM Memory from WSL 2

If you notice that WSL 2 is consuming too many resources, execute the following commands within the WSL 2 terminal to release RAM memory:
If you notice that WSL 2 is consuming a lot of your machine's resources, run the following command in the WSL 2 terminal to free up RAM:

```bash
echo 1 | sudo tee /proc/sys/vm/drop_caches
```

This method is aggressive as it releases RAM instantly but may be necessary in some cases.

> Do not use this option if you

are using Docker Engine. It can be used with Docker Desktop or if Docker is not installed.
> Do not use the option below if you are not using Docker Engine. It can be used with Docker Desktop or if you do not have Docker installed.

WSL has a feature called `autoMemoryReclaim` that automatically releases unused RAM.

Expand All @@ -787,6 +785,8 @@ Edit the `.wslconfig` file:
autoMemoryReclaim=gradual
```

If you want an automatic memory release option and are using Docker Engine, run the following script in WSL: [https://gist.github.com/craigloewen-msft/496078591e0bbbfdec9f144c6b50a8cc](https://gist.github.com/craigloewen-msft/496078591e0bbbfdec9f144c6b50a8cc). By default, it runs every 2 minutes, but you can change the execution interval.

### .wslconfig and wsl.conf Files

The `.wslconfig` file is a global configuration file, meaning it affects all Linux distributions installed in WSL 2, as you might have multiple Linux distributions like Ubuntu, Debian, Fedora, etc.
Expand All @@ -799,6 +799,18 @@ Some options you can use in `.wslconfig` and `wsl.conf` are detailed in the offi

These options will only take effect after restarting WSL with the command `wsl --shutdown`.

### Expanding the WSL 2 Virtual Disk

By default, the WSL 2 virtual disk is 1TB, but if you need more space, you can expand the virtual disk.

A simple way to check the disk size is to run the following command in PowerShell or DOS:

```bash
wsl --system -d <distribution-name> df -h /mnt/wslg/distro
```

Use Windows `diskpart` to expand its size. Follow this tutorial: [How to Expand the Size of Your WSL 2 Virtual Hard Disk](https://learn.microsoft.com/en-us/windows/wsl/disk-space#how-to-expand-the-size-of-your-wsl-2-virtual-hard-disk).

## FAQs

### Do I need a Windows 10/11 Pro license to use WSL 2?
Expand Down
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
- [Iniciar o Docker automaticamente no WSL 2](#iniciar-o-docker-automaticamente-no-wsl-2)
- [Liberar memória RAM do WSL 2](#liberar-memória-ram-do-wsl-2)
- [Arquivos .wslconfig e wsl.conf](#arquivos-wslconfig-e-wslconf)
- [Expandir o disco virtual do WSL 2](#expandir-o-disco-virtual-do-wsl-2)
</details>

<details open>
Expand Down Expand Up @@ -236,7 +237,7 @@ Por padrão, o Windows Terminal vai identificar os principais shells instalados

Podemos dizer que o WSL 2 tem acesso quase que total ao recursos de sua máquina. Ele tem acesso por padrão:

* A todo disco rígido.
* A 1TB de disco rígido. É criado um disco virtual de 1TB para armazenar os arquivos do Linux (este limite pode ser expandido, ver a área de dicas e truques).
* A usar completamente os recursos de processamento.
* A usar 50% da memória RAM disponível.
* A usar 25% da memória disponível para SWAP (memória virtual).
Expand All @@ -254,8 +255,6 @@ Estes são limites de exemplo e as configurações mais básicas a serem utiliza

Para mais detalhes veja esta documentação da Microsoft: [https://learn.microsoft.com/pt-br/windows/wsl/wsl-config#configuration-setting-for-wslconfig](https://learn.microsoft.com/pt-br/windows/wsl/wsl-config#configuration-setting-for-wslconfig). Existem outras configurações que podem ser feitas, como configurações de rede, VPN, liberação de memória, etc.



Para aplicar estas configurações é necessário reiniciar as distribuições Linux. Execute o comando: `wsl --shutdown` (Este comando vai desligar todas as instâncias WSL 2 ativas, basta abrir o terminal novamente para usa-las já com as novas configurações).

Este arquivo `.wslconfig` é um arquivo de configuração global, ou seja, ele afetará todas as distribuições Linux que você tiver instalado no WSL 2, porque você pode ter mais de uma distribuição Linux instalada no WSL 2, como um Ubuntu, um Debian, um Fedora, etc.
Expand Down Expand Up @@ -723,7 +722,7 @@ Para resolver isto, ative o modo `mirrored` da rede do WSL 2, que fará com que

```conf
[wsl2]
network=mirrored
networkingMode=mirrored
```

Esta opção só funcionará após reiniciar o WSL com o comando `wsl --shutdown`.
Expand Down Expand Up @@ -759,15 +758,15 @@ command = service docker start

### Liberar memória RAM do WSL 2

Se verificar que o WSL 2 está consumindo muitos recursos da máquina, execute os seguintes comandos dentro do terminal WSL 2 para liberar memória RAM:
Se verificar que o WSL 2 está consumindo muitos recursos da máquina, execute o seguinte comando dentro do terminal WSL 2 para liberar memória RAM:

```bash
echo 1 | sudo tee /proc/sys/vm/drop_caches
```

Este método é agressivo, porque libera instantaneamente a memória RAM, mas pode ser necessário em alguns casos.

> Não use esta opção se estiver usando o Docker Engine. Pode ser utilizado com o Docker Desktop ou se não tiver o Docker instalado.
> Não use a opção abaixo opção se não estiver usando o Docker Engine. Pode ser utilizado com o Docker Desktop ou se não tiver o Docker instalado.

O WSL possui um recurso chamado `autoMemoryReclaim` que libera a memória RAM que não está sendo usada de forma automática.

Expand All @@ -783,6 +782,8 @@ Edite o arquivo `.wslconfig`:
autoMemoryReclaim=gradual
```

Caso queria uma opção de liberação de memória automática e estiver usando o Docker Engine, coloque o seguinte script para rodar no WSL: [https://gist.github.com/craigloewen-msft/496078591e0bbbfdec9f144c6b50a8cc](https://gist.github.com/craigloewen-msft/496078591e0bbbfdec9f144c6b50a8cc). Por padrão, ele vai rodar de 2 em 2 minutos, mas você pode alterar o tempo de execução.

### Arquivos .wslconfig e wsl.conf

O arquivo `.wslconfig` é um arquivo de configuração global, ou seja, ele afetará todas as distribuições Linux que você tiver instalado no WSL 2, porque você pode ter mais de uma distribuição Linux instalada no WSL 2, como um Ubuntu, um Debian, um Fedora, etc.
Expand All @@ -795,6 +796,19 @@ Existem algumas opções que podem ser usadas no arquivo `.wslconfig` e `wsl.con

Esta opção só funcionará após reiniciar o WSL com o comando `wsl --shutdown`.

### Expandir o disco virtual do WSL 2

Por padrão o disco virtual do WSL 2 é de 1TB, mas se você precisar de mais espaço, é possível expandir o disco virtual.

Uma maneira simples de verificar o tamanho do disco é rodar o seguinte comando no PowerShell ou DOS:

```bash
wsl --system -d <distribution-name> df -h /mnt/wslg/distro
```

Utilize o `diskpart` do Windows para expandir o tamanho dele, siga este tutorial: [https://learn.microsoft.com/en-us/windows/wsl/disk-space#how-to-expand-the-size-of-your-wsl-2-virtual-hard-disk](https://learn.microsoft.com/en-us/windows/wsl/disk-space#how-to-expand-the-size-of-your-wsl-2-virtual-hard-disk)


## Dúvidas

### Preciso de uma licença PRO do Windows 10/11 para usar o WSL 2?
Expand Down