ubuntu 安装遇到的问题(win11)

1,172 阅读1分钟

ubuntu 安装遇到的问题(win11)

当我打算使用windows在微软app store 中安装ubuntu 的时候,遇到了很多问题,这里记录一下:

image.png

一、问题一

image.png

找了一下,大概就是需要启动windows 的两个服务,然后更新一下wsl 到版本2, 并设置默认版本即可。

1.1 启动两个服务:

打开控制面板:

image.png

程序和功能

image.png

启用或关闭Windows 功能

image.png

第一个

image.png

第二个

image.png

1.2 更新wsl版本

更新 wslwsl2 下载地址

下载之后,直接双击安装。

powershell 中 以管理员身份分别执行两个命令

$ dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
$ dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

如果报错换成这个

$ ./dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
$ ./dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

注意:重要的事情说三次

不要直接在powershell中执行wsl相关的命令

不要直接在powershell中执行wsl相关的命令

不要直接在powershell中执行wsl相关的命令

要执行wsl 相关的命令,需要以管理员身份的运行 cmd:

  1. win+R 输入cmd
  2. ctrl+shift+enter

然后运行以下命令:

$ wsl --set-default-version 2

image.png

然后重新启动 ubuntu 就可以了。

二、问题二:安装nginx 镜像源报错

解决办法,切换镜像

1.备份源文件

通过以下命令对官方源的配置文件进行备份

sudo cp /etc/apt/sources.list /etc/apt/sources.list.old

2.修改源 清华源

sudo vim /etc/apt/sources.list

更改文件为

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse

然后执行

$ sudo npt-get update

问题三: 报错 /usr/lib/wsl/lib/libcuda.so.1 is not a symbolic link

具体的错误忘记截图了,现在解决了不想换回去截图

大概就是就是某个文件不是 一个符号链接

1. 解决

$ cd /usr/lib/wsl  
$ sudo mkdir lib2  
$ sudo ln -s lib/* lib2
$ sudo vim /etc/ld.so.conf.d/ld.wsl.conf

将 /usr/lib/wsl/lib 改为 /usr/lib/wsl/lib2

image.png

测试修改是否生效

$ sudo ldconfig

参考文献

【1】learn.microsoft.com/zh-cn/windo…

【2】zhuanlan.zhihu.com/p/664403552

【3】huaweicloud.csdn.net/63564089d3e…

【4】blog.csdn.net/weixin_4399…