Build system setup WSL

This method is NOT OFFICIALLY supported. A native GNU/Linux environment is recommended.

See also: Windows Subsystem for Linux Documentation, How much faster is WSL 2?

The OpenWrt build system is reported to work in WSL with Debian.

sudo apt update
sudo apt dist-upgrade

To be able to build an OpenWrt image, you must not have spaces in PATH or in the work folders on the drive. But by default in a WSL environment there are windows folders too and those have spaces in path:

> echo ${PATH}
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files (x86)/GnuPG/bin:/mnt/c/Program Files (x86)/dotnet/:/mnt/c/Program Files/WireGuard/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files (x86)/AOMEI/AOMEI Backupper/6.5.1:/mnt/c/Program Files (x86)/Bitvise SSH Client:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Users/Bas Mevissen/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/Bas Mevissen/.dotnet/tools 

When launching commands in the OpenWrt build system folder, you can override the path with only the folders you want (i.e. only Linux ones since nothing from Windows is needed to compile OpenWrt) this is an example where we are just calling a make:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin make 

See also: Automatically Configuring WSL, How to remove the Win10's PATH from WSL

Configure WSL so that no Windows path elements (starts with /mnt) are in the PATH environment variable of the Linux distribution. In the Linux environment create /etc/wsl.conf:

sudo tee -a /etc/wsl.conf << EOF > /dev/null
[interop]
appendWindowsPath = false
EOF
exit

Restart WSL to apply changes:

wsl --shutdown

In the Linux environment verify whether no Windows path elements appear in the PATH environment variable by following command.

echo ${PATH}

See also: Configure global options with .wslconfig

It is possible to limit WSL2's use of RAM/CPU resources by creating/editing %USERPROFILE%\.wslconfig.

[wsl2]
memory=8GB # Limits VM memory in WSL 2 to 8 GB
processors=4 # Makes the WSL 2 VM use four virtual processors

Restart WSL to apply changes:

wsl --shutdown

By default, WSL2 mounts your Windows drive under /mnt/c, so you can access from WSL2 to Windows.

You can access the WSL2 file system from Windows 10 by opening explorer.exe and entering \\wsl$\<name of WSL Instance>, e.g. \\wsl$\Ubuntu-20.04. You can map this to a drive letter to easily access the WSL2 system from Windows programs, like Atom or other graphical IDE software.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2021/10/15 08:24
  • by bobafetthotmail