在工作过程中,经常因为一些意外造成系统文件被误删或者修改,造成wsl中的ubuntu系统无法启动或者不能进行提权操作,例如误删libcrypto.so,造成提权操作出现
Sorry, try again
Sorry, try again
sudo:3 incorrect password attempts
1、从朋友wsl中导出一个备份文件
wsl --export Ubuntu E:\WSL\Ubuntu.tar
2、本地注册并挂载
#新系统名字UbuntuXX
wsl --import UbuntuXX E:\UbuntuXX E:\WslUbuntuXX\Ubuntu.tar
#将原ubuntu系统盘挂载到新系统
wsl -d UbuntuXX --mount --vhd "E:\WslUbuntu\ext4.vhdx"
#默认挂载到/mnt/wsl/EWslUbuntuext4vhdx,后续进入wsl系统,修复相关文件
wsl -d UbuntuXX
#关闭wsl,重启系统,恢复成功
wsl --shutdown
#注销新系统
wsl --unregister UbuntuXX
其实可以在自己电脑上创建一个空的wsl ubuntu系统,只有在修复时,使用
#将原ubuntu系统盘挂载到新系统
wsl -d UbuntuXX --mount --vhd "E:\WslUbuntu\ext4.vhdx"
#默认挂载到/mnt/wsl/EWslUbuntuext4vhdx,后续进入wsl系统,修复相关文件
wsl -d UbuntuXX
#关闭wsl,重启系统,恢复成功
wsl --shutdown