Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for use with nested virtualization in WSL2 #12328

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AskAlice
Copy link

@AskAlice AskAlice commented Apr 27, 2021

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

@hashicorp-cla
Copy link

hashicorp-cla commented Apr 27, 2021

CLA assistant check
All committers have signed the CLA.

@AskAlice
Copy link
Author

AskAlice commented Jul 2, 2021

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

@rbuquet
Copy link

rbuquet commented Jun 13, 2022

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!

@Nebucatnetzer
Copy link

This would be a fantastic addition.

@schwanberger
Copy link

+1. Please do this. I would like to think something like this would have been done merged long ago if @mitchellh was still at the helm!

Since it's quite a chore to compile vagrant every now and then, I've decided to just do a custom compile of my WSL kernel to not include the substring "microsoft".

See this excellent blog post for more information: https://blog.sampath.dev/building-the-wsl2-linux-kernel-yourself

@ngttuc
Copy link

ngttuc commented Dec 26, 2024

Any chance for this to be merged? I really need this for my use case within the company. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants