Configure Linux subsystem on Windows (WSL)

Create

Start the PowerShell and type:

wsl --install

After reboot enter your username/password and viola, you have your Ubuntu.

Unfortunately it is on drive C. If you need it somewhere else, there is a way:

Move to over location (D:)

Make a backup for your newly created image (in PowerShell):

wsl --export Ubuntu D:\u.tar

Delete your original Ubuntu distribution from drive C.

wsl --unregister Ubuntu

Create a directory for a new Ubuntu home.

cd /d d:/
mkdir wsl
cd wsl

Install Ubuntu in a new location, remove the intermediate file and switch the default user from `root` to the desired name.

wsl --import Ubuntu D:\wsl\ D:\u.tar
rm D:\u.tar
cd $env:USERPROFILE\AppData\Local\Microsoft\WindowsApps
ubuntu config --default-user <DESIRED_ACCOUNT_NAME>
wsl

RAM

For some reason WSL allocates only 7 GB of RAM for Linux machines, while LLVM build requires much much more. Let's fix it.

Shut down the current Ubuntu from Powershell.

wsl --shutdown

Edit/create file $env:USERPROFILE\.wslconfig (in my case it's in c:\Users\ak\.wslconfig). There should be:

[wsl2]
memory=14GB

Restart Ubuntu and check memory with htop.

Leave a Reply

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