I've got a Raspberry Pi and I'm using it as a headless server. But I want to run X on it. It comes with lightdm, and if you run it using the included HDMI or video out it works, and I can use that and x11vnc to that, but without a monitor attached, it defaults to 800x600 or something really small. I've tries setting the geometry, no effect.

So I thought I'd run Xvfb, then run lightdm on that, then x11vnc the whole shebang.

The problem is lightdm doesn't seem to want to connect to an already running X server, it wants to make its own. Fine, so I tell it to run Xvfb instead of X, and it fails because lightdm tries to pass 'vt7' as a param to the X server, but Xvfb doesn't accept the virtual terminal as a param because it's not using any terminal, it's a virtual frame buffer.

So help me out? How can I either get lightdm (I've checked the docs and options, nothing obvious) to start Xvfb correctly (without vt7 param), or get it to attach to an existing X server that's already running and not try and run its own.

1 Answer 1


Incidentally, I was facing the same problem at the same time. Also wanted to run a headless server with Xvfb and VNC, not on RPi though. I found a working solution doing the following steps...

apt-get install lubuntu-core xvfb x11vnc

I figured out that all configuration options of lightdm.conf are documented in /usr/share/doc/lightdm/lightdm.conf.gz. So have a look at them by issuing the following command.

zcat /usr/share/doc/lightdm/lightdm.conf.gz

Obviously, as you reported, lightdm tries to instantiate its own X server and passes some arguments that Xvfb can't handle. First step to work around this is adding a line 'xserver-command' to lightdm's configuration file /etc/lightdm/lightdm.conf (it defaults to xserver-command=X).


After that, I modified /etc/X11/xinit/xserverrc so as to start Xvfb instead of a real X server (note that I commented out the original X exec line that passes the command line arguments on to X). Adding an exec line instead that runs Xvfb was enough to get lightdm working with Xvfb.


#exec /usr/bin/X -nolisten tcp "$@"
exec Xvfb :0 -screen 0 1024x768x24

This seems to me like a convenient method of wrapping the lightdm X command in a suitable wrapper script that is already present on the (L)Ubuntu default installation.

Finally, I use VNC after ssh'ing into the system, forwarding the VNC port and connecting to the forwarded port on localhost with a VNC client (in my case Mac OS screen sharing).

ssh -L 5900:localhost:5900 user@machine 'x11vnc -localhost -display :0 -many'
  • Okay, you're a genius, but explain me this: xserver-command points to a script that runs Xvfb. so why not just put Xvfb on the xserver-command line? I had tried that and it didn't work because lightdm still passes params to X that way, but when I do it the way you suggest, it does not and it works. What am I missing? Happy that it works though.
    – Stu
    Dec 30, 2012 at 14:06
  • The secret is that lightdm still passes all those arguments to the script. But the script just ignores these arguments and instead calls Xvfb with a fixed command. Obviously, lightdm gets the xserver-command value and appends all the arguments which are supposed to work for X and then executes this as a command. You can verify this by logging the arguments passed to xserverrc. Inserting the following line just before the exec Xfvb writes the arguments to /tmp/xvfbargs.log. echo "$@" > /tmp/xvfbargs.log Then, you can view the arguments passed to the script by cat /tmp/xvfbargs.log
    – Andreas
    Dec 30, 2012 at 18:29
  • I get it now, you're still a genius. That's a cute trick I hadn't thought of before. I mean I make scripts all the time to concat strings of params from one script to the next, but I never thought of using it to remove params before. :-)
    – Stu
    Jan 1, 2013 at 15:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .