Here is a detailed article on how to install and update WSL2 within a Virtual Desktop (VD) when the network is not available:
Installing and Updating WSL2 within a Virtual Desktop (VD) when the Network is Not Available
When working remotely with a Virtual Desktop (VD), you may encounter situations where you need to install or update the Windows Subsystem for Linux (WSL) 2, but the network is not available. This article will guide you through the process of installing and updating WSL2 within a VD without a network connection.
Prerequisites
Before proceeding, ensure you meet the following prerequisites:
- You have administrative privileges on your VD.
- You have installed the latest version of Windows 10 (version 2004 or later) with the Windows Subsystem for Linux (WSL) feature enabled.
- You have created a Linux distribution (distro) within WSL.
Installing WSL2
-
Open PowerShell as an administrator:
winver | Select-String -Pattern "PowerShell" -Context 1This command will open PowerShell with administrative privileges.
-
Disable the network adapter:
Set-NetAdapter -Name "<Your Network Adapter Name>" -DisableReplace
<Your Network Adapter Name>with the name of your network adapter. You can find the name by runningGet-NetAdapter. -
Install the Linux kernel:
wsl --install -d UbuntuThis command will download and install the latest version of Ubuntu, along with the Linux kernel.
-
Enable the WSL2 feature:
wsl --set-default-version 2This command sets the default WSL version to 2, enabling WSL2.
-
Start your Linux distro:
wsl -d UbuntuThis command starts your Ubuntu distro.
-
Once you have completed your tasks, enable the network adapter again:
Set-NetAdapter -Name "<Your Network Adapter Name>" -Enable
Updating WSL2
-
Open PowerShell as an administrator:
winver | Select-String -Pattern "PowerShell" -Context 1 -
Disable the network adapter:
Set-NetAdapter -Name "<Your Network Adapter Name>" -Disable -
Update your Linux distro:
wsl -d Ubuntu sudo apt update sudo apt upgradeThis command updates your Ubuntu distro.
-
Once you have completed your tasks, enable the network adapter again:
Set-NetAdapter -Name "<Your Network Adapter Name>" -Enable
References
- Install the Windows Subsystem for Linux (WSL) on Windows 10
- Manage network adapters in Windows PowerShell
- Updating WSL2
This article covered the process of installing and updating WSL2 within a Virtual Desktop (VD) when the network is not available. By following these steps, you can work with Linux distros in your VD even when you're offline.