引言

今天发现 xrdp 的日志太大了直接挤满了硬盘,而删除了之后因为 xrdp 仍在使用无法释放空间,所以需要关闭应用并重启。但是重启之后无法登录 (黑屏) 了,所以只好修复一下。

查阅后发现是因为在没有注销的情况下进行了重启[1], 因此针对性解决并优化。

系统版本:Ubuntu 22.04.3 LTS

效果展示

过程

安装并启动 dbus-x11

最重要的事情是安装 dbus-x11 并在 /etc/xrdp/startwm.sh 中加入相关代码[2].

1
2
3
## 安装并启动 dbus-x11
sudo apt install dbus-x11
dbus-launch

修改 startwm.sh

1
sudo vim /etc/xrdp/startwm.sh

Inside the script, add the following line:

在脚本内部,添加以下行:

1
export $(dbus-launch)

Ensure that the line is added before the following lines:

在以下行之前确保添加该行:

1
2
test -x /etc/X11/Xsession && exec /etc/X11/Xsession
exec /bin/sh /etc/X11/Xsession

Save the changes and exit the editor.

保存更改并退出编辑器。

重启 xrdp 服务生效:

1
sudo systemctl restart xrdp

优化

之后是优化 xrdp 的体验,减少卡顿[3].

调整 Xrdp 配置参数:

编辑 /etc/xrdp/xrdp.ini

1
2
tcp_send_buffer_bytes=4194304
tcp_recv_buffer_bytes=6291456

tcp_send_buffer_bytes, tcp_recv_buffer_bytes 两个参数默认被注释了,注释默认值(32768),根据实际情况进行调整。

调整系统参数:

临时生效:

1
2
sudo sysctl -w net.core.rmem_max=12582912
sudo sysctl -w net.core.wmem_max=8388608

重启后保留:

将以下内容写入配置文件 /etc/sysctl.conf:

1
2
net.core.rmem_max = 12582912
net.core.wmem_max = 8388608

然后执行:

1
sudo sysctl -p

重启 xrdp 服务生效:

1
sudo systemctl restart xrdp

结论

引用

  1. 完美方案——解决 XRDP 连接黑屏,以及桌面优化!
  2. Remote Desktop from Windows onto Ubuntu 22.04 takes me to a XRDP login then a blank screen - Ask Ubuntu
  3. Xrdp 体验优化 减少/解决画面卡顿