How to Setup a Headless Computer

a computer with no monitor working with Debian


0. Headless Computer

A headless system is a computer system or device that has been configured to operate without a monitor (the missing "head"), keyboard, and mouse. A headless system is typically controlled via a network connection. One possiblility is to use VNC. You have a tutorial about VNC here. In this tutorial you will find the solutions to the problems that I had setting up headless servers with different graphics cards in a Debian system. This tutorial is heavily "inspired" in the links you find in every section. I collected all this information because it took me a while to get the full picture and I do not want to forget everything I learned solving this problem.

There are two ways to setup a headless computer. The esiest one makes use of a dummy display driver, which does not actually display anything. You will be able to control your system only through VNC or ssh. You will get no output through your graphics card. You will be able to easily choose among a big variety of "virtual display" resolutions. The "dummy headless system" is ready in a few minutes with no problems. Just follow the procedure described in section 1.

The other possibility, usually more troublesome, is to keep the current driver working. This allows you to work through VNC or ssh and also plug and use the monitor if you need to do so. This may depend a bit on the kind of graphics card you have in your computer. I describe here what I did for an Ndivia card in section 2 and a Radeon card in section 3. As you will see the procedure is similar for every graphics card.

An alternative procedure that I did not test is described in section 4 for Nvidia/ATI Radeon/Intel graphics cards.

If you are not so familiar with graphics card management, Xorg and so on, I recommend to take a look at the following tutorials from Debian web pages:

Xorg (Debian wiki)
NvidiaGraphicsDrivers (Debian wiki)
AtiHowTo (Debian wiki)

where you will find information mainly about drivers.

It is also pays off to read from the ArchLinux wiki:

Xorg (Archwiki)
Nvidia (Archwiki)
ATI Radeon (Archwiki)

where xorg.conf files and options of the graphics card are very nicely described.

1. Installation of a Dummy Display Driver

The dummy display driver does not display anything. You will get no output through your graphics card. The idea is that you want to be able to control your system only through VNC or ssh. With the dummy driver you choose among a big variety of "virtual display" resolutions to fit your needs.

To install the dummy driver open a terminal and type:

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

Next step, we have to configure the virtual display for VNC. This is done by writting a configuration file: /etc/X11/xorg.conf. If you already have such a file in your system, change its name:

sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.old

We create the new one:

sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.old

And fill it with the following content:

# This xorg configuration file is meant to be used
# to start a dummy X11 server.
# For details, please see:
# https://www.xpra.org/xorg.conf

# Here we setup a Virtual Display of 1600x900 pixels

Section "Device"
    Identifier "Configured Video Device"
    Driver "dummy"
    #VideoRam 4096000
    #VideoRam 256000
    VideoRam 16384
EndSection

Section "Monitor"
    Identifier "Configured Monitor"
    HorizSync 5.0 - 1000.0
    VertRefresh 5.0 - 200.0
    Modeline "1600x900" 33.92 1600 1632 1760 1792 900 921 924 946
EndSection

Section "Screen"
    Identifier "Default Screen"
    Monitor "Configured Monitor"
    Device "Configured Video Device"
    DefaultDepth 24
    SubSection "Display"
        Viewport 0 0
        Depth 24
        Virtual 1600 900
    EndSubSection
EndSection

This configuration file corresponds to a virtual display of 1600x900. There are many other modes that you can find here: https://www.xpra.org/xorg.conf. Just change the Modeline and Virtual depending on your needs. If you increase the size of your virtual screen you may need also to increase the VideoRam parameter. To have an idea, it seems that a display of 16384x8192 needs "VideoRam 256000". After making the changes, reboot the system, access the computer with VNC, and check the log file /var/log/Xorg.0.log carefully. Check if there are any errors, like for instance not enough memory. In that case you will get a smaller display. Increasing VideoRam you will easily solve the problem.

A list of some other common modes:

Modeline "1920x1080" 23.53 1920 1952 2040 2072 1080 1106 1108 1135
Modeline "1680x1050" 20.08 1680 1712 1784 1816 1050 1075 1077 1103
Modeline "1600x1200" 22.04 1600 1632 1712 1744 1200 1229 1231 1261
Modeline "1600x900" 33.92 1600 1632 1760 1792 900 921 924 946
Modeline "1440x900" 30.66 1440 1472 1584 1616 900 921 924 946
ModeLine "1366x768" 72.00 1366 1414 1446 1494 768 771 777 803
Modeline "1280x1024" 31.50 1280 1312 1424 1456 1024 1048 1052 1076
Modeline "1280x800" 24.15 1280 1312 1400 1432 800 819 822 841
Modeline "1280x768" 23.11 1280 1312 1392 1424 768 786 789 807
Modeline "1360x768" 24.49 1360 1392 1480 1512 768 786 789 807
Modeline "1024x768" 18.71 1024 1056 1120 1152 768 786 789 807

2. Headless Computer with an Nvidia card (propietary driver installed)

If you are reading this section is because you have an nvidia graphics card and you wish to keep the current driver working on your headless computer. This allows you to work through VNC or ssh. But it also allows you to attach and use the monitor if you want to do so. First thing to do is to obtain an /etc/X11/xorg.conf file. You can get one easily using some nvidia utilities. Install the following packages (if you already do not have them):

sudo apt-get install nvidia-settings nvidia-xconfig

and then you get your xorg.conf file by issuing:

sudo nvidia-xconfig

This is a nice starting point. In my case I finally used a file like this one:

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig: version 1.0 (buildd@barber) Sun Jun 13 12:08:56 UTC 2010
Section "ServerLayout"
    Identifier "Layout0"
    Screen 0 "Screen0"
    InputDevice "Keyboard0" "CoreKeyboard"
    InputDevice "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier "Mouse0"
    Driver "mouse"
    Option "Protocol" "auto"
    Option "Device" "/dev/psaux"
    Option "Emulate3Buttons" "no"
    Option "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier "Keyboard0"
    Driver "kbd"
EndSection

Section "Monitor"
    Identifier "Monitor0"
    VendorName "Unknown"
    ModelName "Unknown"
    HorizSync 30.0 - 81.0
    VertRefresh 56.0 - 75.0
    Option "DPMS"
    Option "DPI" "92 x 88"
EndSection

Section "Device"
    Identifier "Device0"
    Driver "nvidia"
    VendorName "NVIDIA Corporation"
    Option "RenderAccel" "1"
    Option "TripleBuffer" "1"
    Option "Coolbits" "1"
    Option "DamageEvents" "1"
    Option "RegistryDwords" "PerfLevelSrc=0x3333"
    Option "RegistryDwords" "PerfLevelSrc=0x2222"
EndSection

Section "Screen"
    Identifier "Screen0"
    Device "Device0"
    Monitor "Monitor0"
    DefaultDepth 24
    SubSection "Display"
        Depth 24
        Modes "1680x1050"
    EndSubSection
EndSection

There are several things to check. First, this file allows to get a screen with 1680x1050 pixels, as indicated in the "Modes" line. If this line is missing you should add it with the resolution of your monitor. If you are lucky, the values for "HorizSync" and "VertRefresh" will be correct for the resolution of your monitor. If you are not lucky, when you restart the system with no monitor, may be you will get a 640x480 small screen when using VNC.

One way to get "HorizSync" and "VertRefresh" for a monitor in Debian Wheezy, install the program xresprobe:

sudo apt-get install xresprobe

Then you type:

sudo ddcprobe

You will get a long list of characteristics of your monitor. By the end of the list you should get something like "monitorrange: 24-82, 50-75". Those are the values you need for"HorizSync" and "VertRefresh".

Once you have your xorg.conf, you are ready to restart the system with no monitor. To solve any problems you should carefully check the log file /var/log/Xorg.0.log

Please check also what to do if you have a free driver installed just in case it helps you (section 3).

3. Headless Computer with a Radeon card with free drivers

If you are reading this section is because you have an ATI Radeon graphics card and you wish to keep the current driver working on your headless computer. This allows you to work through VNC or ssh. But it also allows you to attach and use the monitor if you want to do so. First thing to do is to obtain an /etc/X11/xorg.conf file. The starting point is to the console via Ctrl+Alt+F6. You may get out from the console later on via Ctrl+Alt+F7. You log in and then stop the display manager. If you do not know which one are you using just type:

sudo /etc/init.d/gdm stop && /etc/init.d/gdm3 stop && /etc/init.d/kdm stop && /etc/init.d/xdm stop

Then you generate an /root/xorg.conf.new file by:

sudo Xorg -configure

Now you start working using that file. Probably you can not use it directly, but it is a nice starting point. Better than nothing.

My final /etc/X11/xorg.conf file looks like this:

Section "ServerLayout"
    Identifier "X.org Configured"
    Screen 0 "Screen0" 0 0
    InputDevice "Mouse0" "CorePointer"
    InputDevice "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
    ModulePath "/usr/lib/xorg/modules"
    FontPath "/usr/share/fonts/X11/misc"
    FontPath "/usr/share/fonts/X11/cyrillic"
    FontPath "/usr/share/fonts/X11/100dpi/:unscaled"
    FontPath "/usr/share/fonts/X11/75dpi/:unscaled"
    FontPath "/usr/share/fonts/X11/Type1"
    FontPath "/usr/share/fonts/X11/100dpi"
    FontPath "/usr/share/fonts/X11/75dpi"
    FontPath "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
    FontPath "built-ins"
EndSection

Section "Module"
    Load "record"
    Load "dri2"
    Load "extmod"
    Load "dbe"
    Load "glx"
    Load "dri"
EndSection

Section "InputDevice"
    Identifier "Keyboard0"
    Driver "kbd"
EndSection

Section "InputDevice"
    Identifier "Mouse0"
    Driver "mouse"
    Option "Protocol" "auto"
    Option "Device" "/dev/input/mice"
    Option "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
    #DisplaySize 460 300 # mm
    Identifier "Monitor0"
    VendorName "SAM"
    ModelName "SyncMaster"
    HorizSync 30.0 - 81.0
    VertRefresh 56.0 - 75.0
    Option "DPMS"
EndSection

Section "Device"
    ### Available Driver options are:-
    ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
    ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
    ### [arg]: arg optional
    Option "AccelMethod" "EXA"
    Option "MigrationHeuristic" "greedy"
    Option "EnablePageFlip" "on"
    Option "AccelDFS" "on"
    Option "RenderAccel" "on"
    Option "ColorTiling" "on"
    Identifier "Card0"
    Driver "radeon"
    VendorName "ATI Technologies Inc"
    BoardName "RV280 [Radeon 9200]"
    BusID "PCI:1:0:0"
EndSection

Section "Screen"
    Identifier "Screen0"
    Device "Card0"
    Monitor "Monitor0"
    SubSection "Display"
        Viewport 0 0
        Depth 24
        Modes "1680x1050"
    EndSubSection
EndSection

You have to pay special attention to the "Modes" line in the "Screen" section. If you do not have it, add your own corresponding to your monitor. The values for "HorizSync" and "VertRefresh" will probably not be correct for the resolution of your monitor.

One way to get "HorizSync" and "VertRefresh" for a monitor in Debian Wheezy, is to install the program xresprobe:

sudo apt-get install xresprobe

Then you type:

sudo ddcprobe

You will get a long list of characteristics of your monitor. By the end of the list you should get something like "monitorrange: 24-82, 50-75". Those are the values you need for "HorizSync" and "VertRefresh".

Once you have your xorg.conf, you have to edit the following file:

sudo gedit /etc/modprobe.d/radeon-kms.conf

And set modeset to zero:

options radeon modeset=0

You are ready now to restart the system with no monitor. To solve any problems you should carefully check the log file /var/log/Xorg.0.log. If you get a small virtual screen you should recheck "HorizSync" and "VertRefresh".

4. Another approach for Nvidia/Radeon/Intel graphics card working with free drivers

Another nice approach described in Debian forums is the following:

Step 1. Create a xorg.conf in /etc/X11 with the following:

Section "Device"
    Identifier "VNC Device"
    Driver "vesa"
EndSection

Section "Screen"
    Identifier "VNC Screen"
    Device "VNC Device"
    Monitor "VNC Monitor"
    SubSection "Display"
        Modes "1024x768"
    EndSubSection
EndSection

Section "Monitor"
    Identifier "VNC Monitor"
    HorizSync 30-70
    VertRefresh 50-75
EndSection

Step 2. Disable KMS for your video card as described here https://wiki.ubuntu.com/X/KernelModeSetting

The jist is to know which video card manufacturer you have and use the command line entry below it to create the appropriate kms.conf file with the line "options...modeset=0" line in it. If you have access to the GUI you could just are easily create/modify the file and put the "options...modeset=0" in as appropriate.

The following are input into the terminal windows as a line command.

# ATI Radeon:
echo options radeon modeset=0 > /etc/modprobe.d/radeon-kms.conf

# Intel:
echo options i915 modeset=0 > /etc/modprobe.d/i915-kms.conf

# Nvidia (this should revert you to using -nv or -vesa):
echo options nouveau modeset=0 > /etc/modprobe.d/nouveau-kms.conf

Step 3. Reboot...Putty In...startx...GTG!

Again notice that if you change the "Modes" option you have to change "HorizSync" and "VertRefresh" accordingly.

It is my wish this page is helpful to someone. At least it is useful to myself!