I tried migrating Ubuntu 20.04 of WSL1, but I reverted to the original because of the following problems.
There was only a steady method. Therefore, when migrating to WSL2, I think it is better to export and try it in the newly created environment.
It is for reference only. I have recovered from the failed procedure, so I haven't actually tried it.
wsl --export Ubuntu-20.04 ./Ubuntu.tar
wsl --import Ubuntu-20.04-WSL2 .\Ubuntu-20.04-WSL2 Ubuntu.tar --version 2
Ubuntu-20.04
in WSL1Ubuntu-20.04-WSL2
with tarCheck the status
PS C:\wsl_migration> wsl -l --verbose
NAME STATE VERSION
* Ubuntu-20.04 Running 2
PS C:\wsl_migration>
Close the terminal or VS-Code
After closing, make sure it is Stopped
PS C:\wsl_migration> wsl -l --verbose
NAME STATE VERSION
* Ubuntu-20.04 Stopped 2
PS C:\wsl_migration>
Export
PS C:\wsl_migration> wsl --export Ubuntu-20.04 ./Ubuntu.tar
NAME STATE VERSION
* Ubuntu-20.04 Stopped 2
PS C:\wsl_migration>
Unregister Distribution
PS C:\wsl_migration> wsl --unregister Ubuntu-20.04
Unregistered... PS C:\wsl_migration> wsl -l --verbose The distribution is not installed on the Windows subsystem for Linux. The distribution visits the Microsoft Store and installs Can be: https://aka.ms/wslstore PS C:\wsl_migration> ```
Start PowerShell as an administrator and set the default version of WSL to 1.
PS C:\WINDOWS\system32> wsl --set-default-version 1
PS C:\WINDOWS\system32>
Reinstall Ubuntu-20.04 If there is a link in the Windows menu, you can click it or install it from the Store.
** Introducing **
```
PS C:\wsl_migration> wsl -l --verbose
NAME STATE VERSION
Ubuntu-20.04 Installing 1
PS C:\wsl_migration>
```
** Installation completed **
```
PS C:\wsl_migration> wsl -l --verbose
NAME STATE VERSION
* Ubuntu-20.04 Running 1
PS C:\wsl_migration>
```
Import
wsl --import <uncovered NAME> <Destination of LocalState (rootfs, etc.)> <Path of exported tar file> --version 1
.
PS C:\wsl_migration> wsl --import Ubuntu-20.04-WSL1 C:\Users\RoboDev\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows Ubuntu.tar --version 1
PS C:\wsl_migration> wsl -l --verbose
NAME STATE VERSION
* Ubuntu-20.04-WSL1 Stopped 1
PS C:\wsl_migration>
Start Start with the following command or Windows Terminal. failed. failed. failed.
PS C:\wsl_migration> wsl -d Ubuntu-20.04-WSL1
Server execution failed PS C:\wsl_migration> ```
Start PowerShell as an administrator and recover
The wsl -l --verbose
command freezes, and unregister also terminates with an error, so recover.
PS C:\WINDOWS\system32> Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Since a reboot was requested, execute the following command after the reboot.
```
PS C:\WINDOWS\system32> dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
```
If Ubuntu remains in the application and function, delete it
```
PS C:\WINDOWS\system32> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
```
Delete it with wsl --unregister Ubuntu-20.04-WSL1
.