Windows

You can now choose the ram and cpu you want to use in windows 10 for wsl2 (linux subsystem for windows)

One of the novelties that came with Windows 10 Anniversary Update  (version 1607) was the Linux Subsystem for Windows 10, WSL. This small ecosystem allows us to run a virtual Linux (with Hyper-V) within Windows 10 so that anyone can run this operating system and its applications from Windows without having to resort to other virtual machines such as VirtualBox or VMware. With Windows 10 20H1, the update that will arrive in the spring of next year, Microsoft is going to launch what will be the second version of this subsystem, WSL2, and it will bring very interesting news.

We have already seen how the new Linux Subsystem for Windows 2 will bring improvements in the way of communicating with Windows 10, it will allow us to access the files of this ecosystem from /, it will have its own IP as a virtual machine and new commands to control the general functioning of WSL.

In addition to these features that are already available in the Insider version of Windows 10 20H1, Microsoft continues to bring new improvements and news to this version of the operating system. One of the new features coming to WSL 2 in Windows 10 20H1 is the ability to make global configurations to this subsystem. These settings allow us, for now, to limit the use of CPU and RAM within Linux ecosystems.

How to limit RAM and CPU within the Linux Subsystem for Windows 10

WSL is not a function for new users, so we will not find a menu or an option within the Windows configuration to control this aspect. To configure WSL2 we must do it by hand using configuration files, in the purest Linux style. For this, we will specifically have to create a text file called “.wslconfig” inside our personal folder.

In our specific case, the file will be in the following directory: C: Usersruvelro. This will be a plain, normal text file, and we can edit it with notepad.

The configuration options offered by WSL2 are the following:

  • kernel = <path>: allows us to indicate the path to a custom Linux kernel.
  • memory = <size>: allows us to specify, in MB or GB, the amount of RAM that we want to use in the Linux Subsystem.
  • processors = <number>: allows us to specify the maximum number of processors (or cores) that can be used in the virtual machine.
  • swap = <size> / <path>: maximum size and directory of the SWAP swap memory.
  • localhostForwarding = <bool>: allows us to specify if the ports will have access to localhost.

We can see the documentation for these commands from GitHub.

Thus, for example, we will be able to tell WSL2 that it can only use a maximum of 4 GB of RAM and 2 cores of our CPU, leaving the rest of the free resources available for our Windows 10.

The important thing about this configuration file is that [wsl2] appears in the first line as shown in the screenshots. The rest of the options must go as specified and everything that follows a # will be a comment, identifying text that does not influence the configuration.

Windows 10 20H1 is still in development

There is still time until Microsoft releases Windows 10 20H1 with WSL 2, so it is very likely that we will still see other features and improvements in the Linux Subsystem for Windows 10 before the new version reaches everyone.

If all goes well, Windows 10 20H1 should reach users in spring 2020, but before that happens we will have to update to Windows 10 19H2, an update of which, for now, not much is known.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button