Setting up a 2-in-1 VM for Labs using Windows Subsystem Linux (WSL)

I am currently preparing a Network Fundamentals training that I’ll be presenting in June and as part of that, I need a VM that I can share with the participants as I’ll be incorporating some hands-on exercises in my presentation. Instead of setting up two different machines, I opted to use a Windows 10 VM and enable the Windows Subsystem Linux (WSL) feature that allows us to run a Linux distribution on the same VM.

My initial setup was based on a Windows 32-bit system but I had to figure out how to upgrade it to a 64-bit system as WSL is only supported on 64-bit systems. Just bear that in mind if you wish to use WSL.

During the setup, I used VMware Fusion. Should I have time, I will show how to do the same on a VirtualBox system. Be sure to download the Windows 10 ISO from the official Microsoft site if you do not have one already.

Table of Contents

  1. Creating a new Windows 10 VM
  2. Installing Windows Subsystem Linux
  3. Installing Linux Ubuntu distribution on windows 10
  4. Setting up Linux for use
  5. References

Creating a new Windows 10 VM

We start off by selecting the option New to create a new VM.

We then import the ISO into VMware Fusion. You can simply drag and drop the ISO file here.

Ensure that the appropriate ISO is selected. In this case, I am using the 64-bit ISO.

Next, we choose the firmware type. I simply go with the default in this case.

And we are ready to run the Installation. You can choose to customise the networking and other options at this point or later after Windows is installed. I prefer to do that later.

Select the appropriate location to store the VM and then start the VM.

I prefer using the US keyboard so there are no changes I made to the language, the times and keyboard.

Click install to start the process.

I do not have a product key so let’s select “I don’t have a product key”. This can be added later if you are using the VM for longer than trial period.

As I had mentioned before, I first installed a 32-bit system and then had to reinstall a 64-bit system. Just to show you the different, I have both screenshots here. x86 architecture refers to the 32-bit system while x64 architecture refers to the 64-bit system.

For WSL, be sure to use 64-bit architecture. It is possible to upgrade a 32-bit system to a 64-bit system but it basically involves reinstallation of the ISO so best to avoid that.

Let’s read and accept the Software License agreement.

Since this is a new installation, the upgrade option will not work. We need to select Custom. If you had a 32-bit system and need to upgrade it to the 64-bit system, them you would go for Upgrade instead.

We will install Windows in the Unallocated space.

Once that is done, the setup process begins.

We can customise the region as we see fit.

Select whichever keyboard layout you wish to use.

I only have one keyboard layout.

The VM will be for personal use and not for an organization so selected the appropriate option.

Next, we need to create a local Administrator account.

The account also requires a password that can be used to sign in.

You also need to provide 3 security questions and answers that will enable you to log back into the VM incase you lost your password. The ones used here are for demo purposes. Put some thought into yours to ensure better security.

I like disabling anything I think unnecessary.

I opt out of Cortana since I do not need it.

And that’s basically it. Next, let’s ensure that we have network connectivity as we will need to install some things.

I’m using Bridged networking. Once the installation is over and everything is installed, I might just want to have it set to Private to my Mac as I will no longer use Internet.

At this point, the VM is ready for login.

Installing Windows Subsystem Linux

There are a couple of features that need to be enabled ignorer to successfully run a Linux Machine in the windows 10 VM. We can enable these features by navigating to Start > Settings > Apps & features > Related settings > Programs and Features.

Let’s enable the feature “Windows Subsystem Linux”.

This can also be done via Powershell by running the following command

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Enabling the feature requires a reboot.

Next, we need to enable the “Virtual Machine Platform” features. This can also be done by navigating to Start > Settings > Apps & features > Related settings > Programs and Features as shown above or via the powershell command line as shown below.

You need to restart the machine again to apply this change.

Since we want to run the latest version of WSL which is WSL2, there is a Linux Kernel update package that needs to be installed this can be obtained from the official Microsoft website.

At this point, it would have been best to set the default WSL Version to version 2. I forgot to do that here and ended up doing it at a later stage. If you have the option, best to do that now.

wsl --set-default-version 2

Installing Linux Ubuntu distribution on windows 10

We are now ready to install our flavour of Linux. Let’s download that from Microsoft Store.

We’ll install the latest stable version Ubuntu 20.04 LTS.

Once we have downloaded the product, we can go ahead and launch it.

This initiates the Installation process. A username and password is required.

As I had mentioned before, I had forgotten to specify the use of WSL2, therefore the Ubuntu instance that I launched was launched as version 1. We can change that using the below command.

wsl --set-version Ubuntu-20.04 2

At this point, Linux system is installed and booted.

Setting up Linux for use

First, let’s ensure that we are running the installed software is up to date. We need to ensure that we have proper date and time, otherwise, the update fails.

sudo apt install ntp 
sudo service ntp restart 

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Using the ifconfig command on PowerShell, we can see the IP address of the windows machine

The Linux instance’s IP address is in the same subnet.

Since this is a lab instance, we can turn off the firewall so as to validate connectivity between the two (you can also opt to add firewall rules to allow the ping if you wish to have Firewall enabled).

The VM is now ready for use. You can install whatever applications you need.

Happy lab-ing!


Windows Subsystem for Linux Installation Guide for Windows 10

How to install Windows Subsystem for Linux (WSL) on Windows 10

How to upgrade from 32-bit to 64-bit version of Windows 10

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s