TechBuzzPro

WSL2 Setup on Windows 11: A Complete Guide

· 5 min read · Windows & PC

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can set up WSL2 (Windows Subsystem for Linux 2) on Windows 11 to run Linux distributions like Ubuntu, Debian, or Fedora directly within Windows. This provides a lightweight and efficient way to develop and test Linux-based applications without needing a virtual machine or dual-booting. The process involves enabling virtualization, installing WSL, and then setting up your preferred Linux distribution. Let’s walk through it step-by-step.

What You'll Need

  • A Windows 11 PC.
  • Administrator privileges on your Windows 11 machine.
  • An internet connection.

Step-by-Step

  1. Enable Virtualization: This is the most crucial first step. WSL2 relies on virtualization. To check if it's enabled, open Task Manager (Ctrl+Shift+Esc), go to the "Performance" tab, and look for "Virtualization." If it says "Disabled," you need to enable it in your BIOS/UEFI settings. The process for accessing BIOS/UEFI varies by manufacturer (usually by pressing Delete, F2, F12, or Esc during startup). Once in the BIOS/UEFI, look for settings related to "Virtualization Technology" (VT-x or AMD-V) and enable it. Save your changes and exit.
  2. Run the WSL Installation Command: Open PowerShell as an administrator (right-click the Start button and select "Windows Terminal (Admin)" or "PowerShell (Admin)"). Paste and run the following command: wsl --install This command enables the necessary components and installs a default Linux distribution (usually Ubuntu).
  3. Restart Your Computer: After the command completes, you’ll be prompted to restart your computer. Do so to finalize the installation.
  4. Complete the Linux Distribution Setup: After restarting, the Linux distribution you chose (or the default Ubuntu) will begin installing. A console window will open, and you’ll be prompted to create a user account and password for your Linux environment. Follow the on-screen instructions.
  5. Set WSL2 as the Default Version (Important): While the `wsl --install` command *should* set WSL2 as the default, it’s a good idea to verify and manually set it if needed. Open PowerShell as administrator again and run: wsl --set-default-version 2 This ensures that new Linux distributions you install will use WSL2 by default.
  6. Install Additional Distributions (Optional): If you want to use a different Linux distribution, you can install it from the Microsoft Store. Search for the distribution you want (e.g., "Debian," "Kali Linux," "Fedora Remix for WSL") and click "Get." Follow the installation instructions.
  7. Update Your Installed Distributions: Once your distribution is installed and running, it's a good practice to update it. Open your Linux distribution's terminal and run the appropriate update commands. For Ubuntu/Debian, use: sudo apt update && sudo apt upgrade For Fedora, use: sudo dnf update

Common Mistakes

  • Forgetting to Enable Virtualization: This is the most common issue. Without virtualization enabled in the BIOS/UEFI, WSL2 will not function correctly.
  • Not Running PowerShell as Administrator: Some commands, like `wsl --install` and `wsl --set-default-version`, require administrator privileges.
  • Incorrect BIOS/UEFI Settings: Ensure you’re enabling the correct virtualization technology (VT-x or AMD-V). The exact wording can vary.
  • Firewall Issues: Occasionally, firewalls can block communication between Windows and WSL2. Ensure your firewall isn’t blocking the necessary ports.
  • Conflicting Hyper-V Settings: While WSL2 and Hyper-V can coexist, sometimes conflicting settings can cause problems. If you're experiencing issues, try disabling Hyper-V temporarily to see if it resolves the problem (though this will impact other Hyper-V-dependent features).

Tips

  • Use Windows Terminal: Windows Terminal provides a much better experience for interacting with WSL2 than the default console window. It supports multiple tabs, profiles, and themes.
  • Customize Your Linux Environment: Once you have WSL2 set up, you can customize your Linux environment to your liking. Install your favorite tools, editors, and IDEs.
  • Access Windows Files from Linux: Windows files are typically located under `/mnt/c` (for the C: drive), `/mnt/d` (for the D: drive), and so on.
  • Access Linux Files from Windows: Accessing Linux files from Windows can be a bit more involved. You can use the `\\wsl$` network share in File Explorer. Type `\\wsl$` in the address bar and press Enter. You'll see your installed distributions listed.
  • Keep WSL2 Updated: Microsoft regularly releases updates for WSL2. Keep your system up-to-date to benefit from bug fixes and performance improvements. Run `wsl --update` in PowerShell as administrator.

Troubleshooting

  • "Error: 0x8007019e" or "Virtualization is required for WSL 2": This almost always indicates that virtualization is not enabled in your BIOS/UEFI. Double-check your BIOS/UEFI settings.
  • WSL2 Not Starting: Try restarting your computer. If that doesn’t work, check your system event logs for any error messages.
  • Network Connectivity Issues: Ensure your firewall isn't blocking WSL2’s network access. Try temporarily disabling your firewall to see if that resolves the problem.
  • Disk Space Issues: WSL2 uses a virtual disk. If your disk is full, WSL2 may not function correctly. Free up some disk space.
  • Corrupted WSL2 Installation: As a last resort, you can try unregistering and reinstalling WSL2. Open PowerShell as administrator and run: wsl --unregister (Replace `` with the name of your distribution, e.g., "Ubuntu"). Then, reinstall the distribution from the Microsoft Store.

Frequently Asked Questions

What is the difference between WSL1 and WSL2?

WSL2 uses a lightweight virtual machine, providing significantly better file system performance and full system call compatibility compared to WSL1.

Can I run graphical applications in WSL2?

Yes, with WSLg (Windows Subsystem for Linux GUI), you can now run graphical Linux applications directly on Windows. WSLg is automatically enabled with recent versions of Windows 11.

How do I update WSL?

Open PowerShell as administrator and run `wsl --update`.

How do I access the Windows file system from within WSL?

Windows drives are mounted under `/mnt/c`, `/mnt/d`, etc.

Can I use WSL2 with multiple Linux distributions?

Yes, you can install and use multiple Linux distributions simultaneously. Each distribution runs in its own isolated environment.