WSL因fstab挂载失败无法启动,寻求技术解决方案
WSL Ubuntu启动失败:挂载错误与getpwuid/execvpe报错
我是认真的,为什么没人回答这个问题
由于此前Windows更新出现严重问题,已经两年没有使用WSL了,现在启动Ubuntu时出现以下错误,试过YouTube教程无法解决:
Microsoft Windows [Version 10.0.19045.3930] (c) Microsoft Corporation. All rights reserved. C:\Users\user>wsl -l -v NAME STATE VERSION * Ubuntu Stopped 1 C:\Users\user>wsl Processing fstab with mount -a failed. Failed to mount C:\, see dmesg for more details. Failed to mount I:\, see dmesg for more details. Failed to mount K:\, see dmesg for more details. Failed to mount L:\, see dmesg for more details. <3>WSL (9) ERROR: CreateProcessEntryCommon:331: getpwuid(0) failed 2 <3>WSL (9) ERROR: CreateProcessEntryCommon:502: execvpe /bin/sh failed 2 <3>WSL (9) ERROR: CreateProcessEntryCommon:505: Create process not expected to return C:\Users\user>wsl Processing fstab with mount -a failed. Failed to mount C:\, see dmesg for more details. Failed to mount I:\, see dmesg for more details. Failed to mount K:\, see dmesg for more details. Failed to mount L:\, see dmesg for more details. <3>WSL (9) ERROR: CreateProcessEntryCommon:331: getpwuid(0) failed 2 <3>WSL (9) ERROR: CreateProcessEntryCommon:502: execvpe /bin/sh failed 2 <3>WSL (9) ERROR: CreateProcessEntryCommon:505: Create process not expected to return C:\Users\user>
设备配置:
- Windows 10 Pro Build 22H2(近期已更新)
- Intel Celeron 1005M 1.90GHz处理器
- 8GB DDR3内存
- 存储设备:
- Lexar 256GB SSD
- I-O DATA SSPH-UA SCSI磁盘驱动器
- 内置Ubuntu磁盘镜像与数据的KIOXIA TransMemory 32GB U盘
- Intel Dual Band Wireless-N 7260无线网卡
- 集成显卡:Intel HD Graphics
修复步骤
临时绕过挂载错误启动
执行以下命令跳过fstab挂载和初始化脚本,直接启动bash:wsl --exec bash --noprofile --norc成功进入shell后,编辑
/etc/fstab,注释掉所有指向Windows盘符(如C:\、I:\)的挂载行(在行首添加#):sudo nano /etc/fstab保存退出后,关闭并重启WSL:
exit wsl --shutdown wsl修复root用户与shell关联
如果无法通过上述命令进入shell,尝试以root身份启动:wsl -u root进入后执行以下操作:
- 检查
/bin/sh是否存在,若不存在则创建软链接:ln -s /bin/dash /bin/sh - 确认
/etc/passwd中root条目正常,若缺失则添加:echo "root:x:0:0:root:/root:/bin/bash" >> /etc/passwd
- 检查
迁移分发版到本地SSD
由于Ubuntu镜像存储在U盘,可能存在文件系统损坏或权限问题。先备份当前分发版:wsl --export Ubuntu D:\ubuntu_backup.tar卸载旧分发版:
wsl --unregister Ubuntu将备份导入到本地SSD路径:
wsl --import Ubuntu C:\WSL\Ubuntu D:\ubuntu_backup.tar --version 1设置默认用户(替换为你原有的用户名):
ubuntu config --default-user your_username升级到WSL2(推荐)
确认BIOS中已开启Intel VT-x虚拟化,然后执行命令升级:wsl --set-version Ubuntu 2WSL2采用虚拟机架构,文件系统稳定性更强,能有效避免WSL1的挂载与权限问题。
内容的提问来源于stack exchange,提问作者noteswiper_lb787-747
相关产品推荐
相关产品推荐

