vagrant icon indicating copy to clipboard operation
vagrant copied to clipboard

Allow for use with nested virtualization in WSL2

Open AskAlice opened this issue 3 years ago • 3 comments

this applies to windows 11 and i think windows 10 21H1. Regardless it's harmless to push this feature out now. by setting the VAGRANT_WSL_NESTED_VIRTUALIZATION environment variable, users can set up vagrant as if they were running vagrant on a standard linux box. With the latest kernel for WSL2 in windows insiders edition, nested virtualization (and even native GUI support) are available. This allows users to use libvirt/kvm. Therefore this environment variable will allow people to set up vagrant to pretend it's not on WSL.

I wrote an article here on running virtualbox inside of WSL2 using nested virtualization, and using this patch to bypass the wsl checks. https://askalice97.medium.com/running-virtualbox-inside-of-wsl2-with-nested-virtualization-bde85046fe8d

AskAlice avatar Apr 27 '21 01:04 AskAlice

CLA assistant check
All committers have signed the CLA.

hashicorp-cla avatar Apr 27 '21 01:04 hashicorp-cla

any word on this? I was able to build a wsl2 kernel that could run virtualbox

it required some combination of

CONFIG_MODULES=y
CONFIG_MODULE_SIG=n
CONFIG_SECURITY_LOADPIN=n
CONFIG_SECURITY_LOCKDOWN_LSM=n

config_module_sig kept getting set to y so I manually removed the if check so module_sig_check would always return 0 in kernel/module.c:2786

then after building the kernel i had to ensure i ran

sudo make -j $(nproc) modules_install

and once that was done just updated %userprofile%.wslconfig to use the new kernel image, installed virtualbox-6.1, and was done

AskAlice avatar Jul 02 '21 07:07 AskAlice

I hope it will not bother: I took the liberty to up this ticket because I suppose running Vagrant inside WSL2 can work around its slowness on Windows #11853. It would tremendously improve user experience! Thanks @AskAlice for your investigations!

rbuquet avatar Jun 13 '22 14:06 rbuquet

This would be a fantastic addition.

Nebucatnetzer avatar Aug 03 '23 10:08 Nebucatnetzer