This post will show you how to restore a WSL distribution on a Windows 10 machine using the wsl.exe command line.
In the previous blog post, we learned how to back up a WSL distribution on Windows 10 and now would do the restore.
Import (Restore)
In WSL, a restore operation is called import, and in the below example, I’m restoring my Ubuntu distribution from a backup file. The import process will create a new Linux distribution that will run side by side of the existing one (If it was not deleted).
In the example below, I am calling the restored distribution Ubuntu-20.04-restore
wsl --import Ubuntu-20.04-restore C:\WSL-Backup\ C:\WSL-Backup\ubuntu.tar
After the distribution is restored, I will run the list command
wsl --list Windows Subsystem for Linux Distributions: Ubuntu-20.04 (Default) Ubuntu-20.04-restore
To start I will run
wsl --distribution Ubuntu-20.04-restore
If you are happy with the results, you can make it the default distribution using the command below so when you type WSL, it will start.
wsl --distribution Ubuntu-20.04-restore
If you would like to cleanup and remove the old distribution you can simply run the following command.
wsl --unregister Ubuntu-20.04
my restore logs in as root, how can I make it run in usermode again?