Completely reinstall WSL

30,270

Can WSL 2 be installed from scratch without installing WSL 1 before?

No. The base WSL support is required for WSL2.

What is the most secure and advisable process to remove WSL completely?

Here's the best info I have on removing everything related to WSL.

It sounds like you consider the existing instance a lost cause, but if you'd like to back it up for posterity, you can start with:

  • wsl --export <distroname> archivename.tar

Then remove the existing distro installation(s):

  • Any distro you installed from the Store, you should first remove through "Apps & Features" (a.k.a. "Add or remove programs") in Windows. This also goes for distributions installed manually via downloaded Appx package.

Then check to make sure nothing is left. From PowerShell or CMD:

  • wsl -l
  • wsl --unregister <distroname>

You may want to just install a new distro at that point from the Store. It's unlikely that any additional reinstallation of the other components is going to make a difference. But if you do want to remove them:

  • From "Apps & Features" (a.k.a. "Add or remove programs") in Windows, remove the "Windows Subsystem for Linux Update". I'm fairly certain this is the Linux kernel update. Probably reboot if you want to be sure it's fully gone before the next step.
  • From "Turn Windows Features on or off" in Windows, disable the "Virtual Machine Platform". This is the WSL2 Hyper-V support. Probably reboot if you want to be sure it's fully gone before the next step.
  • From "Turn Windows Features on or off", disable "Windows Subsystem for Linux.
  • Reboot.

When you are reinstalling from there, I'd appreciate it if you could confirm that "Windows Subsystem for Linux Update" returns to Apps & Features after installing the kernel update package (Step 4 in the Install doc). I will update this answer based on that info.

Share:
30,270

Related videos on Youtube

yodabar
Author by

yodabar

Best wishes.

Updated on September 18, 2022

Comments

  • yodabar
    yodabar over 1 year

    I installed WSL 1, enjoyed having Linux on my PC, then discovered the limitations of the scarce interoperability over files between the two operating systems.

    So I installed WSL 2 following the specs (enabled virtualization in BIOS settings and all the stuff) but the installation is not completely working, I cannot set it as default and not all the shell commands respond as expected.
    I googled and somebody had similar issues, but not so many straightforward solutions are proposed (I guess it is still a relatively new case).

    So I want remove WSL as deeply as possible and reinstall WSL 2 from scratch.

    • What is the most secure and advisable process to remove WSL completely?
    • Can WSL 2 be installed from scratch without installing WSL 1 before?
  • yodabar
    yodabar over 3 years
    Thanks for the detailed info, I will come back to confirm the process and the last point in particular.
  • Eddie Parker
    Eddie Parker over 2 years
    FWIW I did your steps and I did the 'simplified install' (wsl --install on the command line) and it reinstalled the kernel update package automatically.
  • NotTheDr01ds
    NotTheDr01ds over 2 years
    @EddieParker Thanks! That also reminds me that I need to go back through my old answers and update them for wsl --install since it's now GA.
  • Techrocket9
    Techrocket9 over 2 years
    These steps successfully unborked my WSL install that was borked by upgrading to Windows 11.
  • yodabar
    yodabar over 2 years
    @NotTheDr01ds To answer to your question, "Windows Subsystem for Linux Update" is not visible in Windows Apps & Features after installing the kernel update package, in my PC.
  • Robin De Schepper
    Robin De Schepper over 2 years
    If you go the export/import route, you can restore your default user after import by running ubuntu config --default-username <username> from CMD
  • NotTheDr01ds
    NotTheDr01ds over 2 years
    @RobinDeSchepper True, but that does assume that (a) the distribution is Ubuntu (the non-versioned one from the Microsoft Store) and (b) it was installed from the Store. For Store distros, it could also be ubuntu2004 or alpine or debian or others. I tend to prefer the /etc/wsl.conf method of setting the default user as described here. That also has the advantage of (a) working even if the distribution wasn't installed from the store, and (b) any --export's you do with that image from that point on will "remember" the default user.