Exporting and importing a WSL distro
If you have invested time in setting up a WSL distro, you may wish to be able to copy it to another machine. This could be because you are replacing or reinstalling your machine, or maybe you have multiple machines and want to copy a configured distro to a second machine rather than setting up the distro from scratch. In this section, we will look at how to export a distro to an archive file that can be copied to another machine and imported.
Let's start by preparing the distro for exporting.
Preparing for exporting
Before we export a distro, we want to make sure that the default user for the distro is set in the /etc/wsl.conf
file inside the distro (you can read more about wsl.conf
in Chapter 2, Installing and Configuring the Windows Subsystem for Linux, in the Introducing wsl.conf and .wslconfig section). By doing this, we can ensure that WSL still uses the correct default user for our distro after we have imported it later.
Open...