WSL2 inside Windows 11 inside VirtualBox

Discussions about using Windows guests in VirtualBox.
Post Reply
mverhagen
Posts: 3
Joined: 28. Nov 2024, 06:16

WSL2 inside Windows 11 inside VirtualBox

Post by mverhagen »

Hi,

From what I read it should be possible to run WSL2 with Ubuntu in a Windows 11 VirtualBox VM running on a Windows 11 Host, right?

I've tried everything. In the end, I had to enable Hyper-V on the host PC (so the native Windows 11 installation on my PC). Without enabling this on the host, the Windows 11 VM always got to automatic repair and would not boot to the desktop anymore.

The VirtualBox settings for the Windows 11 VM are:
  • [x] Enable PAE/NX
    [x] Enable Nexted VT-s/AMD-V
    Paravirtualization interface: Hyper-V
    Hardware Virtualization: [x] Enable Nested Paging
With those settings I can enable Hyper-V inside the Windows 11 VM and boot to the Windows 11 desktop without problems. I need WSL2 and can install WSL2 without issues: "wsl --install".

However, when trying to run Ubuntu (which is the default distro being installed in Windows 11 when running wsl --install), I'm getting the following text in the black Ubunto command window:

Code: Select all

Ubuntu is already installed.
Launching Ubuntu...
Installing, this may take a few minutes...
WslRegisterDistribution failed with error: 0x80370102
Please enable the Virtual Machine Platform Windows feature and ensure virtualization is enabled in the BIOS.
For information please visit aka<dot>ms/enablevirtualization
Press any key to continue...
I have visited aka<dot>ms/enablevirtualization and looked at the Hyper-V manager inside the host Windows 11 and the VM Windows 11, but there are no HyperV VMs listed, so the powershell "Set-VMProcessor" command listed there won't work.

The Virtual Machine Platform feature is enabled in the VM (but not on the host OS) and the hypervisorlaunchtype on the VM (and also on the host OS) is set to auto:

Code: Select all

PS C:\Windows\system32> bcdedit /enum | findstr -i hypervisorlaunchtype
hypervisorlaunchtype    Auto
Has anybody got WSL2 going inside a Windows 11 VirtualBox VM running on a Windows 11 Host? If yes; what am I missing or doing wrong?
mverhagen
Posts: 3
Joined: 28. Nov 2024, 06:16

Re: WSL2 inside Windows 11 inside VirtualBox

Post by mverhagen »

I just found this reply "Re: Enable Nested VT-X/AMD-V not working" by by fth0 on 16. Mar 2024, 23:51:
WSL2 needs Hyper-V, and VirtualBox doesn't support Hyper-V als a nested hypervisor. In consequence, you cannot run WSL2 inside a VirtualBox 7.0 Windows 11 VM.
If that still holds true then I have answered my own question...

So, it looks like I should be able to use WSL1 (according to the table at learn<dot>microsoft<dot>com/en-us/windows/wsl/compare-versions).

I'll try that and will report back here (for help to others that may run into the same issue).
mverhagen
Posts: 3
Joined: 28. Nov 2024, 06:16

Re: WSL2 inside Windows 11 inside VirtualBox

Post by mverhagen »

To install WSL1 in Windows 11 (latest version) do as follows:

Set VirtualBox settings to:
System
-- Processor
----- [x] Enable Nexted VT-x/AMD-V
-- Acceleration
----- Paravirtualization Interface: Default
----- Hardware Virtualization: [x] Enable Nested Paging

Make sure Hyper-V is disabled on your host Windows 11 OS (Turn windows features on/off, deselect Hyper-V and restart your PC if you changed this setting).

Now start your Windows 11 VirtualBox VM and open a powershell window as admin once booted into the Windows 11 desktop. Now, instead of executing "wsl --install" (which will install WSL2), execute:

Code: Select all

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
This will install WSL1. After that, restart your VM.

When the VM is booted and back at the desktop, open a Powershell window as admin again and execute the following commands:

Code: Select all

wsl --set-default-version 1
wsl --install -d ubuntu
After the quick install, the Ubuntu window will open with "Installing, this may take a few minutes...". Once done you will have WSL1 with Ubuntu running inside your Windows 11 VirtualBox VM running on your Windows 11 Host.

PS. If the window telling you "Installing, this may take a few minutes..." stays there for longer than say 30 minutes, just start Ubuntu from the Start menu. It did stay very long for me, but apparently Ubuntu was already long installed.
Last edited by mverhagen on 28. Nov 2024, 08:05, edited 1 time in total.
antisa
Posts: 1
Joined: 17. Dec 2024, 14:38

Re: WSL2 inside Windows 11 inside VirtualBox

Post by antisa »

Thanks mverhagen for above writeup!

Just tested this on Ubuntu 22.04 host with Virtualbox 7.0 and Windows 11 vbox evaluation image and it worked!
Post Reply