Yes. First, note the URL of the distribution you want to install in this list, ex: https://aka.ms/wslubuntu2204
Now open PowerShell:
# Substitute the drive on which you
# want WSL to be installed if not D:
Set-Location D:
Create a directory for our installation and change to it, we'll call it WSL:
New-Item WSL -Type Directory
Set-Location .\WSL
Make downloads faster by not displaying progress bar:
$ProgressPreference = 'SilentlyContinue'
Using the URL you found above, download the appx package:
Invoke-WebRequest -Uri <appx_package_url> -OutFile Linux.appx -UseBasicParsing
Make a backup and unpack:
Copy-Item .\Linux.appx .\Linux.zip
Expand-Archive .\Linux.zip
Search for the installer:
Get-Childitem -Filter *.exe
You might find a file named <distribution>.exe. Run that file, and the WSL distribution should be installed in the unpack folder of the other drive. If you don't see an executable, let's look for an .appx file that was just unpacked, that is the flavor you want, and unzip that, as follows:
Set-Location Linux
# look for correct appx file:
Get-Childitem -Filter *.appx
# rename to .zip so that Expand-Archive will work
ren .\Ubuntu_2204.1.7.0_x64.appx .\Ubuntu_2204.zip
Expand-Archive .\Ubuntu_2204.zip
Set-Location .\Ubuntu_2204
# Now exe should exist:
Get-Childitem -Filter *.exe
# run it
.\ubuntu.exe
You can now delete everything except ext4.vhdx (for WSL2, rootfs for WSL1), and ubuntu.exe file which starts that distro and can change the default username.
A little curiosity: the process Set-Location, New-Item these thing could have been done in normal commands like cd D:, mkdir WSL ... i mean, why did you suggested these types of commands instead?
– DG_ Jul 30 '20 at 06:44chmod +xbefore execution – Wasif Jul 30 '20 at 09:30I also removed the .zip files to free up space.
– jezzaaaa Jul 25 '22 at 01:18$ProgressPreference = 'SilentlyContinue'– Paul Randleman Mar 04 '23 at 22:31Copy-Item .\Ubuntu_2204.1.7.0_x64.appx .\Ubuntu2204_x64.zipthenExpand-Archive .\Ubuntu2204_x64.zipthen cd into that directory and saw ubuntu.exe and did.\ubuntu.exebut getFailed to attach disk 'D:\wsl\ext4.vhdx' to WSL2: The system cannot find the file specified. Error code: Wsl/Service/CreateInstance/MountVhd/ERROR_FILE_NOT_FOUND Failed to attach disk 'D:\wsl\ext4.vhdx' to WSL2: The system cannot find the file specified.– mLstudent33 May 06 '23 at 12:00Invoke-WebRequestdoes not work for you (proxy, etc.) just download the file using your browser, and proceed with that file. – TFuto Feb 27 '24 at 07:23