迁移wsl子系统后报错的解决方法

简介

迁移wsl的博客地址:https://blog.csdn.net/weixin_58045467/article/details/124301843

我是没有执行这一步的,因为执行不了

1
ubuntu1804.exe config --default-user vincent

事情的起因是因为我的C盘容量低于30GB了,我就想是不是这个子系统占了位置,刚好能找到相关迁移的博客帖子,看了一篇比较靠谱的就操作起来,谁知道后面就报奇怪的错误:

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
<3>WSL (11) ERROR: CreateProcessParseCommon:711: Failed to translate C:\Users\20832
<3>WSL (11) ERROR: CreateProcessParseCommon:757: getpwuid(0) failed 2
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\20832\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Git\mingw64\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Git\usr\local\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Git\usr\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Git\usr\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Git\mingw64\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Git\usr\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\20832\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Windows
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Windows\system32
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Windows\System32\Wbem
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Windows\System32\WindowsPowerShell\v1.0
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Windows\System32\OpenSSH
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\WINDOWS
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\WINDOWS\system32
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\WINDOWS\System32\Wbem
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\WINDOWS\System32\WindowsPowerShell\v1.0
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\WINDOWS\System32\OpenSSH
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\dotnet
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Program Files\Docker\Docker\resources\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\ShadowBot
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\XFtp
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Git\cmd
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate E:\pythonEnvs
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\myNodejs\nvm
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\myNodejs\nodejs
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\myNodejs\nodejs\node_global
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate C:\Users\20832\pip\pip.ini
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\python3.10.10
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\python3.10.10\Scripts
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\ShadowBot
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\mongoshall
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\mongodb-windows-x86_64-7.0.7\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\mysql-5.7.38-winx64\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\pyCharm\PyCharm 2024.1.2\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Microsoft VS Code\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\ffmpeg-6.0-essentials_build\bin
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\pandoc\pandoc-3.1.12.1
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\TeXLive\texlive\2023\bin\windows
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Fiddler
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\myNodejs\nvm
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\myNodejs\nodejs
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\myNodejs\nodejs\node_global
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Git\usr\bin\vendor_perl
<3>WSL (11) ERROR: UtilTranslatePathList:2866: Failed to translate D:\Softwares\Git\usr\bin\core_perl
Processing fstab with mount -a failed.
Failed to mount C:\, see dmesg for more details.
Failed to mount D:\, see dmesg for more details.
Failed to mount E:\, see dmesg for more details.

<3>WSL (11) ERROR: CreateProcessEntryCommon:334: getpwuid(0) failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:505: execvpe /bin/sh failed 2
<3>WSL (11) ERROR: CreateProcessEntryCommon:508: Create process not expected to return

我的配置文件设置

wsl的wsl.conf 其位置在:/etc/wsl.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[user]
default = redballoon

[boot]
systemd=true

[network]
hostname=Ubuntu
generateHost=false
generateResolvConf = false

[interop]
enabled = false
appendWindowsPath=false

wsl的.wslconfig文件的配置,其位置在:C:\Users\User

这个配置文件是默认不存在的,需要自己手动添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Settings apply across all Linux distros running on WSL 2
[wsl2]

# Limits VM memory to use no more than 4 GB, this can be set as whole numbers using GB or MB
memory=8GB
swap=2GB
# Sets the VM to use two virtual processors
processors=2


[experimental]
autoMemoryReclaim=dropcache
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

这两个文件的配置都可以在微软的官网找到。

解决方法

找了半天后,看到一篇文章,是让我使用wsl -d Ubuntu-22.04命令来进入系统,虽然这样是成功了,可在迁移系统前都是使用wsl就进入了,这样才符合我的预期。

于是有了接下来的步骤,如果你是卡在这一步,按我的方法就可以改回来。

1
2
3
4
5
6
7
8
9
10
11
~ $ wsl -l -v
NAME STATE VERSION
* Ubuntu-22.04 Stopped 2

~ $ wsl --set-default-version 2
有关与 WSL 2 关键区别的信息,请访问 https://aka.ms/wsl2

操作成功完成。

~ $ wsl --set-default Ubuntu-22.04
操作成功完成。

我是在Git Bash上进行操作的,如果你用的是cmd 或 powershell是一样的操作。


迁移wsl子系统后报错的解决方法
https://redballoom.github.io/posts/迁移wsl子系统后报错的解决方法/
作者
redballoom
发布于
2024年6月15日
许可协议