80

I have an Ubuntu 14.04 server that has no external monitor connected. I use NoMachine to remote control the machine. When I do so, the Unity/Gnome interface doesn't see any monitors connected, so I can only use 800x600 when connecting with NoMachine. If I plug in a monitor, I can set the resolution to whatever size the NoMachine window is on the remote computer.

Is there a way to create a "fake" monitor device on Ubuntu so I can set a desktop resolution in Unity/Gnome?

LiveWireBT
  • 28,763
John Chapman
  • 1,903
  • 1
  • 13
  • 9
  • For those using a headless VM I normally use this: http://realtechtalk.com/using_Xvfb_on_virtual_remote_ssh_server_to_have_X_graphical_programs_work-2287-articles – Areeb Soo Yasir Mar 26 '20 at 20:10

9 Answers9

97

Found a way to do it without requiring a dummy plug: Ubuntu Headless VNC VESA 800x600 Resolution Fix ~ Andy Hawkins @ June 12, 2011

Basically install a dummy driver:

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

Then write it in the /usr/share/X11/xorg.conf.d/xorg.conf (or possibly /etc/X11/xorg.conf) file (create one, if it does not exist):

Section "Device"
    Identifier  "Configured Video Device"
    Driver      "dummy"
    # Default is 4MiB, this sets it to 16MiB
    VideoRam    16384
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 "1024x800" EndSubSection EndSection

Then restart your X session by logging out.

John Chapman
  • 1,903
  • 1
  • 13
  • 9
  • related info for those using NoMachine who want to change the screen resolution but have a monitor plugged in on the remote site with a different ratio, so really need the dummy driver: http://ubuntuforums.org/showthread.php?t=1832456 and https://www.xpra.org/xorg.conf and when NoMachine says there are no sessions, debug here: /var/log/Xorg.0.log

    refresh changes: sudo service lightdm restart sudo su sudo /etc/NX/nxserver --restart exit

    – Alexander Taylor Nov 28 '14 at 01:23
  • 3
    Please edit the answer, the package is being updated. Try sudo apt-cache search video-dummy. – cctan Aug 12 '15 at 09:56
  • 2
    Creating the file /usr/share/X11/xorg.conf.d/xorg.conf with this content, or the one from http://xpra.org/xorg.conf, my Ubuntu does not boot anymore (it gets stuck with the Ubuntu logo screen before the login screen). What can be the problem? – David Portabella Aug 23 '16 at 21:40
  • Your patch works like a charme. What about a screen not always connected? Because right now, with this patch and a screen, the computer is stuck because X server fails to load. – brcebn Sep 06 '16 at 07:58
  • 3
    The problem I get now is when I connect a real monitor it won't work. Only if I uninstall all the packages and restart. Couldn't we do a priority thing ? – Arthur Kovacs Jan 19 '18 at 12:22
  • This broke my Kubuntu 17.10 in a way it wouldn't boot properly until I removed the file with the help of an usb installation. Be careful, have a plan in case this goes wrong. (Admittedly layman here.) – Neinstein Mar 12 '18 at 21:10
  • 22
    Also broke my os. Did not boot. Its remote and now I need to get in a car and drive 1hr. Risky stuff :-) – Derek Apr 07 '18 at 17:49
  • 1
    @Derek Which of these was it? (1) Placing the xorg.conf file really broke your ssh server (How???). (2) You had no ssh server set up, VNC to the X session was your only access mode. (3) Random unrelated HW Failure. // Cause I'm going to try the same to a remote machine. I can't imagine how the ssh server will be affected even if the X session will fail to start. – Ludwig Schulze Aug 25 '18 at 13:14
  • 1
    This works for me! However there is a problem that if I attach a real monitor it's always black screen – soulmachine Nov 11 '18 at 19:06
  • 1
    How can I add two dummy screens in this way? – iBug Jun 22 '19 at 12:46
  • 1
    For ubuntu 18.04 the package name is xserver-xorg-video-dummy-hwe-18.04 Also solves the same problem with Teamviewer 14 – frommelmak Jul 17 '19 at 11:13
  • For me, it works in editing /etc/X11/xorg.conf instead of /usr/share/X11/xorg.conf.d/xorg.conf – sangorys Oct 28 '19 at 11:49
  • Seconding @frommelmak had to install server-xorg-video-dummy-hwe-18.04 and the config, then everything worked. – Sam-Graham Nov 06 '19 at 17:57
  • @Sam-Graham what exactly worked for you? I installed the dummy package install server-xorg-video-dummy-hwe-18.04, things work great when no monitor is attached. However when I plug in a monitor I get a black screen with a blinking cursor. – Vik Dec 15 '19 at 16:20
  • @Vik I was in the same boat as frommelmak and was connecting using Teamviewer. I had the same issue as you with the monitor being blank if you plugged in a real one. I had to set it up to auto login as well in my case, which might fix your issue, as mine seemed to get stuck on the login screen. Hope this helps. – Sam-Graham Dec 18 '19 at 04:48
  • 10
    This should no longer be accepted solution. It's bricking too many OS's for people. including mine :) – Darius Dec 30 '19 at 10:38
  • I finally have enough points to comment. I had luck with the following answer: https://askubuntu.com/questions/1085161/how-can-i-start-a-qt-gui-application-on-boot-without-a-display-connected/1085165#1085165 – petrosmm Mar 20 '20 at 13:49
  • I'm not sure this is actually breaking anything other then when connecting a monitor. I had the same problem and just powered off the machine was accessible remotely. I have the ability to power off the machine remotely so that could be why I was not stuck. But bottom line, I don't think it is a fair assessment that this breaks remote access, even with a monitor connected. It may be hanging trying to shutdown during reboot. – nospam2k Apr 01 '20 at 16:40
  • 2
    This method will break some display and it will be blank or stuck with some logo. I solved this by turn off pc and turn on then pressed F1 until I see some menu, then select "Advanced options for ubuntu" then select "Ubuntu, with Linux *** (recovery mode)", then choose "root ", so you mini terminal exist in the bottom, then you can go to remove the file you create by "cd /usr/share/X11/xorg.conf.d" or "cd /etc/X11/", then "rm -rf xorg.conf", then "reboot". Booom!! Welcome back to your lovely display! XD – Heng Sengthai Nov 17 '20 at 02:19
  • I just installed the dummy driver and created an empty xorg.conf file /usr/share/X11/xorg.conf.d/xorg.conf that works as a solution. when i have a monitor connected it displays on monitor, but when i boot it without a monitor i can ssh from another machine. did this for ubuntu 19.04 running on my intel nuc. works flawless. – Sanket Sonavane Apr 06 '21 at 13:51
  • earlier i had edited the xorg.conf with above details and i could see loading till ubuntu progress bar and post that nothing but i was able to ssh into my machine. so i edited the xorg.conf at that time and deleted all its content and saved it. glad it worked. – Sanket Sonavane Apr 06 '21 at 13:54
  • This worked very well on Linux mint 19.04! Thanks! – Rohit Parte Apr 16 '21 at 07:12
  • 1
    I think it's important to include information on how to undo this. – 842Mono Jul 06 '21 at 01:58
  • 2
    2021-08-11 - This worked perfectly for my raspberry pi 4. I can now boot gui without a monitor connected (or boot headlessly if we want to). I thought that it would be important to add this since others seem to be trying to find a way to do it with Raspberry Pi's. I put mine straight in /etc/X11/xorg.conf (had to make the file). For new coders, or people new to this ecosystem, you have to use sudo to make and work with files there. (sudo nano xorg.conf). Good Luck! – Montag Aug 11 '21 at 19:55
  • 1
  • Ubuntu 20.04. NVIDIA proprietary drivers. Works flawlessly. This allows me to connect to my desktop over VNC from my laptop with ease!
  • – McSuperbX1 Aug 23 '22 at 13:15
  • For a higher resolution 1920x1080, I used the xorg.conf found at this link: https://gist.githubusercontent.com/mangoliou/ba126832f2fb8f86cc5b956355346038/raw/b6ad063711226fdd6413189ad905943750d64fd8/xorg.conf – robnick Mar 14 '24 at 02:19