Gentoo in WSL

WSL stands for Windows Subsystem for Linux. It is a subsystem for running Linux on Windows. Since WSL uses a real Linux kernel running on top of a hypervisor you are effectively running Linux within Windows.

Gentoo can run on top of WSL too.

Installing Gentoo on WSL
A stage 3 tarball is required, and WSL needs to be installed. Version 2 is assumed here but these instructions might apply to version 1.

Use the following command to import Gentoo into WSL.

Gentoo = the name of the Linux distribution we are importing. (path) = the path we want Gentoo to go. Then we select our stage 3. We are using WSL version 2.

For example:

Entering and setting up the Gentoo distribution
This is not gonna be a rewrite of the Gentoo handbook, just covering some of the basics to get started. Enter the Gentoo distribution on WSL by using the command:

Configure the system using the instructions in the handbook. Note that only the sections listed below are relevant on WSL; instructions in all other sections may be ignored.
 * Configuring compile options
 * Optional: Selecting mirrors
 * Configuring Portage
 * Configure locales

Create and configure a user, this is what WSL prompts you to do when you use one of the prepackaged distros. Replace  with a username of your choice.

Set a root password.

Now we have a basic Gentoo system setup in WSL. You can install programs and use it the way you'd normally use Gentoo!

Setting your user to be default
When starting Gentoo in WSL, by default the user will be used. This isn't secure, or preferable. It would be better if WSL would use the user we created as default.

Create a file called in the Gentoo system on WSL with the following contents.

Replace  with your own username.

Configuring WSL 2
WSL can be configured in ways such as adjusting the memory allocation, since WSL 2 is a virtual machine. Here's an example of configuring WSL 2: