Export and Import WSL Linux Distro in Windows 10

Windows 10 version 1903 "April 2019 Update" comes with a number of interesting changes and improvements made to the WSL feature. These include additional distros in the Store, the ability to browse WSL files from File Exporer via a virtual network share, and the ability to export and import a WSL distro to/from a TAR file.

The ability to run Linux natively in Windows 10 is provided by the WSL feature. WSL stands for Windows Subsystem for Linux, which initially, was limited to Ubuntu only. Modern versions of WSL allow installing and running multiple Linux distros from Microsoft Store.

Linux Distros Microsoft Store Windows 10

Tip: Here's how to tweak your PC to ensure top performance for a specific type of task, be it gaming, document work or something else.

After enabling WSL, you can install various Linux versions from the Store. You can use the following links:

  1. Ubuntu
  2. openSUSE Leap
  3. SUSE Linux Enterprise Server
  4. Kali Linux for WSL
  5. Debian GNU/Linux

and more.

Export and Import WSL Distros

With Windows 10 version 1903 "April 2019 Update" you can import and export your Linux distros to a TAR file. This will allow you to customize your Linux environment, install desired apps, then export it to a file. Later, you can restore your setup on another PC, or share it with a friend.

This can be done with wsl.exe, a command line tool that allows managing WSL. As of this writing, this feature is implemented in Windows 10 build 18836. It is on its way to the 19h1 branch, so we will see it with the next build.

To export a WSL distro to a file, do the following.

  1. Start the distro you want to export.
  2. Update it, install and configure apps, and make any other changes you want.
  3. Exit the WSL environment.
  4. Open a new command prompt or PowerShell.
  5. Run the following command: wsl.exe --export <DistributionName> <FileName>. Substitute DistributionName with the actual name of your WSL distro, for example, Ubuntu. Replace <FileName> with the full path to the TAR file to store your distro.

Tip: You can see the list of installed WSL distros and their names with the wsl --list --all command.

See the following screenshots.

Windows 10 List Installed Distros

Windows 10 Export WSL Distro

Windows 10 Exported WSL Distro

Import a WSL Distro from a file in Windows 10

You can import a tar file that contains the root file system of a Linux distro, which allows you to import any distro you like, with any configuration you’d like. You can specify any name and a custom folder location to store the customized distro.

To import a WSL distro from a file, do the following.

  1. Open a new command prompt.
  2. Run the following command: wsl.exe --import <DistributionName> <InstallLocation> <FileName>.
  3. Substitute <DistributionName> with the name you want to assign for the distro you are importing.
  4. Substitute <InstallLocation> with the full path to the folder you want to store this WSL distribution.
  5. Replace <FileName> with the full path to your TAR files.

See the following screenshots.

Windows 10 Import WSL Distro

Windows 10 Imported WSL Distro

Windows 10 Imported WSL Distro List

To run the imported distro, issue the following command in the command prompt or PowerShell.

wsl --distribution <DistributionName>

Substitute the <DistributionName>  portion with the name you have assigned to the imported distro.

Windows 10 Run Imported WSL Distro

Finally, to remove an imported Linux distribution, execute the command

wsl.exe --unregister <DistributionName>

For example,

wsl.exe --unregister UbuntuCustom

That's it.

Driver Updater

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.