MicrosoftDocs / WSL

Source code behind the Windows Subsystem for Linux documentation.
https://docs.microsoft.com/windows/wsl
Other
1.91k stars 563 forks source link

How can I revert from WSL 2 to the earlier version of WSL? (Need to remove conflict with VirtualBox) #590

Closed eliotmoss closed 4 years ago

eliotmoss commented 4 years ago

I had WSL 1 running fine and co-existing with VirtualBox. I then upgraded my OS (that was due anyway) and upgraded to WSL 2, because I wanted to try it out and check the performance benefits. That caused VirtualBox to stop working (as described in various VB forum threads, etc.). I really needed VB, so I turned off Hyper-V (which is the thing that interferes with VB, apparently). Of course that breaks WSL 2. Just doing --set-version Ubuntu 1 is not enough to revert (though it "worked", i.e., the command did not complain, because I turned Hyper-V back on temporarily). But I would like to the run the "old" WSL version 1.

How do I revert?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

charounsons commented 4 years ago

From the command shell, run: wsl.exe --set-version Ubuntu 1 From Windows Powershell, run: wsl --set-version Ubuntu 1

This assumes you are using Ubuntu.

eliotmoss commented 4 years ago

That will downgrade the distro, but it does not downgrade the wsl /program/. The program still insists on having VirtualMachineExtensions turned on, which is what interferes with VirtualBox.

ghost commented 4 years ago

BTW if your goal was to run WSL and VirtualBox at the same time: Latest release(6.1.4) of VirtualBox is now compatible with Hyper-V hypervisor again, as changelog describes.

Windows host: Restore the ability to run VMs through Hyper-V, at the expense of performance

eliotmoss commented 4 years ago

Yes, I had seen that. Supposedly the performance penalty is really bad. Sigh. Doesn't someone know how to revert the WSL program?

eliotmoss commented 4 years ago

Sorry, didn't mean to close it - clicked wrong option.

Arkhaeon commented 4 years ago

@eliotmoss you just need to disable the Virtual Machine Platform feature after converting all your distros back to WSL1. Also don't forget to set the default version back to one.

dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /norestart
wsl --set-default-version 1

EDIT: Successfully tested this on my machine with WSL Ubuntu and VMWare Workstation 15.

soconn commented 4 years ago

I'm assuming turning VirtualMachinePlatform to on enabled Hyper-V. Try to disable hyperV in Windows Services.

eliotmoss commented 4 years ago

I know people are trying to be helpful, but the steps Arkhaeon suggested do not accomplish what is required. After doing them, when I try to start wsl I get:

Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS. For information please visit https://aka.ms/wsl2-install

So it seems wsl itself is still version 2, which requires VMP. The distro is version 1 (fine), but the newer wsl won't run it without VMP. (PS: A reboot did not affect this.)

Arkhaeon commented 4 years ago

@eliotmoss That's odd, I managed to do this yesterday because I needed to use VMWare virtualisation again... Perhaps check to see if you have installed any other distros that are on WSL2 with wsl -l -v.

Might also be worth trying converting your distro back to wsl2 wsl.exe --set-version Ubuntu 2 and back again wsl.exe --set-version Ubuntu 1.

My WSL is definitely working again with Virtual Machine Platform, Hyper-V and Windows Hypervisor platform features all disabled.

eliotmoss commented 4 years ago

Ah! I thought I had revert the Ubuntu distro to version 1, but it was still at version 2. I see a path forward, but I have a long backup running and can't reboot for while to test. I'll edit this comment when I can ...

b-hayes commented 4 years ago

Yeah I tried WSL2 before and hyper-v made my system unstable.

I heard WSL2 didn't need hyper-v anymore and now so tried again but got stuck and now I'm this position. Hyper -v wasn't installed but VMware can no longer run because of something else.

I created a system restore point before setting up but restoring doesn't change anything.

I reversed what I did dism.exe /online /disable-feature /featurename:VirtualMachinePlatform /all /norestart And restarted and still no effect.

I really hate that some feature prevents me from running applications and can't be undone without re-installing windows.

eliotmoss commented 4 years ago

I found that a recent change to Windows mean there is an additional setting I had to change. It seems that some new security features are supported by running the kernel under Hyper-V -- it's called virtualization-based security. I ended up having to go down into bcdedit. I think the entry I change was nx, and I set it to OptIn. This is the no-execute feature (prevent executing instructions fetched from data-only pages), also called DEP (data execution prevention). Then you can turn off Windows Defender Advanced Threat Protections. (Settings->Windows Security->Core Isolation->Memory integrity, and Memory access protection. To make the nx change you mat need to turn Secure Boot off temporarily. In that case, if it is off and your disk it BitLocker encrypted, you'll need the BitLocker key for the drive. This is from memory, but I think it is the setting in question. In any case, the goal is to get the virtualization at boot not done, because that is what turns Hyper-V on, even when you've apparently turned it off. (What we really need is proper virtualization sharing between Windows and VirtualBox, but I don't know if that's in the cards).

Jeoxs commented 3 years ago

From the command shell, run: wsl.exe --set-version Ubuntu 1 From Windows Powershell, run: wsl --set-version Ubuntu 1

This assumes you are using Ubuntu.

This was the solution for me. I'm on Win10 Home insiders preview Build 20226. All ports on WSL were closed. rolling back to WSL 1 solved the issue for me. Thank you!

lucharo commented 3 years ago

None of these options are working for me. When I try to run any variant of wsl --set-version Ubuntu 1 I get:

Error: Oxffffffff
davidljuba15031979 commented 3 years ago
> wsl --set-version Ubuntu 1

Conversion in progress, this may take a few minutes...
Conversion complete.

It successfully uninstalled/downgraded to WSL1.

This fixed my problem related to /mnt folder slowness:

https://github.com/microsoft/WSL/issues/4197

hapticPaper commented 3 years ago

What if the reason for downgrading is to get direct LAN access to the VM? It's my understanding that was possible without proxying in v1 - will setting a distribution to v1 have any effect on the way networking is handled or will I just have a VM running on wsl1 in its virtual network?

ray-johannsson commented 3 years ago

Thank-you!

bananabr commented 2 years ago

Anybody has a working solution to rollback WSL to version 1?

JaimeChavarriaga commented 2 years ago

Anybody has a working solution to rollback WSL to version 1?

Nowadays, Windows installs both versions of WSL. You may set WSL 1 as the default version. If you wanna use VirtualBox without Hyper-V, you may disable Hyper-V.

To instruct Windows to use WSL 1 as the default when a new distro is created

wsl --set-default-version 1 

To modify a distribution to use WSL 1 you may use wsl --set-version <distro name> 1. For instance, to modify a distribution named Ubuntu

wsl --set-version Ubuntu 1

To check which Linux distribution are set to WSL 1 or WSL 2, use the command wsl -l -v.

To disable Hyper-V and use other virtualization software (like VirtualBox) without the Hyper-V hypervisor, you may execute the following as administrator in PowerShell.

Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor
owlstead commented 1 year ago

I think you need to temporarily enable virtualization to be able to downgrade to WSL 1. Let me check...

goshante commented 11 months ago

Don't use this command: wsl --set-version Ubuntu 1 This won't help you if you want to use version 1 before installing distro. Use this command instead, it has global effect: wsl --set-default-version 2

Erich-Chen commented 2 months ago

VirtualMachinePlatform is not required for running WSL 1. You may turn off the feature "VirtualMachinePlatform" after installing a Linux distro with WSL 1.

Now turn off "Memory integrity" in ms-settings and reboot the system. Check in "msinfo32", ensuring Virtualization-Based Security is Not enabled. VMWare Workstation or VirtualBox is happy with your system now, co-existing with WSL 1.