A series of issues started when I tried to upgrade my Ubuntu 20 WSL2 installation.
After removing my last WSL distribution, I found that installing a new Linux distribution would get stuck and never finish.
Installing a WSL distribution depends on the VirtualMachinePlatform Windows feature. Press Win + R, type:
optionalfeatures
and open Turn Windows features on or off. Make sure VirtualMachinePlatform is enabled.
However, on my machine, the Windows feature installation itself would also get stuck after clicking OK, for the same reason as before.
After some investigation, I found that VBS (Virtualization-Based Security) was running on the system. In theory, disabling Memory Integrity should also disable VBS. However, on my Windows 11 24H2 installation, VBS remained enabled even after Memory Integrity was turned off.
Some guides suggest disabling CPU virtualization (Intel VT-x / AMD SVM) in the BIOS. Unfortunately, my motherboard BIOS does not provide such an option, so I could not try that approach.
As a result, I decided to run a Linux virtual machine directly in Hyper-V instead of using WSL.
Installing Debian
I chose the Debian Netinst image. The ISO is around 700 MB and has relatively low resource usage, making it suitable as a development server.
During installation, simply select Graphical Install.
When you reach the software selection screen, I recommend disabling all desktop environments and selecting only:
- SSH Server
- Standard System Utilities
This results in a lightweight command-line-only server with lower memory usage.
Installing SSH
After Debian is installed, install and start OpenSSH:
sudo apt update
sudo apt install openssh-server
Check the VM's IP address:
ip a
Then connect from Windows Terminal:
ssh username@ip-address
This works, but if you use Hyper-V's default networking, the VM's IP address may change after a reboot. To avoid that, you can configure a static IP address.
Creating a Hyper-V Internal Network
Open:
Hyper-V Manager
→ Virtual Switch Manager
→ New Virtual Network Switch
→ Internal
For example, name it:
VM-Internal
After creating the switch, open the VM settings and attach the virtual network adapter to the new switch.
Note:
Once you switch the network adapter, the existing SSH connection will immediately stop working. It's recommended to complete the Windows networking configuration first and switch the VM network afterward.
Configuring Windows NAT
Open PowerShell as Administrator.
Assign a gateway IP address to the Hyper-V virtual adapter:
New-NetIPAddress `
-IPAddress 192.168.100.1 `
-PrefixLength 24 `
-InterfaceAlias "vEthernet (VM-Internal)"
Create a NAT network:
New-NetNat `
-Name "VM-NAT" `
-InternalIPInterfaceAddressPrefix "192.168.100.0/24"
Configuring a Static IP Address in Debian
Check the network interface name:
ip a
Common interface names include:
eth0
ens160
enp0s3
Edit the network configuration:
sudo nano /etc/network/interfaces
Change:
iface eth0 inet dhcp
to:
iface eth0 inet static
address 192.168.100.10
netmask 255.255.255.0
gateway 192.168.100.1
dns-nameservers 1.1.1.1 8.8.8.8
Restart networking:
sudo systemctl restart networking
Verify the IP address:
ip a
You should now see:
192.168.100.10
Test Internet connectivity:
ping 1.1.1.1
ping google.com
If both commands work, NAT and DNS are configured correctly.
You can now always connect using:
ssh username@192.168.100.10
without worrying about the VM's IP address changing after a reboot.