【MBJC】windows11 wsl2 配置Linux子系统 安装 Ubuntu22.04 配置gnome GUI(方法一:VcXsrv,方法二:xrdp远程控制)

【MBJC】windows11 wsl2 配置Linux子系统 安装 Ubuntu22.04 配置gnome GUI

由于需要在ROS2进行深度强化学习的训练,原有的VMware虚拟机不行,微软wsl2自带的GUI分体式用着不爽,坑很多,无奈只得硬刚。

wsl2配置较简单,这里不再赘述,详见官方链接: https://learn.microsoft.com/en-us/windows/wsl/install

在powershell中输入
wsl --install

注意开启虚拟机需要的功能

在这里插入图片描述

Microsoft Store下载Ubuntu 22.04.3LTS

Microsoft Store下载Ubuntu 22.04.3LTS

设置用户名和密码

在这里插入图片描述

wsl2默认保存在C盘,管理员下启动poweshell依次输入命令修改Ubuntu子系统储存在E盘

wsl -l --all -v
wsl --export Ubuntu-22.04 E:/wsl-ubuntu-22.04.tar
wsl --unregister Ubuntu-22.04
wsl --import Ubuntu-22.04 E:/wsl-ubuntu-22.04 E:/wsl-ubuntu-22.04.tar --version 2
ubuntu2204 config --default-user mbjc

在这里插入图片描述

换阿里源(可选)

# 备份原来的软件源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
# 编辑软件源
sudo nano /etc/apt/sources.list
# 注释原软件源加入内容
deb https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse

# deb https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse

deb https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src https://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

wsl2 不支持 systemd 而 gnome 桌面又是基于 systemd,git clone如果网络不行也可下载下来,拖进去。

sudo apt update && sudo apt upgrade
git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh

在这里插入图片描述

重启ubuntu终端,输入以下命令(安装时间较长,可能受网络影响需要魔法科学上网)Unable to install certain systemd reliant packages/start services 问题参考链接: https://github.com/microsoft/WSL/discussions/9350

sudo apt-mark hold acpid acpi-support
sudo apt install ubuntu-desktop

方法一:结合VcXsrv就可以使用了,VcXsrv安装与配置,参考链接: https://blog.csdn.net/weixin_44478077/article/details/128723158

sudo service dbus restart
sudo nano ~/.bashrc
#输入
export DISPLAY=$(grep -m 1 nameserver /etc/resolv.conf | awk '{print $2}'):0.0
export XDG_SESSION_TYPE=x11

source ~/.bashrc
gnome-session

在这里插入图片描述

方法二:xrdp远程控制(Windows专业版)参考链接: https://ishwarjagdale.github.io/wslWithGUI/http://681314.com/A/3yH5k7dyyV

sudo apt-get install xrdp
sudo cp /etc/xrdp/xrdp.ini /etc/xrdp/xrdp.ini.bak
sudo sed -i 's/3389/3390/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/max_bpp=32/#max_bpp=32\nmax_bpp=128/g' /etc/xrdp/xrdp.ini
sudo sed -i 's/xserverbpp=24/#xserverbpp=24\nxserverbpp=128/g' /etc/xrdp/xrdp.ini
echo "gnome-session" > ~/.xsession
sudo nano /etc/xrdp/startwm.sh
#注释两行并加
# test -x /etc/X11/Xsession && exec /etc/X11/Xsession
# exec /bin/sh /etc/X11/Xsession
gnome-session

sudo systemctl restart xrdp
sudo systemctl status xrdp
# 管理员启动powershell
# 停止服务
net stop LxssManager
# 启动服务
net start LxssManager

sudo /etc/init.d/xrdp start

在这里插入图片描述
在这里插入图片描述

just enjoy yourself!

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值