WSL迁移至其它盘符
WSL Migration Manual
BASH
Usage: wsl.exe [Argument] [Options...] [CommandLine]Arguments for managing distributions in Windows Subsystem for Linux: --export <Distro> <FileName> [Options] Exports the distribution to a tar file. The filename can be - for stdout. Options: --vhd Specifies that the distribution should be exported as a .vhdx file. --import <Distro> <InstallLocation> <FileName> [Options] Imports the specified tar file as a new distribution. The filename can be - for stdin. Options: --version <Version> Specifies the version to use for the new distribution. --vhd Specifies that the provided file is a .vhdx file, not a tar file. This operation makes a copy of the .vhdx file at the specified install location.
Commands
wsl -l -v
查看 WSL Distroswsl --export <Distro> <FileName> [Options]
将要迁移的 WSL Distro 导出为 tarwsl --unregister <Distro>
卸载 WSL Distrowsl --import <Distro> <InstallLocation> <FileName> [Options]
将 tar 导入到新的 WSL Distrowsl --set-default <UserName>
为 WSL Distro 设置默认用户wsl -d <Distro>
Linux,启动 😎
SHELL
# show distributions$ wsl -l -v NAME STATE VERSION* docker-desktop-data Stopped 2 Ubuntu-24.04 Running 2 docker-desktop Stopped 2 Arch Running 2# export to tar$ wsl --export Arch E:\wsl\Arch.tarExport in progress, this may take a few minutes.The operation completed successfully.# unregister Ubuntu$ wsl --unregister Ubuntu-24.04Unregistering.The operation completed successfully.# import from tar$ wsl --import Ubuntu e:\wsl\Arch e:\wsl\Arch.tarImport in progress, this may take a few minutes.The operation completed successfully.# set default user$ Arch config --default-user efterklang# launch$ wsl -d Arch ff gjx@Efterklang I use Arch BTW(●ˇ∀ˇ●) ┌──────────────────────────────────────────────────────────────────────────────┐ ▄ OS ➜ Arch Linux 20240101.0.204074 x86_64 ▟█▙ │ ├ Kernel ➜ Linux 5.15.146.1-microsoft-standard-WSL2 ▟███▙ │ ├ Packages ➜ 190 (pacman) ▟█████▙ │ └ Shell ➜ fish 3.7.1 ▟███████▙ LM ➜ login (TTY) ▂▔▀▜██████▙ │ ├ Terminal ➜ WezTerm 20240203-110809-5046fc22 ▟██▅▂▝▜█████▙ PC ➜ Windows Subsystem for Linux - Arch ▟█████████████▙ │ ├ CPU ➜ AMD Ryzen 7 5800H (16) @ 3.19 GHz ▟███████████████▙ │ ├ GPU ➜ NVIDIA GeForce RTX 3060 Laptop GPU (5.87 GiB) [Discrete] ▟█████████████████▙ │ ├ GPU ➜ AMD Radeon(TM) Graphics (1.98 GiB) [Integrated] ▟███████████████████▙ │ ├ Disk ➜ 2.09 GiB / 1006.85 GiB (0%) - ext4 ▟█████████▛▀▀▜████████▙ │ ├ Disk ➜ 165.95 GiB / 200.00 GiB (83%) - 9p ▟████████▛ ▜███████▙ │ ├ Disk ➜ 101.74 GiB / 275.69 GiB (37%) - 9p ▟█████████ ████████▙ │ ├ Disk ➜ 166.97 GiB / 475.45 GiB (35%) - 9p ▟██████████ █████▆▅▄▃▂ │ ├ Memory ➜ 793.43 MiB / 6.71 GiB (12%) ▟██████████▛ ▜█████████▙ │ ├ Swap ➜ 0 B / 2.00 GiB (0%) ▟██████▀▀▀ ▀▀██████▙ │ ├ Uptime ➜ 7 seconds ▟███▀▘ ▝▀███▙ Local IP ➜ 113.54.240.64/19 ▟▛▀ ▀▜▙ Public IP ➜ 89.116.88.203 (Tokyo, JP) └──────────────────────────────────────────────────────────────────────────────┘ ● ● ● ● ● ● ● ●
WSL迁移至其它盘符