ubuntu18.04安装虚拟显示器,不接显示器可远程桌面



主机配置

  • 系统:Ubuntu 18.04
  • 显卡:Intel 集成显卡

启用远程控制

注意,如果 teamviewer 是有登录账号,通过账号链接,那么有无上文的 Ubuntu 自带的远程桌面控制关系不大。
如果 teamviewer 是通过输入随机生成的密码,或者是通过主机点击“接收/确认”来允许远程桌面控制链接的话,那么当然必须要有 Ubuntu 的远程桌面控制服务在运行,先通过 VNC-Viewer 链接控制;获得密码或者点击接收,然后 teamviewer 才能链接上。

为什么要使用 Teamviewer 而不是自带的远程桌面控制软件? – 因为 Teamviewer 在速度上比较快(传输桌面图像的时候会压缩数据再在网络上传输)。
即使是都在局域网下,Teamviewer 也比较快。


安装软件和支持

安装使 Ubuntu 使用虚拟显示器的软件:

$ sudo apt-get install  xserver-xorg-core-hwe-18.04
$ sudo apt-get install  xserver-xorg-video-dummy-hwe-18.04  --fix-missing

修改/创建配置文件(默认就会使用虚拟显示器):

$ sudo vim /usr/share/X11/xorg.conf.d/xorg.conf
Section "Device"
    Identifier  "Configured Video Device"
    Driver      "dummy"
EndSection
Section "Monitor"
    Identifier  "Configured Monitor"
    HorizSync 31.5-48.5
    VertRefresh 50-70
EndSection
Section "Screen"
    Identifier  "Default Screen"
    Monitor     "Configured Monitor"
    Device      "Configured Video Device"
    DefaultDepth 24
    SubSection "Display"
    Depth 24
    Modes "1920x1080"
    EndSubSection
EndSection
~
~
~
:wq
$

注意:虽然配置上面写了 “1920x1080”,但是实际上最大支持 "1360x768"

n/a

如何使支持 1920x1080 暂时还不清楚;觉得 1360x768 已经够用,所以就没有深究。

支持 1920x1080 见下文 Reference 3.

重启就可以生效


其它

相关命令:

xrandr: 在使用虚拟显示器之后,使用 xrandr 命令查看显示器信息如下(这个显示结果和原始使用实体显示器略有不同):

xrandr -q 
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 320 x 240, current 1360 x 768, maximum 1360 x 768
default connected primary 1360x768+0+0 0mm x 0mm
   1360x768      60.00* 
   1280x720      60.00  
   1024x768      60.00  
   1024x576      60.00  
   960x540       60.00  
   800x600       60.00    56.00  
   640x480       60.00  
   684x384       60.00  
   680x384       60.00  
   640x360       60.00  
   512x384       60.00  
   512x288       60.00  
   480x270       60.00  
   400x300       60.00    56.00  
   320x240       60.00

     
     
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19

Xvfb: X Virtual Framebuffer
在自动化测试等方面可能会考虑使用 Xvfb 来创建虚拟显示器。
具体用法非本文范围。


注意事项

重启之后即使接入了显示器,也不会输出信号到显示器上!
但是通过 VNC-Viewer 与在未按照本文安装软件和修改配置文件前一模一样可以链接到 Ubuntu 主机上,进行“远程”桌面控制



Reference

  1. How to use Ubuntu 18.04 on VNC without display attached?
  2. Add Fake Display when No Monitor is Plugged In
  3. How to run X server using xserver-xorg-video-dummy driver on Ubuntu
发布了63 篇原创文章 · 获赞 7 · 访问量 3396

猜你喜欢

转载自blog.csdn.net/weixin_44523062/article/details/105405019