6

I'd like to setup x11vnc (or any other vnc server) to start at boot-time. The display manager is kdm, the distribution is Ubuntu 12.04.2 LTS.

When I try to start x11vnc, I'm getting this errors:

$ x11vnc -rfbauth /var/run/xauth/A:0-crWk72  -rfbport 5901
 passing arg to libvncserver: -rfbauth
 passing arg to libvncserver: /var/run/xauth/A:0-crWk72
 passing arg to libvncserver: -rfbport
 passing arg to libvncserver: 5901
 x11vnc version: 0.9.12 lastmod: 2010-09-09  pid: 2828
 XOpenDisplay("") failed.
 Trying again with XAUTHLOCALHOSTNAME=localhost ...

 *** XOpenDisplay failed. No -display or DISPLAY.
 *** Trying ":0" in 4 seconds.  Press Ctrl-C to abort.
 *** 1 2 3 4 
 XOpenDisplay(":0") failed.
 Trying again with XAUTHLOCALHOSTNAME=localhost ...
 XOpenDisplay(":0") failed.
 Trying again with unset XAUTHLOCALHOSTNAME ...

I've tried installing xserver-xorg-video-dummy in order to avoid issues with no screen attached, but so far with no success.

migrated from serverfault.com Jun 4 '13 at 0:57

This question came from our site for system and network administrators.

  • have you tried to install xvfb? – postmaps Jun 3 '13 at 21:26
5

I came up with following solution:

  1. sudo apt-get install x11vnc xserver-xorg-video-dummy
  2. check /etc/default/grub that it includes nomodeset flag:

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset"

  3. Create (or modify) /etc/X11/xorg.conf, modify USER and LISTEN address according to your settings.

Section "Monitor"
Identifier "Monitor0"
HorizSync 28.0-80.0
VertRefresh 48.0-75.0
# 1680x1050 @ 60.00 Hz (GTF) hsync: 65.22 kHz; pclk: 147.14 MHz
Modeline "1680x1050_60.00" 147.14 1680 1784 1968 2256 1050 1051 1054 1087 -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 "1680x1050"    
    EndSubSection
EndSection

You can generate your own resolution.

4 - create service script in /etc/init.d/vncserver

#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     3 4 5
# Default-Stop:      0 6
### END INIT INFO

PATH="$PATH:/usr/X11R6/bin/" CMD="/usr/bin/x11vnc"

# The Username:Group that will run VNC 
export USER="your_username"

# The display that VNC will use DISPLAY="1"

# Color depth (between 8 and 32) DEPTH="16"

# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
#GEOMETRY="800x600" GEOMETRY="1680x1050"
#GEOMETRY="1280x1024"

# The name that the VNC Desktop will have. NAME="my-vnc-server"

PORT=5900 
LISTEN="192.168.1.10"


OPTIONS="-xkb -noxrecord -noxfixes -noxdamage -listen ${LISTEN} -name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -auth guess
-usepw ~/.vnc/passwd -rfbport ${PORT} -forever -bg -oa /var/log/x11vnc.log"

. /lib/lsb/init-functions

case "$1" in start) echo ${OPTIONS} log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}" su ${USER} -c "${CMD} ${OPTIONS}" ;;

stop) log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}" su ${USER} -c "${CMD} -kill :${DISPLAY}" ;;

restart) $0 stop $0 start ;; esac

exit 0
  • the only problem with this is that dummy driver won't use specified resolution: DUMMY(0): Not using default mode "1680x1050" (insufficient memory for mode). When the monitor is connected the nvidia card doesn't have problem with the resolution. – Tombart Jun 4 '13 at 11:54
1

The following always gets me with a working vnc session quickly:

apt-get install vnc4server x11-xserver-utils xserver-xorg-video-dummy xterm wm2

I added x11-xserver-utils and xserver-xorg-video-dummy in case X11 is not yet installed on your system and you want to avoid having a full X11 install. However this point is most likely irrelevant in your case, just added it in case someone else finds it useful.

I added xterm and wm2 in case you want a simple setup and not a full blown gnome session or similar. If that is the case then under your user account run vnc4server in order to auto create ~/.vnc/xstartup. Then kill it and edit ~/.vnc/xstartup and add the following 2 lines to the bottom.

x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
wm2 &

And run vnc4server again.

Otherwise just running vnc4server under your own account should suffice. When started for the first time the vncserver will ask you to create a password, use that password to connect from a remote system.

On the remote system install something like xtightvncviewer and use it to connect to your vnc server:

apt-get install xtightvncviewer
xtightvncviewer 192.0.2.1:1   [1]

1 - See http://www.iana.org/go/rfc5737 on why to use this ip range in documentation

  • I've posted mine solution, it's more complicated and right now works with KDE and resolution 1360x768. I will have a look at wm2 it looks interesting. Thanks. – Tombart Jun 4 '13 at 11:57
  • @Tombart There's no difference between x11vnc and x11vnc, literally. – smwikipedia Aug 17 '18 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.