4

The Windows Subsystem for Linux (WSL) is installed using the "Turn on or off Windows features" wizard. After turning this feature on, when invoking Bash For Windows for the first time, it claims to be downloading software from Microsoft Store. Is it possible to create some bundle containing all necessary files for WSL installation and make Windows install WSL using these files in an environment with no internet connection? If so, How?

3
  • @Ramhound: That's kind of the point of OP's question, though. Does it require Internet access specifically, or can it be fed the same files through another way, pre-downloaded? Commented Aug 29, 2016 at 13:15
  • According to slightfuture.com/technote/lxss-lxrun , the subsystem (and some .ico file) is downloaded from Microsoft. I wonder if I can trick the system to download from a localhost server holding those two files, using the HOSTS file, maybe. Commented Sep 6, 2016 at 6:44
  • 2
    Use this app from GitHub LxRunOffline.
    – Biswapriyo
    Commented Aug 8, 2017 at 16:30

2 Answers 2

5

Installing a Linux Distribution without internet connection

You can (1) download the installer from the Windows Store or (2) download a distribution file and install it using tools such as lxRunOffline. If you have the distribution file you can make the installation copying the files using a USB drive or something else.


Downloading the installer from the Windows Store

You can download the installers from the Windows Store using Powershell. For instance, you can download the Ubuntu 16 version using the following command

PS> Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile Ubuntu.appx -UseBasicParsing

In the above command, the output file is Ubuntu.appx. It must be named in that way. You can run that application to install the Ubuntu.

PS> Ubuntu.appx

Using LxRunOffline

First, you must download some distribution file. There are many distribution files available in the lxRunOffline wiki.

For instance, to install the same Ubuntu 16 from the Microsoft Windows Store, you can download the file at

https://lxrunoffline.apphb.com/download/UbuntuFromMS/16

Then, you can install the linux distribution using lxRunOffline

# lxrunoffline install -n <name> -d <folder> -f <distribution file>

C:\wsl> lxrunoffline install -n copy -d c:\wsl\copy -f 16.04.2-server-cloudimg-amd64-root.tar.gz

To run the distribution, you may use the same lxRunOffline

C:\wsl> lxrunoffline run -n copy -w

Using a DistroLauncher

You can use some DistroLauncher. There are many versions based on the Microsoft example to create custom linux distributions for WSL. For instance, you can use the Yuk7 version.

You must download a distribution file and the launcher.exe. You must rename the distribution file to rootfs.tar.gz and the launcher to the distribution name you want. Later you must run the launcher as an Administrator (I got errors running it as a normal user)

PS> ren launcher.exe mydistro.exe
PS> ren .\16.04.2-server-cloudimg-amd64-root.tar.gz rootfs.tar.gz
PS> .\mydistro

The first time you run the launcher, it installs and run the distribution. The next time, it runs the linux distribution.


After installing, you can manage the distributions using the wslconfig or the lxrunoffline commands.

1

After you setup Windows for WSL, you will need to install a suitable WSL Linux distribution.

You will find instructions on off-line installations of WSL Linux distributions in the WSL docs at https://learn.microsoft.com/en-us/windows/wsl/install-manual.

Note, however, since a WSL distribution comes as a Windows Store app package, you will need a license to activate the app. If your computer does not have an internet connection, the app will not start when you attempt to run it, as Windows cannot acquire a license. The Windows event log will contain an error event giving you details.

Essentially, you will need both the APPX package and a license file to do a true off-line installation and activation of a WSL Linux distribution. This requires a Microsoft Business account, from which you can obtain the required app license file. To install WSL and activate it, you should not use the PowerShell cmdlet Add-AppxPackage, but the cmdlet Add-AppxProvisionedPackage with the option -Online, while providing both the package and license file.

A workaround for a true off-line installation, is to not install a WSL distribution app package, but to setup and export a WSL instance from a computer with Internet connection, and then import the image on the target system. For details, see https://learn.microsoft.com/en-us/windows/wsl/enterprise#creating-a-custom-wsl-image.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .