## Listing all WSL2 Distros using Windows Powershell running as Administrator
PS C:\WINDOWS\system32> wsl --list -v
NAME STATE VERSION
* Ubuntu Running 2
docker-desktop Running 2
fedoraremix Running 2
docker-desktop-data Running 2
## Shutdown all WSL2 Distros using Windows Powershell running as Administrator
PS C:\WINDOWS\system32> wsl --shutdown
## Listing all WSL2 Distros using Windows Powershell running as Administrator
PS C:\WINDOWS\system32> wsl --list -v
NAME STATE VERSION
* Ubuntu Stopped 2
docker-desktop Stopped 2
fedoraremix Stopped 2
docker-desktop-data Stopped 2
## Export using Windows Powershell running as Administrator
## EXAMPLE: wsl --export distro_name file_name.tar
PS C:\WINDOWS\system32> wsl --export Ubuntu C:\Shared\WSL2\Backups\Ubuntu.tar
PS C:\WINDOWS\system32> wsl --export fedoraremix C:\Shared\WSL2\Backups\fedoraremix.tar
## Remove old WSL instances
wsl --unregister Ubuntu
wsl --unregister fedoraremix
## Import using Windows Powershell running as Administrator
## EXAMPLE: wsl --import distro_name install_location file_name.tar
wsl --import Ubuntu C:\Shared\WSL2\Ubuntu C:\Shared\WSL2\Backups\Ubuntu.tar
wsl --import fedoraremix C:\Shared\WSL2\fedoraremix C:\Shared\WSL2\Backups\fedoraremix.ta
## Listing backups under /Shared/WSL2/Backups
Shared/WSL2/Backups on ☁️ (us-east-1) on ☁️ [redacted]
❯ ls -lah
rwxrwxrwx 1 kenforeman kenforeman 4 KiB Mon Oct 19 17:01:35 2020 ./
rwxrwxrwx 1 kenforeman kenforeman 4 KiB Mon Oct 19 15:11:51 2020 ../
rwxrwxrwx 1 kenforeman kenforeman 4 GiB Mon Oct 19 16:57:30 2020 Ubuntu.tar
rwxrwxrwx 1 kenforeman kenforeman 2 GiB Mon Oct 19 16:58:46 2020 fedora.tar
rwxrwxrwx 1 kenforeman kenforeman 557 B Mon Oct 19 15:10:28 2020 fedora.png
rwxrwxrwx 1 kenforeman kenforeman 787 B Mon Oct 19 15:09:44 2020 redhat.png
rwxrwxrwx 1 kenforeman kenforeman 560 B Mon Oct 19 15:11:24 2020 ubuntu.png
## From within your Windows PowerShell running as Administrator
PS C:\WINDOWS\system32> choco install lxrunoffline
Chocolatey v0.10.15
Installing the following packages:
lxrunoffline
By installing you accept licenses for the packages.
Progress: Downloading lxrunoffline 3.5.0... 100%
lxrunoffline v3.5.0 [Approved]
lxrunoffline package files install completed. Performing other installation steps.
The package lxrunoffline wants to run 'chocolateyInstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): A
Progress: 100% - Running Microsoft.Dism.Commands.ImageObject
Downloading lxrunoffline
from 'https://github.com/DDoSolitary/LxRunOffline/releases/download/v3.5.0/LxRunOffline-v3.5.0-msvc.zip'
Progress: 100% - Completed download of C:\Users\kenfo\AppData\Local\Temp\lxrunoffline\3.5.0\LxRunOffline-v3.5.0-msvc.zip (2.54 MB).
Download of LxRunOffline-v3.5.0-msvc.zip (2.54 MB) completed.
Hashes match.
Extracting C:\Users\kenfo\AppData\Local\Temp\lxrunoffline\3.5.0\LxRunOffline-v3.5.0-msvc.zip to C:\tools\lxrunoffline...
C:\tools\lxrunoffline
PATH environment variable does not have C:\tools\lxrunoffline in it. Adding...
Environment Vars (like PATH) have changed. Close/reopen your shell to
see the changes (or in powershell/cmd.exe just type `refreshenv`).
The install of lxrunoffline was successful.
Software installed to 'C:\tools\lxrunoffline'
Chocolatey installed 1/1 packages.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
## From within your Windows Command Prompt (cmd.exe)
Microsoft Windows [Version 10.0.19042.572]
(c) 2020 Microsoft Corporation. All rights reserved.
C:\Users\kenfo>lxrunoffline list
Ubuntu-20.04
C:\Users\kenfo>
## From within Windows PowerShell as Administrator
wsl --shutdown
## From within the Windows Command Prommpt (cmd.exe)
lxrunoffline move -n Ubuntu-20.04 -d M:\Shared\WSL2\ubuntu .
## From within Windows PowerShell as Administrator
## Prep shared drive (used for backup, restore, and storage)
cd M:\Shared\
mkdir -p WSL2\Ubuntu
cd M:\Shared\WSL2\Ubuntu
## Export and Unregister (if desired) from WSL
wsl --export Ubuntu ubuntu.tar
wsl --unregister Ubuntu
## Import Distro Name to Target from Backup
wsl --import Ubuntu Ubuntu ubuntu.tar