Hardware Tech for Fun

无头机上启用核显加速的虚拟屏幕供远程使用

参照网上的教程与问AI,之前断断续续配置了几次都没有成功。今天因为dummy的一个分辨率问题,再次尝试使用显卡加速的虚拟屏幕,终于成功。

机器较特殊,是一台没有屏幕,没有任何外接屏幕接口的,N5095平台的笔记本电脑。

vi /etc/default/grub

...
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash i915.enable_psr=0 i915.force_probe=4e55 acpi_mask_gpe=0x6F video=HDMI-A-2:D drm.edid_firmware=HDMI-A-2:edid/edid.bin"
...

其中,acpi_mask_gpe=0x6F是屏蔽机器的大量中断占用cpu。其它都是为了核显上的虚拟屏幕。

sudo update-grub
sudo reboot

如果还没有起作用,尝试安装Xvfb,但并不需要启用。

sudo apt install xvfb

如果还不成功,尝试启用VKMS

sudo modprobe vkms enable_cursor=1 num_outputs=1
echo "options vkms enable_cursor=1 num_outputs=1" | sudo tee /etc/modprobe.d/vkms.conf
sudo update-initramfs -u
export DISPLAY=:0
xrandr

此时,核显上的虚拟屏幕很可能已经有了。可以使用vnc或rustdesk来远程连接了。

注:连接上的是核显上的虚拟EDID模拟的屏幕,显卡加速的,而不是VKMS的cpu渲染的虚拟屏幕。

bamboo@Fly5095:~$ glxinfo | grep "OpenGL renderer"
OpenGL renderer string: Mesa Intel(R) UHD Graphics (JSL)
bamboo@Fly5095:~$ inxi -Gxx
Graphics:
  Device-1: Intel JasperLake [UHD Graphics] driver: i915 v: kernel
    arch: Gen-11 ports: active: HDMI-A-2 empty: DP-1,HDMI-A-1 bus-ID: 00:02.0
    chip-ID: 8086:4e55
  Display: x11 server: X.Org v: 21.1.11 with: Xwayland v: 23.2.6
    compositor: xfwm4 v: 4.18.0 driver: X: loaded: modesetting dri: iris
    gpu: i915 display-ID: :0.0 screens: 1
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96
  Monitor-1: HDMI-A-2 mapped: HDMI-2 pos: primary model: AOC U2790B
    res: 1920x1080 dpi: 82 diag: 685mm (27")
  Monitor-2: Virtual-1 mapped: Virtual-1-1 note: disabled size-res: N/A
  API: EGL v: 1.5 platforms: device: 0 drv: iris device: 1 drv: swrast gbm:
    drv: iris surfaceless: drv: iris x11: drv: iris inactive: wayland
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: intel mesa
    v: 25.0.7-0ubuntu0.24.04.2 glx-v: 1.4 direct-render: yes renderer: Mesa
    Intel UHD Graphics (JSL) device-ID: 8086:4e55
  API: Vulkan v: 1.3.275 surfaces: xcb,xlib device: 0 type: integrated-gpu
    driver: N/A device-ID: 8086:4e55 device: 1 type: cpu driver: N/A
    device-ID: 10005:0000
bamboo@Fly5095:~$ echo $DISPLAY
:0.0
bamboo@Fly5095:~$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
HDMI-1 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-2 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 597mm x 336mm
   1920x1080     60.00*+  50.00    59.94  
   1920x1080i    60.00    50.00    59.94  
   1680x1050     59.95  
   1280x1024     75.02    60.02  
   1440x900      59.89  
   1280x960      60.00  
   1280x720      60.00    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x480       60.00    59.94  
   640x480       75.00    72.81    66.67    60.00    59.94  
   720x400       70.08  
Virtual-1-1 connected (normal left inverted right x axis y axis)
   1920x1080     60.00 +
   1024x768      60.00 +
   4096x2160     60.00    59.94  
   2560x1600     59.99    59.97  
   1920x1440     60.00  
   1856x1392     60.00  
   1792x1344     60.00  

连上的是上面的HDMI-2而不是Virtual-1-1。

附上我成功连上虚拟屏幕的最后几条命令,部分是不需要的,仅备忘。

 
 1090  xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
 1091  sudo rustdesk --get-id
 1092  sudo systemctl restart rustdesk


 1093  xrandr --listmonitors
 1094  xrandr --addmode Virtual-1 1920x1080
 1095  echo $DISPLAY
 1096  Xvfb :1 -screen 0 1920x1080x24 &      <--这里还没有安装xvfb
 1097  sudo apt install xvfb                <--安装xvfb后我并没有启用xvfb虚拟屏幕
 1098  sudo modprobe vkms enable_cursor=1 num_outputs=1
 1099  echo "options vkms enable_cursor=1 num_outputs=1" | sudo tee /etc/modprobe.d/vkms.conf
 1100  sudo update-initramfs -u
 1101  ls /dev/dri/
 1102  ls /sys/class/drm/ | grep -i virtual
 1103  drm_info    <--这里提示没有安装
 1104  sudo vi /etc/X11/xorg.conf.d/30-vkms.conf
 1105  sudo systemctl restart display-manager
 1106  export DISPLAY=:0
 1107  xrandr     <--这里尝试rustdesk连接并成功连上HDMI-2的虚拟屏幕,由核显UHD渲染。
 1108  top
 1109  history | tail -n 20 > ~/recent_cmds.txt
George

Geek for fun.

https://jimy.fun

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top