How to Enable Windows Subsystem for Linux

Before install Windows Subsystem for Linux (WSL) you must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11. To install and run Windows Subsystem for Linux (WSL), you must entering this command in PowerShell or Windows Command Prompt and then restarting your machine.

PowerShell

wsl --install

This command will enable the required optional components, download the latest Linux kernel, set WSL 2 as your default, and install a Linux distribution for you (Ubuntu by default, see below to change this).

The first time you launch a newly installed Linux distribution, a console window will open and you’ll be asked to wait for files to de-compress and be stored on your machine. All future launches should take less than a second.

Change the default Linux distribution installed

By default, the installed Linux distribution will be Ubuntu. This can be changed using the -d flag.

  • To change the distribution installed, enter: wsl --install -d <Distribution Name>. Replace <Distribution Name> with the name of the distribution you would like to install.
  • To see a list of available Linux distributions available for download through the online store, enter: wsl --list --online or wsl -l -o.
  • To install additional Linux distributions after the initial install, you may also use the command: wsl --install -d <Distribution Name>.

Troubleshooting Windows Subsystem for Linux

Installation issues

  • Installation failed with error 0x80070003
    • The Windows Subsystem for Linux only runs on your system drive (usually this is your C: drive). Make sure that distributions are stored on your system drive:
    • Open Settings > System > Storage > More Storage Settings: Change where new content is saved
  • WslRegisterDistribution failed with error 0x8007019e
    • The Windows Subsystem for Linux optional component is not enabled:
    • Open Control Panel > Programs and Features > Turn Windows Feature on or off > Check Windows Subsystem for Linux or using the PowerShell cmdlet mentioned at the beginning of this article.
  • Installation failed with error 0x80070003 or error 0x80370102
    • Please make sure that virtualization is enabled inside of your computer’s BIOS. The instructions on how to do this will vary from computer to computer, and will most likely be under CPU related options.
    • WSL2 requires that your CPU supports the Second Level Address Translation (SLAT) feature, which was introduced in Intel Nehalem processors (Intel Core 1st Generation) and AMD Opteron. Older CPUs (such as the Intel Core 2 Duo) will not be able to run WSL2, even if the Virtual Machine Platform is successfully installed.
  • Error when trying to upgrade: Invalid command line option: wsl --set-version Ubuntu 2
    • Ensure that you have the Windows Subsystem for Linux enabled, and that you’re using Windows Build version 18362 or higher. To enable WSL run this command in a PowerShell prompt with admin privileges: Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux.
  • The requested operation could not be completed due to a virtual disk system limitation. Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.
    • Deselect “Compress contents” (as well as “Encrypt contents” if that’s checked) by opening the profile folder for your Linux distribution. It should be located in a folder on your Windows file system, something like: USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited...
    • In this Linux distro profile, there should be a LocalState folder. Right-click this folder to display a menu of options. Select Properties > Advanced and then ensure that the “Compress contents to save disk space” and “Encrypt contents to secure data” checkboxes are unselected (not checked). If you are asked whether to apply this to just to the current folder or to all subfolders and files, select “just this folder” because you are only clearing the compress flag. After this, the wsl --set-version command should work.
  • The term ‘wsl’ is not recognized as the name of a cmdlet, function, script file, or operable program.
    • Ensure that the Windows Subsystem for Linux Optional Component is installed. Additionally, if you are using an ARM64 device and running this command from PowerShell, you will receive this error. Instead run wsl.exe from PowerShell Core, or Command Prompt.
  • Error: Windows Subsystem for Linux has no installed distributions.
    • If you receive this error after you have already installed WSL distributions:
    1. Run the distribution at least once before invoking it from the command line.
    2. Check whether you may be running separate user accounts. Running your primary user account with elevated permissions (in admin mode) should not result in this error, but you should ensure that you aren’t accidentally running the built-in Administrator account that comes with Windows. This is a separate user account and will not show any installed WSL distributions by design.
    3. The WSL executable is only installed to the native system directory. When you’re running a 32-bit process on 64-bit Windows (or on ARM64, any non-native combination), the hosted non-native process actually sees a different System32 folder. (The one a 32-bit process sees on x64 Windows is stored on disk at \Windows\SysWOW64.) You can access the “native” system32 from a hosted process by looking in the virtual folder: \Windows\sysnative. It won’t actually be present on disk, mind you, but the filesystem path resolver will find it.
  • Error: This update only applies to machines with the Windows Subsystem for Linux.
    • To install the Linux kernel update MSI package, WSL is required and should be enabled first. If it fails, it you will see the message: This update only applies to machines with the Windows Subsystem for Linux.
    • There are three possible reason you see this message:
    1. You are still in old version of Windows which doesn’t support WSL 2. See step #2 for version requirements and links to update.
    2. WSL is not enabled. You will need to return to step #1 and ensure that the optional WSL feature is enabled on your machine.
    3. After you enabled WSL, a reboot is required for it to take effect, reboot your machine and try again.
  • Error: WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel .
    • If the Linux kernel package is missing in the %SystemRoot%\system32\lxss\tools folder, you will encounter this error. Resolve it by installing the Linux kernel update MSI package in step #4 of these installation instructions. You may need to uninstall the MSI from ‘Add or Remove Programs’, and install it again.

Related Posts

Leave a Reply

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

© 2022 Fix Windows PC - Theme by WPEnjoy · Powered by WordPress