Skip to content

Instantly share code, notes, and snippets.

@dragolabs
Created April 29, 2020 20:09
Show Gist options
  • Save dragolabs/8e559113567faed32327ef24fdce775b to your computer and use it in GitHub Desktop.
Save dragolabs/8e559113567faed32327ef24fdce775b to your computer and use it in GitHub Desktop.
Run VNC without connected monitor to ubuntu Desktop

Install Video Dummy Package

sudo apt-get install xserver-xorg-video-dummy

Create Default X Windows Configuration File

Create / Edit xorg.conf file Rename file if already exists for backup

sudo vi /usr/share/X11/xorg.conf.d/xorg.conf

Add the following content to the file Set the resolution to what you like (whatever resolution the screen is that is used to connect remotely is probably is a good idea)

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

Save the file Reboot and Test

@chandler150
Copy link

chandler150 commented Nov 15, 2024

Just an update, I haven't tried this yet, but I did find this tonight: https://techoverflow.net/2019/02/23/how-to-run-x-server-using-xserver-xorg-video-dummy-driver-on-ubuntu/

This configuration works just fine. I'll paste it here just to be sure it will never be missed.

Section "Monitor"
  Identifier "Monitor0"
  HorizSync 28.0-80.0
  VertRefresh 48.0-75.0
  # https://arachnoid.com/modelines/
  # 1920x1080 @ 60.00 Hz (GTF) hsync: 67.08 kHz; pclk: 172.80 MHz
  Modeline "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
EndSection
Section "Device"
  Identifier "Card0"
  Driver "dummy"
  VideoRam 256000
EndSection
Section "Screen"
  DefaultDepth 24
  Identifier "Screen0"
  Device "Card0"
  Monitor "Monitor0"
  SubSection "Display"
    Depth 24
    Modes "1920x1080_60.00"
  EndSubSection
EndSection

Also, you can generate your own Modeline here: https://arachnoid.com/modelines/

This worked well for me, new maximum I can get is 2048x1152, and that is with the modeline line replaced with

# 3840x2160 @ 60.00 Hz (GTF) hsync: 134.10 kHz; pclk: 712.34 MHz
Modeline "3840x2160_60.00" 712.34 3840 4152 4576 5312 2160 2161 2164 2235 -HSync +Vsync

Not sure why it's capping there yet, but useful

@Human0722
Copy link

This works for me on Ubuntu 22.04:

​When HDMI is plugged in, the monitor works.
​When HDMI is unplugged, the dummy display driver takes over.

  • Step 1
apt install xserver-xorg-video-dummy
vim /etc/X11/xorg.conf.d/10-headless.conf

10-headless.conf's content:

Section "Monitor"
    Identifier  "VirtualMonitor"
    HorizSync   30.0-62.0
    VertRefresh 50.0-70.0
    Modeline "1920x1080" 172.80 1920 2040 2248 2576 1080 1081 1084 1118
EndSection

Section "Device"
    Identifier  "VirtualCard"
    Driver      "dummy"
    VideoRam    256000
EndSection

Section "Screen"
    Identifier  "VirtualScreen"
    Device      "VirtualCard"
    Monitor     "VirtualMonitor"
    DefaultDepth 24
    SubSection "Display"
        Depth   24
        Modes   "1920x1080"
    EndSubSection
EndSection
  • Step 2:
vim /etc/systemd/system/vnc-display.service

vnc-display.service's content:

[Unit]
Description=Configure VNC dummy screen
After=systemd-user-sessions.service

[Service]
ExecStart=/usr/local/bin/vnc-display.sh

[Install]
WantedBy=multi-user.target
vim /usr/local/bin/vnc-display.sh

vnc-display.sh's content:

#!/bin/bash
# Check connected displays
HDMI_STATUS=`cat /sys/class/drm/card1-HDMI-A-1/status`
if [ $HDMI_STATUS = "connected" ]
then
  # If yes, disable the dummy driver configuration by renaming the file
  sudo mv /etc/X11/xorg.conf.d/10-headless.conf /etc/X11/xorg.conf.d/10-headless.conf.bak
else
  # If no, enable the dummy driver configuration by restoring the file
  sudo mv /etc/X11/xorg.conf.d/10-headless.conf.bak /etc/X11/xorg.conf.d/10-headless.conf
  sudo X :0 -config /etc/X11/xorg.conf.d/10-headless.conf &
fi
sudo chmod +x /usr/local/bin/vnc-display.sh
systemctl daemon-reload
systemctl enable vnc-display.service

@TitjyDev
Copy link

Thanks @Human0722! I was having headaches for days and almost bought a dummy HDMI plug on Aliexpress until I came across this thread!
So, it still works like a charm on the latest version of Ubuntu 25.04.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment