WSL2 There was only a steady way to get Ubuntu20.04 back to WSL1

Overview

I tried migrating Ubuntu 20.04 of WSL1, but I reverted to the original because of the following problems.

result

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.

Procedure: If you did not export when migrating to WSL2

It is for reference only. I have recovered from the failed procedure, so I haven't actually tried it.

  1. Open WSL Close Terminal, VS-Code and other editors, Explorer, etc.
  2. wsl --export Ubuntu-20.04 ./Ubuntu.tar
  3. wsl --import Ubuntu-20.04-WSL2 .\Ubuntu-20.04-WSL2 Ubuntu.tar --version 2
  4. Reinsert Ubuntu-20.04 in WSL1
  5. Migrate files from Ubuntu-20.04-WSL2 with tar

Reference: Failed procedure

  1. Check the status

    PS C:\wsl_migration> wsl -l --verbose
      NAME            STATE           VERSION
    * Ubuntu-20.04    Running         2
    PS C:\wsl_migration> 
    
  2. 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>
    
  3. Export

    PS C:\wsl_migration> wsl --export Ubuntu-20.04 ./Ubuntu.tar
      NAME            STATE           VERSION
    * Ubuntu-20.04    Stopped         2
    PS C:\wsl_migration>
    
  4. 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> ```

  1. 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>
    
  2. Reinstall Ubuntu-20.04 If there is a link in the Windows menu, you can click it or install it from the Store. image.png

** 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>
```
  1. 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>
    
  2. 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> ```

  1. 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.

reference

Recommended Posts

WSL2 There was only a steady way to get Ubuntu20.04 back to WSL1
A note when I was addicted to converting Ubuntu on WSL1 to WSL2
How to get JDK 11 on your mac in a comfortable way
Resultset's next () was misunderstood as a method to determine if there is a next