# How to manually install WSL2 on a Windows 10 Virtual Machine

I finally, finally get `WSL2` to run in a Virtual Machine running on **VMWare Player v17.0.0** after hours and hours of trial and error and research and tons and tons of reading. And that's not the best part, the best part is I also managed to get it working in an air-gapped (offline) environment. I'm so glad that I finally get it to work, and also gained some insights into the various technical aspect of virtualization.

I'm quite sure this will work for most, if not all, scenarios. I will be going through the steps by steps guide, as well as the possible error or issues you may encounter along the way, and how to overcome them (See [troubleshooting section](#heading-troubleshooting)).

> This guide is targeted at an air-gapped environment context where no internet is available within the virtual machine. However, it is also useful for those who want to know how to enable and run nested virtualization within a VM

# Context

I am exploring ways to enable virtualization within a virtual machine (VM) which is also sometimes referred to as nested virtualization.

The diagram below shows an overview of what I am trying to achieve.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670001181582/7d269317-d9ec-4e78-86aa-2f1451dbdac4.png align="center")

1. This is the host machine
    
2. VMWare Player is installed on the host machine where
    
3. I create a Windows 10 virtual machine using VMWare Player
    
4. Within the virtual machine, I want to run WSL2 on it
    

# Challenge

So what's exactly the challenge about getting this to work? Well, before I got it to work, it seems like an impossible task, but after I made it work, it seems like just getting the right pieces together which consist mainly on

* Enable nested virtualization to work on VMWare Player
    
    * Where the host machine is also running virtualization (e.g Hyper-V)
        
* Manual installation of Linux Kernel Package, WSL2, and Linux Distribution (i.e. Ubuntu)
    
* Most importantly, to get it to work in an air-gapped (offline) environment
    

Seem easy enough, ain't it? Let's see how we can do it in this article

# Setup

In my setup, these are the following Operating Systems and Applications versions used at the time of writing.

<table><tbody><tr><td colspan="1" rowspan="1" colwidth="199"><p><strong>Host Machine</strong></p></td><td colspan="1" rowspan="1"><p>Windows 10 x64 Version 22H2 (Build 19045.2251)</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="199"><p><strong>VMWare</strong></p></td><td colspan="1" rowspan="1"><p>VMware® Workstation 17 Player 17.0.0 build-20800274</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="199"><p><strong>Virtual Machine</strong></p></td><td colspan="1" rowspan="1"><p>Windows 10 x64 Version 22H2 (ISO Image build using Windows Media Tool)</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="199"><p><strong>WSL</strong></p></td><td colspan="1" rowspan="1"><p>WSL2 v1.0.0</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="199"><p><strong>WSL Kernel</strong></p></td><td colspan="1" rowspan="1"><p>5.10.16</p></td></tr><tr><td colspan="1" rowspan="1" colwidth="199"><p><strong>Linux Distribution</strong></p></td><td colspan="1" rowspan="1"><p>Ubuntu 22.04 LTS</p></td></tr></tbody></table>

While I used VMWare Player to test it out, this should work for `Oracle VM VirtualBox` or even `Hyper-V` as well

> For 3rd party hypervisors such as VMWare, or VirtualBox. Please ensure it is at least [Version 15.5](https://blogs.vmware.com/workstation/2020/05/vmware-workstation-now-supports-hyper-v-mode.html) and [Version 6.0](https://www.virtualbox.org/wiki/Changelog-6.0) respectively
> 
> For Hyper-V, see [this](https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/user-guide/nested-virtualization)

# Preparation

Since this is based on the assumption of installing and running on an air-gapped environment, you will not have access to the internet within the VM, and these are the installers you will need to download first on the host machine (or elsewhere), and later port into the VM.

| Application | Purpose |
| --- | --- |
| [Windows 10 Installation Media](https://www.microsoft.com/en-au/software-download/windows10) | Prepare Windows 10 x64 22H2 ISO image |
| [VMware Player](https://www.vmware.com/asean/products/workstation-player.html) | Hypervisor to run a virtual machine |
| [WSL](https://github.com/microsoft/WSL/releases) | Windows Subsystem for Linux |
| [WSL2 Linux Kernel Update Package](https://learn.microsoft.com/en-us/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package) | Update Linux Kernel to support WSL2 |
| [Ubuntu 22.04 LTS Distribution](https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions) | WSL Linux distributions |

I won't be going through how to create an image or install VMWare Player, as these are not the focus of this article. There are plenty of great articles out there on how to do those.

My assumption is that you already have VMWare Player installed.

## Enable Virtualization in BIOS

I think at this current time and age, virtualization would be enabled on your BIOS by default, and you probably need not change anything, especially if you are already running some sort of virtualized work on your host machine such as running Hyper-V, Docker Desktop and so on.

Otherwise, you can follow this [excellent guide](https://support.bluestacks.com/hc/en-us/articles/360058102252-How-to-enable-Virtualization-VT-on-Windows-10-for-BlueStacks-5) on how to enable it in your BIOS.

## Disable Hypervisor on host machine

This can be said to be the **most important step** because without disabling the hypervisor on the host machine, VMWare virtual machine **cannot be** configured to use nested virtualization as the option will be greyed out

* Launch terminal with **administrator rights**
    
* Run `bcdedit` and see something along this line
    

```bash
> bcdedit

Windows Boot Loader
-------------------
identifier              {current}
device                  partition=C:
path                    \WINDOWS\system32\winload.efi
description             Windows 10
locale                  en-US
inherit                 {bootloadersettings}
recoverysequence        {61b00ac8-16d1-xxxx-xxxx-xxxxxxxxxxxx}
volumebandid            2
displaymessageoverride  Recovery
recoveryenabled         Yes
isolatedcontext         Yes
allowedinmemorysettings 0x15000075
osdevice                partition=C:
systemroot              \WINDOWS
resumeobject            {61b00ac6-16d1-xxxx-xxxx-xxxxxxxxxxxx}
nx                      OptIn
bootmenupolicy          Standard
hypervisorlaunchtype    Auto
```

* Focus on the last item - `hypervisorlaunchtype`
    
    * We need to set this to `off` by running the following command
        

```bash
bcdedit /set hypervisorlaunchtype off
```

* It does not provide any sort of feedback to indicate that the changes is made
    
* After running the command, reboot your machine manually
    

If you look around enough, there will be various other ways to achieve `nested virtualization` but in my opinion, this method should be the least intrusive and most easy. Why? Because you only need to run a single command and reboot your host machine and it does (should) not cause any side-effect to your existing virtualization software or tools or configuration.

What this command does is essentially disable the hypervisor (i.e. `Hyper-V`) from running on the host machine, and allow VMWare to enable `nested virtualization`

This is how it looks like on my host machine

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670136600790/g_90BSMRN.gif align="center")

Everything is still intact

What this means is that you can't use Hyper-V, Docker Desktop or any other virtualization stuff on your host machine while allowing nested virtualization to happen. But it also means that whenever you do not need to use nested virtualization, you can simply run the following command to disable it and you can continue to use virtualization stuff on your host machine.

```bash
bcdedit /set hypervisorlaunchtype auto
```

With that, we are all set to create our VM, install Windows 10 OS, and WSL2

# Steps

## Creating Virtual Machine

* Launch VMWare Player
    
* Click `Create a new Virtual Machine`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670041831980/ec5650f4-845f-42ee-8023-6047763309a5.png align="center")
    
* Browse to the `iso file` and click `Next >`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670041893530/cdd79817-ad94-4f21-b03b-875d3dd64e51.png align="center")
    
* Give your virtual machine a name and click `Next >`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670041946353/be3ab827-0e47-4e05-b4dd-fbcd4b07f376.png align="center")
    
* Click `Next >` when asked for `Disk Capacity`. The default is `60GB`
    
* Click on `Customize Hardware`
    
    * **Memory**: Adjust your memory as you wish, I do recommend at least `4GB`
        
    * **Processors**: Check `Virtualize Intel VT-x/EPT or AMD-V/RVI` to allow for nested virtualization
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670042786160/d76aa3f8-5de0-4eb8-bf43-e561c7c562a4.png align="center")
        
        > This is the most important step, ensure that this option is checked. If this section is greyed out, ensure you have done the preparation, or go through the troubleshooting guide
        
    * **Network Adapter**: Uncheck `Connect at power on` to simulate an offline environment
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670042758500/f9110217-80b9-4bc7-9f5f-98b367167f4d.png align="center")
        
* Click `Close` once done
    
* Click `Finish` to start the creation of the virtual machine. It will auto-power on right after the creation
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670042604193/fa9f044a-f1ed-46dc-aa6f-155e0a33379c.png align="center")
    
* Continue with the installation of **Windows 10**
    

## Installing Windows 10 OS

I will not go through the step-by-step for this section, only highlight certain parts to take note of during the installation

* Select `Windows 10 Pro` when prompted
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670043176837/8d9e14be-c73d-4851-8536-288419fe6613.png align="center")
    
* Select `I don't have internet`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670043631995/d504acd3-1c04-4d97-b474-415543330626.png align="center")
    
* Select `Continue with limited setup`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670043678479/6470daf2-bfe8-4a6d-be22-f2fbb32ef009.png align="center")
    

## Post OS Installation

There are a couple of things we need to do before the actual installation of WSL2

### VMWare Tools

This is not exactly required to run WSL2, but more to improve your experience while managing virtual machine(s) and more seamless interaction

* Select `Player > Manage > Install VMWare Tools...`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670044283825/633f3708-0b49-485f-9021-70003306f278.png align="center")
    
* It will then be mounted as a drive within the VM
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670044404507/63df29d6-f4f7-4888-a857-44829daac4ab.png align="center")
    
* Double-click to launch it
    
* Follow the screen instruction to install it
    
    * Select `Complete` setup type when prompted
        
* Restart VM after installation is completed
    

### Copy files to VM

Since we are working in offline mode, we have to copy files from the host machine to the VM by simply dragging the files from the host machine directory into the VM directory as shown in the gif below.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670046129295/136b6179-5923-4708-85d7-e98eb6b47a26.gif align="center")

You will only require the following files for the rest of the guide

* Microsoft.WSL\_1.0.0.0\_x64\_ARM64.msixbundle
    
* Ubuntu2204-221101.AppxBundle
    
* wsl\_update\_x64.msi
    

> Your filename may differ if you came from the future, as the version number will likely be different

## Installing WSL2

Now that we have the required files within the VM, we can now start the actual installation of WSL2.

> If you are working on an internet-enabled machine, you can simply run `wsl --install` which will enable the necessary components, update the kernel, and install `Ubuntu` as the default Linux distribution

### Windows Features

First, let's take a look at the current state of the `Windows Features` inside our VM

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670160123491/jHzGWO-7w.png align="center")

The two key components are now unchecked

* Virtual Machine Platform
    
* Windows Subsystem for Linux
    

> WSL is now [generally available](https://devblogs.microsoft.com/commandline/the-windows-subsystem-for-linux-in-the-microsoft-store-is-now-generally-available-on-windows-10-and-11/) (GA) in Windows Store since 22 Nov 2022

### Enable WSL component

* Launch `PowerShell` as administrator
    
* Run `dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670146124087/YY1vfbR1w.png align="center")
    

### Enable Virtual Machine Platform

* Run `dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670146228389/o21sAMJcb.png align="left")
    
* Reboot your machine
    

### Install Linux Kernel Package

* Navigate to the directory where the files are located at
    
* Double-click on `wsl_update_x64.msi`
    
* Follow on-screen instruction
    
* After installed, run `wsl --status`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670146676384/NH5UymAj7.png align="left")
    
    > The kernel version at the time of writing is **5.10.16**
    

### Install WSL 2

* Launch `PowerShell` as administrator
    
* Navigate to the directory where the files are located at
    
* Run `Add-AppxPackage .\Microsoft.WSL_1.0.0.0_x64_ARM64.msixbundle`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670063569228/b5943c3d-9b29-4baa-9474-32f48f8da6d7.png align="center")
    

### Set default WSL version

* Run `wsl --set-default-version 2`
    

## Install Ubuntu 22.04 LTS

\[Update 7th Jan 2023\]: Please follow the instructions [here](https://bwgjoseph.com/a-better-way-to-install-windows-app-bundle-file-in-offline-machine) to extract the necessary files and install Ubuntu, and ignore the steps below

* \[continue from above\]
    
* Run `Add-AppxPackage .\Ubuntu2204-221101.AppxBundle`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670064373698/857413b7-d988-4c62-b6a9-3418caeb8bb5.png align="center")
    
* Once completed, follow the instruction [here](#heading-unable-to-launch-ubuntu-post-installation) to gain access to the `WindowsApp` directory (I'll wait)
    
* Once you have gained access and copied the files
    
* Navigate to the directory
    
* Double-click on `ubuntu.exe`
    
* Follow the on-screen instruction to finish the rest of the setup
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670070449311/bad0d105-c20c-468b-94ca-eb078541575e.gif align="center")
    

> While the workaround works, you cannot launch it via the `Start Menu` but you can pin it to the taskbar, or create a shortcut on your desktop to launch it

Congratulations! You have completed all the steps necessary to reach the goal we set at the start.

# Conclusion

I hope that this article helps someone else who is looking into performing manual installation of WSL2 on a virtual machine in an air-gapped environment and sharing solutions to overcome some of the issues you may face along the way.

Give a thumbs-up if you find this article useful.

---

# Troubleshooting

## Virtualized Intel VT-x/EPT is not supported on this platform

I have previously encountered an issue where I disabled all four components of the `Windows Features`, and I can check `Virtualize Intel VT-x/EPT or AMD-V/RVI` in VMWare VM Settings but yet it still complains something along this line when the VM is starting

```bash
Virtualized Intel VT-x/EPT is not supported on this platform.

Continue without virtualized Intel VT-x/EPT?
```

The solution is simply going into BIOS and triggering a "reset" of the virtualization setting. All thanks to the following [comment](https://github.com/microsoft/WSL/issues/5363#issuecomment-699467732) buried within a sea of comments and issues all around the internet

## Unable to launch Ubuntu post installation

If you run the following command `Add-AppxPackage .\Ubuntu2204-221101.AppxBundle` to install the Ubuntu distribution but

* it did not show any installed distro after running `wsl -l -v`
    
    ```bash
    PS C:\wsl> wsl -l -v
    Windows Subsystem for Linux has no installed distributions.
    Distributions can be installed by visiting the Microsoft Store:
    https://aka.ms/wslstore
    ```
    
* You cannot launch it via the Start Menu
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670068136460/719452b5-b78f-4f25-acc0-072f3414648c.gif align="center")
    

I hope this will help to solve your issue.

So what happened? I believe this has to do with permission somehow due to manual installation. If we look at the windows event logs, we can find the following error

```bash
0x800704CF: Cannot create the process for package CanonicalGroupLimited.Ubuntu_2204.1.7.0_x64__79rhkp1fndgsc because an error was encountered while preparing for activation.
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670068646546/e203eaff-ad4d-44ee-ad2f-e2e59b755256.png align="center")

And if you attempt to launch via the installer file, you will encounter the following error

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670068757321/0e18edf8-62fd-4a52-a442-312801014ba7.gif align="center")

After some google searches, I finally landed on a workaround mentioned [here](https://github.com/microsoft/WSL/issues/3020#issuecomment-604589190) and [here](https://github.com/microsoft/WSL/issues/2577#issuecomment-344583203) which is to copy the ubuntu directory to another location (i.e. `C:\`)

However, if you attempt to access `C:\Program Files\WindowsApp`, you will encounter yet another error

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670069143816/731f9f56-c81c-4646-b985-c1e02b55d16c.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670069166815/072686d6-3c7b-4bb8-80a3-34eac85804a8.png align="center")

Follow the [instruction](https://www.makeuseof.com/windows-access-windowsapps-folder/) listed under `1. How to Access WindowsApps via File Explorer` should suffice. Once you gain access to the `WindowsApp` directory, copy `CanonicalGroupLimited.Ubuntu_2204.1.7.0_x64__79rhkp1fndgsc` directory to `C:\` (or any other location of your choice)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670069674451/60640fd6-96da-43d9-9d42-5a46f7e02556.gif align="center")

> Remember to head back to [installing-ubuntu-2204-lts](#heading-install-ubuntu-2204-lts) if you came from there and continue the rest of the instruction

## Missing WSL optional component

If you attempt to launch WSL right after installation, and you may face the following error

```bash
This application requires the Windows Subsystem for Linux Optional Component.
The system may need to be restarted so the changes can take effect.
Press any key to continue...
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1670063660051/1c462c23-b2f1-4178-9ad5-a70ff222a15f.png align="center")

That means exactly what the error message said, where the WSL optional component is not enabled yet. So make sure you follow the instruction listed [here](#heading-windows-features) to enable the WSL component.

## WSL 2 Kernel file is not found

If you ran `wsl --status` and you get the following message

```bash
Default Version: 2

The Windows Subsystem for Linux kernel can be manually updated with 'wsl --update', but automatic updates cannot occur due to your system settings. To receive automatic kernel updates, please enable the Windows Update setting: 'Receive updates for other Microsoft products when you update Windows'. For more information please visit https://aka.ms/wsl2kernel.

The WSL 2 kernel file is not found. To update or restore the kernel please run 'wsl.exe --update'
```

Double-click on `wsl_update_x64.msi` to update the kernel and then run `wsl --status` again and you should see the following now.

Notice the kernel version is now showing as `5.10.16`

```bash
Default Version: 2

Windows Subsystem for Linux was last updated on 3/12/2022
The Windows Subsystem for Linux kernel can be manually updated with 'wsl --update', but automatic updates cannot occur due to your system settings.
To receive automatic kernel updates, please enable the Windows Update setting: 'Receive updates for other Microsoft products when you update Windows'.
For more information please visit https://aka.ms/wsl2kernel.

Kernel version: 5.10.16
```

# References

* [WSL Troubleshooting Guide](https://learn.microsoft.com/en-us/windows/wsl/troubleshooting#installation-issues)
    
* [WSL Manual Install](https://learn.microsoft.com/en-us/windows/wsl/install-manual)
    
* [VMWare nested virtualization explained](https://www.nakivo.com/blog/vmware-nested-virtualization-explained-use-cases-and-tutorial/)
    
* [VMWare now supports Hyper-V mode](https://blogs.vmware.com/workstation/2020/05/vmware-workstation-now-supports-hyper-v-mode.html)
