Backing up your WSL Distro and Copying it to another PC

In our last article we talked about Moving an install WSL Distro from it awful install folder to another drive and path. So let’s make a back up of that distro, and then install it on a different PC.

Using our new favorite tool LxRunOffline let’s make back up of a distro on our PC.

However, as one starts down the path of using LxRunOffline, there is a slight issue when it comes to WSL2 Distros:

lxrunoffline export -n openSUSE-Leap-15-1 -f suse.tar.gz
[ERROR] The action/argument “export” doesn’t support WSL2.

Ok, not a huge problem… this article just got longer…. LxRunOffline export will work for WSL 1 type Distros… So let’s do an example of both using LxRunOffline and WSL utilities.

For WSL 1 type Distros:

LxRunOffline has a command called List- from a Powershell window my list looks like this

LxRunOffline.exe list


Now the LX tool has a command to do a backup. This collects the distro into a Linux tar file (in Linux terms a compressed tape file).

LxRunOffline export n <NameOfDistro> –f <pathAndNameOfExportFile>

That’s the general format of the export.

Now before one goes about exported a Distro – I would really do a WSL –shutdown Why? I think it’s best not to have any Distro’s running when you are trying to export them. It’s not a 100% required, but it is a good practice.

For WSL 2 type Distros:

Still do the WSL –shutdown.

Now we use the WSL command to backup the Distro. Like the LX tool, WSL has basically the same set of commands.
Get a list of Distros with:

wsl --list
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)

And the backup command for WSL:

wsl --export WLinux .\PengWin.tar.gz


    Directory: D:\cse.Linux

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          10/17/2020 12:46 PM     9039769600 PengWin.tar.gz

Now we have in either case a copy of our Distro that can be imported on another PC with WSL.

When using WSL.exe


--import <Distro> <InstallLocation> <FileName> [Options]
        Imports the specified tar file as a new distribution.
        The filename can be - for standard input.

            --version <Version>
                Specifies the version to use for the new distribution.

The –import command  Allows one to name the Distro, install to a location, from a filename. The options here, –version allows one to change the WSL version while it’s being imported.

Now LXRunOffline is a little different:

lxrunoffline install

  -n arg                Name of the distribution
  -d arg                The directory to install the distribution into.
  -f arg                The tar file containing the root filesystem of the
                        distribution to be installed. If a file of the same
                        name with a .xml extension exists and "-c" isn't
                        specified, that file will be imported as a config file.
  -r arg                The directory in the tar file to extract. This argument
                        is optional.
  -c arg                The config file to use. This argument is optional.
  -v arg (=2)           The version of filesystem to use, latest available one
                        if not specified.
  -s                    Create a shortcut for this distribution on Desktop.

As we see the install command has a few more options beyond Name, Directory, and tar filename.

Happy WSL’ing,

Prev Article: Moving your installed WSL Linux Distro

Go Back to Index of WSL articles


Leave a Reply