Black/blank console when starting headless Xorg

In addition to a single GTX 1080 this host has onboard graphics. The plan is to use the onboard device for the console, while the 1080 will be used for rendering through VirtualGL. To my understanding, the latter requires a running X server.

All boot messages, as well as the login prompt appear on a monitor connected to the onboard device. However, as soon as the X server is started, the console turns black/blank, which renders it useless. Is it possible to keep a functioning console while an X server is running on the NVIDIA card with no connected monitor?

I’ve tried kernels 3.10 and 4.4, with NVIDIA drivers and 375.39 and 378.13. Currently, /etc/X11/xorg.conf as follows:

Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen		0 "nvidia"
	Inactive	"onboard"
EndSection

Section "Device"
	Identifier	"onboard"
	Driver		"modesetting"
	BusID		"PCI:5:0:0"
EndSection

Section "Device"
	Identifier	"gpu-0"
	Driver		"nvidia"
	BusID		"PCI:130:0:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "onboard"
EndSection

Section "Screen"
	Identifier	"nvidia"
	Device		"gpu-0"
	Option		"UseDisplayDevice"	"none"
EndSection

The same behavior is observed when all references to the onboard device are removed. In this case, I don’t understand why the 1080 with UseDisplayDevice none has any effect at all on the output of the onboard card. Any hints?

This is expected behavior, because the X server grabs the virtual terminal when it starts so that it can control access to the console.

You can sort of work around that by starting X with the -novtswitch (and maybe -sharevts) option, but that has a tendency to not work well because the X driver intercepts keyboard and mouse events by default. You could probably avoid that problem by carefully crafting xorg.conf to avoid having the server grab the input devices, but I don’t know offhand how to do that.

I should note that none of that behavior has anything to do with the nvidia driver. You would see the same thing with xf86-video-dummy.

Thanks! I discovered shortly after posting that “-sharevts” made things ~work the way I wanted, but also noticed that it would behave a tad erratically. The combination “-keeptty -sharevts” is an improvement, but at least now that I know what’s behind all this, I’m in a much better position to come up with a more robust fix, should that become necessary.

And as you say, this has nothing to do with the NVIDIA driver!

To prevent the X server from grabbing any input devices, you can use:

Section "ServerLayout"
    ...
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
    Option         "AutoAddDevices" "false" 
EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "void"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "void"
EndSection

That, in addition to “-sharevts” but without “-novtswitch”, works fine with VirtualGL over here.

Thanks, that appears to work! It seems that the “-sharevts” option is what I was missing. In addition, I find the “-keeptty” option useful in that it allows a server started from an ssh-session to be terminated using CTRL-C.

I’m starting the X server as a background process from rc.local.

# start plain X
X -ac -nolisten tcp -noreset -sharevts < /dev/null >& /dev/null &

But of course it depends on what you want to achieve.