1. 创建虚拟显示器—必须是Intel集成显卡。包含VirtualHeads功能。AMD不用考虑。如果是独显,请关闭独显使用集成显卡。另外需要安装intel开源驱动。
2. 创建虚拟显示器的配置文件
root@srv1:~# vim /usr/share/X11/xorg.conf.d/20-intel.conf
Section “Device”
Identifier “intelgpu0”
Driver “intel”
Option “VirtualHeads” “1”
EndSection
3. 打开终端,输入xrandr命令,查看是否存在VIRTUAL开头的显示器
root@srv1:~# xrandr
Screen 0: minimum 8 x 8, current 3520 x 1200, maximum 32767 x 32767
LVDS1 connected primary 1600×900+0+0 (normal left inverted right x axis y axis) 310mm x 170mm
1600×900 59.97*+ 59.82
1440×900 59.89
1400×900 59.96 59.88
1368×768 60.00 59.88 59.85
1360×768 59.80 59.96
1280×800 59.81 59.91
1152×864 60.00
1280×720 59.86 60.00 59.74
1024×768 60.00
1024×576 60.00 59.90 59.82
960×540 60.00 59.63 59.82
800×600 60.32 56.25
864×486 60.00 59.92 59.57
800×450 60.00
640×480 59.94
720×405 59.51 60.00 58.99
640×360 59.84 59.32 60.00
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
4. 获取平板显示器所需分辨率—-请查询自家平板的最高支持分辨率
root@srv1:~# cvt 1920 1200
# 1920×1200 59.88 Hz (CVT 2.30MA) hsync: 74.56 kHz; pclk: 193.25 MHz
Modeline “1920x1200_60.00” 193.25 1920 2056 2256 2592 1200 1203 1209 1245 -hsync +vsync
5. 为VIRTUAL1生成新的分辨率模式—将第4步的Modeline后面的内容复制
root@srv1:~# xrandr –newmode “1920x1200_60.00” 193.25 1920 2056 2256 2592 1200 1203 1209 1245 -hsync +vsync
6. 向虚拟显示器添加分辨率
root@srv1:~# xrandr –addmode VIRTUAL1 “1920x1200_60.00”
“`
7. 调整虚拟显示器与笔记本显示器-LVDS1的位置—笔记本显示器请按实际名称对应
# 笔记本在左侧,虚拟显示器在右侧
root@srv1:~# xrandr –output LVDS1 –left-of VIRTUAL1 –auto
# 笔记本在右侧,虚拟显示器在左侧侧
root@srv1:~# xrandr –output LVDS1 –right-of VIRTUAL1 –auto
8. 检查虚拟显示器是否开启
root@srv1:~# xrandr
Screen 0: minimum 8 x 8, current 3520 x 1200, maximum 32767 x 32767
LVDS1 connected primary 1600×900+0+0 (normal left inverted right x axis y axis) 310mm x 170mm
1600×900 59.97*+ 59.82
1440×900 59.89
1400×900 59.96 59.88
1368×768 60.00 59.88 59.85
1360×768 59.80 59.96
1280×800 59.81 59.91
1152×864 60.00
1280×720 59.86 60.00 59.74
1024×768 60.00
1024×576 60.00 59.90 59.82
960×540 60.00 59.63 59.82
800×600 60.32 56.25
864×486 60.00 59.92 59.57
800×450 60.00
640×480 59.94
720×405 59.51 60.00 58.99
640×360 59.84 59.32 60.00
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
VGA1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 connected 1920×1200+1600+0 (normal left inverted right x axis y axis) 0mm x 0mm
1920x1200_60.00 59.88*
VIRTUAL2 disconnected (normal left inverted right x axis y axis)
9. 安装x11vnc
root@srv1:~# apt install x11vnc
10. 配置并启动x11vnc
# 如果想设置密码–不想设置可忽略
root@srv1:~# x11vnc -storepasswd
#x11vnc所用的参数说明
-rfbport:指定了连接所用的端口,默认为5900也可以自行设置。
-clip:该命令设置x11vnc映射屏幕的范围,可以使用-clip WxH+X+Y来手动设置映射范围,也可以使用-clip xinerama0来自动映射显示器,其中xinerama0为屏幕设置中从左往右数第一个显示器,以此类推xinerama1为第二个,如果你的主屏幕在左边虚拟屏幕在右边,那如果设置为xinerama0就会将主屏幕的显示内容复制到虚拟屏幕上,也就是两个屏幕的内容一样了,这时就应该设置为xinerama1。
-wait:是两次屏幕抓取的时间间隔,默认为 20 ms 效果比较卡顿,设置为 1 的话会尽可能降低抓取时间减少延迟。
-defer:向vnc客户端发送更新的间隔,默认也为 20 ms,设置为 1 可以尽可能提高发送频率(但对网速的要求就高了)。
-nowf:在移动窗口到虚拟屏幕时显示内容,否则会显示为一个框。
-sb:设置休眠时间,默认为 60s 也就是如果屏幕 60s 内没有活动的话就停止数据传送,这样会导致有时鼠标从主屏移动到虚拟屏幕时会卡顿,设置为 0 后就不会休眠了。
# 启动x11vnc—虚拟化显示器在左侧输出
root@srv1:~# x11vnc -rfbport 5900 -clip xinerama0 -wait 1 -defer 1 -nowf -sb 0 &
# 启动x11vnc—虚拟化显示器在右侧输出
root@srv1:~# x11vnc -rfbport 5900 -clip xinerama1 -wait 1 -defer 1 -nowf -sb 0 &
11. 在Android平板上安装并使用bvnc或其他vnc连接Linux的5900端口
12. 无网络情况下使用USB连接Linux
root@srv1:~# apt install adb android-tools-adb android-tools-fastboot
# 通过adb反向代理,使平板通过USB连接
root@srv1:~# adb reverse tcp:5900 tcp:5900
13. 在Android平板上安装并使用bvnc或其他vnc,通过USB连接localhost:5900端口