title: Is this the correct way to Import a WSL export, overwriting "default" installation?
body: <p>I have created a WSL (version 1) Ubuntu 20.04 distro which I have exported, as a backup.  I have made some changes to the original distro and want to revert back to export.</p>
  <p>The original distro install is called: Ubuntu-20.04</p>
  <pre><code>wsl --list
  </code></pre>
  <p>Output:</p>
  <pre><code>Windows Subsystem for Linux Distributions:
  Ubuntu-20.04 (Default)
  </code></pre>
  <p>The installation folder for Ubuntu is the default folder from installation:</p>
  <pre><code>C:\Users\&lt;my user name&gt;\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_xxxxx
  </code></pre>
  <p>(I've changed the user name and UID)</p>
  <p>I've looked at the import and export options and I can import the exported file into a new folder easily:</p>
  <pre><code>wsl --export Ubuntu-20.04 c:\temp\wcc-ubuntu-20-04-wsl.tar
  wsl --import Ubuntu-20.04-New c:\wsl\ubuntu-new wcc-ubuntu-20-04-wsl.tar
  </code></pre>
  <p>That then appears in the list available:</p>
  <pre><code>wsl --list
  </code></pre>
  <p>Output:</p>
  <pre><code>Windows Subsystem for Linux Distributions:
  Ubuntu-20.04 (Default)
  Ubuntu-20.04-New
  </code></pre>
  <p>If I want to use the &quot;new&quot; import I have to first set the default, then open access it from the command line:</p>
  <pre><code>wsl --setdefault Ubuntu-20.04-New
  wsl -d Ubuntu-20.04-New -u myusername
  </code></pre>
  <p>If I use the Ubuntu icon in the start menu, it seems to ignore the &quot;new&quot; default and will open the original install.  Not a problem, I can always start WSL from command line if needed.</p>
  <p>I then looked into how to import over the original default install.  My research showed that you can delete a distro using the &quot;unregister&quot; option, then import the file again to same location.  So I ran the unregister command:</p>
  <pre><code>wsl --unregister Ubuntu-20.04
  </code></pre>
  <p>However, when I try the import again, setting the target to the setup folder I got issues with the folder is not empty.</p>
  <pre><code>C:\Users\&lt;my user name&gt;\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_xxxxx\LocalState
  </code></pre>
  <p>Having looked at an imported WSL it only has two folders:</p>
  <ul>
  <li>rootfs</li>
  <li>temp</li>
  </ul>
  <p>Following a unregister the rootfs folder is removed entirely and the temp remains.  To overwrite the destination you have to delete the temp folder.  Looking back at the original install folder these two folders exist under the &quot;LocalState&quot; subfolder.  So I manually deleted these two folders.</p>
  <p>I was then able to perform an import to the original folder.  I was able to start the WSL via command line and also via the ubuntu icon in the start menu.  The only thing I noticed was the command prompt had defaulted to the &quot;root&quot; user.</p>
  <pre><code>root@xxxxxxx:~#   
  </code></pre>
  <p>I am able to login as the correct user with the switch users &quot;su&quot; command.</p>
  <pre><code>su - myusername
  myusername@xxxxxxx:~#
  </code></pre>
  <p>I haven't fully tested the imported WSL to make sure it does everything it needs.  Not found any errors.</p>
  <p>My worry is that this may cause issues I haven't seen down the line.  I did read several posts and blogs that explicitly say don't change any files in the install folder.  I was hoping that someone else out there has wanted to do the same thing and has no issues, done something different or found issues with the approach I have used.</p>
  <p>I appreciate you taking time to ready this and any comments or advice.</p>