WSL2Linux Subsystem (4)

WLS2Linux Subsystem Migration/Restore

Following the previous article "WLS2Linux Subsystem Compiles Linux" , this article is to share the migration of WSL to the D drive.
The WSL subsystem is installed behind the C drive by default, and the program installation is easy to explode the "C drive"; migrating to the D drive is a very good choice. After the migration, I found that the original Ubuntu network path is no longer available. If you want to restore it to the original state, please continue reading.

Author: Charcoal Grilled Maodan , click on the blogger to learn more.


提示:操作需谨慎,数据无价。


1. Migrate wsl to drive D

Export ubuntu --> log out of the original Ubuntu --> re-import the D drive

  • Start powershell to view the current Ubuntu version
PS C:\Users\xxxxx> wsl -l -v
  NAME      STATE           VERSION
* Ubuntu    Stopped         2
  • backup ubuntu
wsl --export Ubuntu-20.04 D:\ubuntu.tar
  • log out of Ubuntu
wsl --shutdown
wsl --unregister Ubuntu
  • Import Ubuntu to the D drive
wsl --import Ubuntu D:\WSL D:\ubuntu.tar --version 2

# 启动 wsl
wsl

2. Restore wsl to drive C

The default installation location is C:\User[user_name]\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04LTS_79rhkp1fndgsc\LocalState The
recovery process is the opposite of the installation to the D drive, but the default settings are added. Back up WSL Ubuntu first, then install Ubuntu, and restore the original settings.

  • Backing up Ubuntu
    backup is the same as 1. wsl migration to D drive.

  • install ubuntu

wsl --import Ubuntu C:\User\[user_name]\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04LTS_79rhkp1fndgsc\LocalState --version 2
  • Reset Ubuntu Settings
    Settings --> Applications --> Installed Apps --> Ubuntu
    --> Reset --> Repair/Reset --> WSL Start Ubuntu
# 启动 WSL
wsl

Tips

All the above operations are performed on the PowerShell command terminal. Open as follows:

  1. Start mode "Win" + enter powershell
  2. Desktop "Shift" + right click, select "Open PowerShell window(s) here"

Summarize

It is not in vain that the blogger stepped on the pit and wrote it. Welcome to pay attention to the blogger's charcoal-grilled eggs .

Guess you like

Origin blog.csdn.net/weixin_35723192/article/details/131465760