WSL迁移至其它盘符

WSL迁移至其它盘符

WSL Migration Manual :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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

  1. wsl -l -v 查看 WSL Distros
  2. wsl --export <Distro> <FileName> [Options]将要迁移的 WSL Distro 导出为 tar
  3. wsl --unregister <Distro>卸载 WSL Distro
  4. wsl --import <Distro> <InstallLocation> <FileName> [Options]将 tar 导入到新的 WSL Distro
  5. wsl --set-default <UserName>为 WSL Distro 设置默认用户
  6. wsl -d <Distro>Linux,启动 😎
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# show distributions
┌─  windows   /Desktop   0.081s  RAM 11/13GB 󰅐 5:35 PM Fri  33°C
└  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
┌─  windows   /Desktop   0.046s  RAM 11/13GB 󰅐 5:35 PM Fri
└  wsl --export Arch E:\wsl\Arch.tar
Export in progress, this may take a few minutes.
The operation completed successfully.
# unregister Ubuntu
┌─  windows   /Desktop   58.532s  RAM 9/13GB 󰅐 5:41 PM Fri
└  wsl --unregister Ubuntu-24.04
Unregistering.
The operation completed successfully.
# import from tar
┌─  windows   /Desktop   0.145s  RAM 10/13GB 󰅐 5:44 PM Fri
└  wsl --import Ubuntu e:\wsl\Arch e:\wsl\Arch.tar
Import in progress, this may take a few minutes.
The operation completed successfully.
# set default user
┌─  windows   /Desktop   21.622s  RAM 12/13GB 󰅐 6:00 PM Fri
└  Arch config --default-user efterklang
# launch
┌─  windows   /Desktop   0.182s  RAM 10/13GB 󰅐 6:02 PM Fri
└  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)

└──────────────────────────────────────────────────────────────────────────────┘

● ● ● ● ● ● ● ●
Author

Efterklang

Posted on

2024-05-31

Updated on

2024-09-18

Licensed under

Comments