Export and Import Windows Subsystem for Linux WSL Distro in Windows 10  

    Export and Import Windows Subsystem for Linux WSL Distro in Windows 10

    Export and Import Windows Subsystem for Linux WSL Distro in Windows 10

    How to Export and Import Windows Subsystem for Linux (WSL) Distro in Windows 10
    Published by Category: Apps & Features
    11 Sep 2020
    Designer Media Ltd

    How to Export and Import Windows Subsystem for Linux (WSL) Distro in Windows 10


    The Windows Subsystem for Linux (WSL) is a new Windows 10 feature that enables you to run native Linux command-line tools directly on Windows, alongside your traditional Windows desktop and modern store apps.

    Starting with Windows 10 build 18342 (19H1) and Windows 10 build 18836 (20H1), Microsoft added some new commands that will give you more functionality when using wsl.exe.

    You can now export and import different WSL distros. Exporting a distro is accomplished by passing in --export as an argument and will output a tar file of your current distro. For example, you could use this functionality to share your distro setup with other people. Additionally, if you pass in --import as an argument you can import a tar file that contains the root file system of a Linux distro, which allows you to import any distro you’d like (with any configuration you’d like) as a new distro.

    See also: What’s new for WSL in Windows 10 version 1903?

    This tutorial will show you how to export and import Windows Subsystem for Linux (WSL) distros in Windows 10.

    You will need to have Windows Subsystem for Linux (WSL) enabled to be able to export and import WSL distros in Windows 10.


     CONTENTS:

    • Option One: Export Windows Subsystem for Linux (WSL) Distro in Windows 10
    • Option Two: Import Windows Subsystem for Linux (WSL) Distro in Windows 10
    • Option Three: Uninstall Imported Windows Subsystem for Linux (WSL) Distro in Windows 10





    OPTION ONE

    Export Windows Subsystem for Linux (WSL) Distro in Windows 10


    1. If you haven't already, you will need to perform the following actions to prepare the WSL distro (ex: Debian) you want to export.

    A) Install the WSL distro (ex: Debian) from the Microsoft Store you want to export.

    B) Open this WSL distro (ex: Debian) to finish installing and setup, make any changes you want, and close the distro.

    C) Check for updates in the Microsoft Store app to make sure this WSL distro (ex: Debian) is fully updated, and close the Microsoft Store app when finished.

    2. Open a command prompt.

    3. Copy and paste the command below into the command prompt, and press Enter. This will give you a list of all currently installed WSL distros for the current user. Make note of the WSL distro name (ex: Debian) you want to export. (see screenshot below)

    wsl --list --all

    Export and Import Windows Subsystem for Linux WSL Distro in Windows 10-export_wsl_linux_distro-1.png

    4. Enter the command below into the command prompt, and press Enter. (see screenshot below)

    wsl --export <DistributionName> <Full path to .tar FileName>

    Substitute <DistributionName> in the command above with the actual WSL distro name (ex: "Debian") from step 3 you want to export.

    Substitute <Full path to .tar FileName> in the command above with the full path of the location (ex: "%UserProfile%\Desktop") to where you want to export with the name of the .tar file (ex: "Debian.tar") you want to use.

    For example: wsl --export Debian %UserProfile%\Desktop\Debian.tar


    Export and Import Windows Subsystem for Linux WSL Distro in Windows 10-export_wsl_linux_distro-2.png

    5. When finished, you can close the command prompt if you like.

    6. This .tar file (ex: "Debian.tar") is the export of your custom WSL distro used to import with Option Two below.






    OPTION TWO

    Import Windows Subsystem for Linux (WSL) Distro in Windows 10


    1. Sign in to the account on the Windows 10 PC you want to import the .tar file (ex: "Debian.tar") from Option One for the WSL distro (ex: Debian) you want.

    2. Open a command prompt.

    3. Copy and paste the command below into the command prompt, and press Enter. This will give you a list of all currently installed WSL distros for the current user. (see screenshot below)

    wsl --list --all

    Export and Import Windows Subsystem for Linux WSL Distro in Windows 10-export_wsl_linux_distro-1.png

    4. Enter the command below into the command prompt, and press Enter. (see screenshot below)

    wsl --import <DistributionName> <InstallLocation> <Full path to .tar FileName>

    Substitute <DistributionName> in the command above with the actual WSL distro name (ex: "Debian-Custom") you want to use for this imported WSL distro. This name must be different than any already installed WSL distros listed in step 3.

    Substitute <InstallLocation> in the command above with the full path of the folder (ex: "C:\Data\Debian-Custom") to where you want to install the imported WSL distro.

    Substitute <Full path to .tar FileName> in the command above with the full path of the .tar file (ex: "%UserProfile%\Desktop\Debian.tar") from Option One for the WSL distro you want to import.

    For example: wsl --import Debian-Custom C:\Data\Debian-Custom %UserProfile%\Desktop\Debian.tar


    Export and Import Windows Subsystem for Linux WSL Distro in Windows 10-import_wsl_linux_distro-1.png

    5. When finished, you can close the command prompt if you like.

    6. Whenever you would like to run the imported WSL distro, type the command below into a command prompt or PowerShell. (see screenshot below)

    wsl --distribution <DistributionName>

    Substitute <DistributionName> in the command above with the actual WSL distro name (ex: "Debian-Custom") you want to run. The wsl --list --all command will give you a list of names for all installed WSL distros for the current account.

    Export and Import Windows Subsystem for Linux WSL Distro in Windows 10-import_wsl_linux_distro-2.png






    OPTION THREE

    Uninstall Imported Windows Subsystem for Linux (WSL) Distro in Windows 10


    1. Open a command prompt.

    2. Copy and paste the command below into the command prompt, and press Enter. This will give you a list of all currently installed WSL distros for the current user. (see screenshot below)

    wsl --list --all

    Export and Import Windows Subsystem for Linux WSL Distro in Windows 10-export_wsl_linux_distro-1.png

    3. Enter the command below into the command prompt, and press Enter. (see screenshot below)

    wsl --unregister <DistributionName>

    Substitute <DistributionName> in the command above with the actual WSL distro name (ex: "Debian-Custom") from step 2 you want to uninstall (unregister).

    For example: wsl --unregister Debian-Custom


    Export and Import Windows Subsystem for Linux WSL Distro in Windows 10-uninstall_wsl_distro.png

    4. When finished, you can close the command prompt if you like.


    That's it,
    Shawn






  1. Posts : 2,667
    Windows 11 21H2 (22000.593)
       #1

    I'm assuming that Option 2 only works with exported distros from Option 1, correct?

    Thanks for this (and all the related ones) that you put up today!
      My Computers


  2. Posts : 68,917
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #2

    johngalt said:
    I'm assuming that Option 2 only works with exported distros from Option 1, correct?

    Thanks for this (and all the related ones) that you put up today!

    Hello John,

    That would be correct. Option 2 would need any exported .tar from Option 1.
      My Computers


  3. Posts : 2,667
    Windows 11 21H2 (22000.593)
       #3

    Bummer.

    Wish WSL would allow users to import their own distros....
      My Computers


  4. Posts : 68,917
    64-bit Windows 11 Pro for Workstations
    Thread Starter
       #4

    johngalt said:
    Bummer.

    Wish WSL would allow users to import their own distros....

    If it's a .tar file, you could give it a try.
      My Computers


  5. Posts : 2,667
    Windows 11 21H2 (22000.593)
       #5

    Actually, I just found this:

    Build a Custom Linux Distro for WSL | Microsoft Docs

    Time to play a bit.
      My Computers


 

Tutorial Categories

Export and Import Windows Subsystem for Linux WSL Distro in Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 06:05.
Find Us




Windows 10 Forums