118

I installed the Windows Subsystem for Linux on Windows 10 Insider Preview build 14316. Now I would like to remove it or, better, revert to its factory defaults i.e. as it was when just installed.

I tried, to remove it from the "Turn Windows features on or off" windows, with no luck. I tried, to mark it as "off" in the above windows and delete its files manually located in %USERPROFILE%/AppData/Local/lxss, with no luck.

Has anyone succeeded in removing/resetting the Ubuntu user-mode environment?

Ramhound
  • 41,734
  • 35
  • 103
  • 130
shub
  • 1,430
  • 2
  • 11
  • 8

2 Answers2

155

The following answer only applies to WSL on Windows 10 1703 and 1607. WSL on Windows 10 1709+ can be installed from within the Windows Store UWP application.

If you want to remove and reset the Linux subsystem, open a command prompt with elevated permissions and enter the following commands:

lxrun /uninstall /full 

lxrun /install

On modern versions of Windows the command to uninstall the default WSL distribution is as follows:

wsl --unregister

Sources:

  1. https://www.slightfuture.com/technote/lxss-lxrun

  2. Installing Fish Shell on Ubuntu on Windows 10

  3. HOWTO: Ubuntu on Windows | Ubuntu Insights

Ramhound
  • 41,734
  • 35
  • 103
  • 130
  • @BenCreasy - What’s your point? It was correct when it was submitted. In fact it’s still correct. – Ramhound Jul 03 '23 at 14:27
  • It's one of the highest voted WSL posts on SU but doesn't help 99.999% of people looking for help at this point. Just unforunate. – Ben Creasy Jul 03 '23 at 17:40
  • @BenCreasy - Majority of those votes were in 2016. There are lots of contributions that are about Windows XP which are completely irrelevant. I disagree this is one of the highest voted WSL answers on SU. I better received answer to be honest. – Ramhound Jul 03 '23 at 18:49
2

I was having problems with installing BASH, it would always hang at "Expanding Filesystem...". When I ran

lxrun /uninstall /full

it would error out.

To fix this, I did a reboot. Ran this again as soon as the computer came back up. This worked. Then I found there is an issue related to installing the BASH prompt.

And someone brought up about pagefiles. I have four drives and three of them had pagefiles. I set the pagefile to one drive and set it to be automatically managed. Rebooted the computer. Then I was able to install the BASH prompt for Windows, but instead of using lxrun /install I used

bash.exe -c "ps auxf"
Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
SPLUS1
  • 21
  • 1