How to Export and Import Your Linux Systems on Windows 10

Linux Tux Penguin on Windows 10 Desktop WallpaperLarry Ewing

Windows 10 now allows you to export installed Linux environments, creating a TAR file of the root file system that you can import to other PCs. Copy your configured systems between computers, share them with others, or simply backup a backup.

How it works

The import and export functions have been added in the Updated May, 2019Windows 10 version 1903. If you have not installed it yet, you will not be able to use these command-line options.

You need two new options for the Windows command wsl: –export and –import. The –export option will export the root file system of a Linux distribution as a TAR file. The –import option allows you to import the root file system of a Linux distribution as a TAR file.

RELATED: How to install and use the Linux Bash Shell on Windows 10

How to export (back up) a Linux system

The wsl command is a Windows command – wsl.exe. You will have to run it in a PowerShell environment or a command prompt, and not in a Windows for Linux environment. You can open one by right-clicking the Start button or pressing Windows + x and clicking "Windows PowerShell".

To list the installed distributions, run the following command:

wsl –list

Now, use the following command to export the file system of a distribution into a TAR file:

wsl –export distro_name filename.tar

For example, to export the Ubuntu 18.04 system to a file named ubuntu.tar, run the following command:

wsl –export Ubuntu-18.04 ubuntu.tar

Exporting a WSL Environment in PowerShell

You now have a TAR file containing the file system of the Linux distribution. The file we created – based on a fairly standard Ubuntu 18.04 LTS system – was 645 MB in size. If you have installed more software in your distribution, these will be larger.

TAR file of a Linux environment created by Windows 10

How to import (restore) a Linux system

You can use the wsl command with the –import option to import a TAR file created in this way. In a PowerShell or Command Prompt window, run the following command.

wsl –import distro_name installation_location filename.tar

Suppose, for example, that you want to import a distribution of a TAR file located in C: Users Chris Ubuntu.tar, call it "Ubuntu-18.04" and store it in C: Users Chris Ubuntu . You would run:

wsl –import Ubuntu-18.04 C: Users Chris Ubuntu C: Users Chris ubuntu.tar

If you want to match the locations where Windows normally installs them by default, they are usually in their own folder in C: Users NAME AppData Local Packages. For example, you might want to put Ubuntu in C: Users NAME AppData Local Packages Ubuntu.

Wherever you place the installation location, note that you should not modify the files directly from Windows tools. Here's how to access files in File Explorer.

Importing a Linux TAR File into PowerShell

How to unregister (delete) a Linux system

You can uninstall a distribution with the –unregister option with its name. This will delete all files from the Linux distribution.

Use the following command to see all installed distributions:

wsl –list

Then specify the distribution you want to delete:

wsl –unregister distro_name

For example, if it's called Ubuntu-18.04, you will run:

wsl –unregister Ubuntu-18.04

Canceling the Registration or Removal of a Linux Environment from the Windows 10 Command Line

This feature also allows you to quickly and easily move installed distributions to another folder or drive. Simply export the distribution to a TAR file, cancel it from your system, and then import the TAR file to another location on your system.

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.