Setting up VNC server on the Pi

Install VNC and Auto Start

Here’s how to install VNC and get it working with the Pi across a network

First of all, make sure you expand the SD card – you don’t want to run out of space!

  1. apt-get install tightvncserver
  2. Yes, you want it to install, so accept the space it tells you it’s going to use!
  3. It’ll go through the usual install procedure and eventually put you back at the shell prompt.
  4. Type:
    1. tightvncserver :1
    2. (This will create a few files it needs to run)
    3. Set a password when it asks. Don’t bother with a view password unless you really want one – it’s just a pain.
  5. Edit the /etc/rc.local file and add the following before the ‘exit’ command at the bottom.
    1. sudo -u root /usr/bin/vncserver :1 -geometry 1024×768 -depth 16 -pixelformat rgb565 -fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/
  6. Save the file, back to the prompt you go.
  7. This will mean that your VNC server starts up before you need to login on port 1 and a screen size of 1024×768.
  8. Reboot. Watch that magic happen. Dude. S’up.

The reason you do sudo is that it needs to know who to run the server as – remember, you’re not logged in before the login prompt comes up!

Now, you should be able to reboot and connect to the VNC server from your laptop, for instance.
You’ll need to download the Tight VNC viewer to do this.

2 comments for “Setting up VNC server on the Pi

  1. >First, if you want to start a vncserver instead of the ordinary X11-server (/usr/bin/X), you just copy /etc/X11/xinit/xserverrc to your home directory.

    cp /etc/X11/xinit/xserverrc ~/.xserverrc

    Then you edit it to your likeing (change the /usr/bin/X part of the line that starts with exec to the server you want to run). Like this:

    exec /usr/bin/tightvncserver "$@"

    Now when you type startx you will start your selected server instead of /usr/bin/X

    If you want to start grafical when you boot the system, you need to have a dm (display manager) running. The Raspberry Pi haves gdm installed, and I belive that the newer version that are based on Whezze will have gdm3. "Problem" is that it isn't started from the start.

    To see what graphical working space (X server) it starts, just look in the file /etc/gdm/gdm.conf where you have lots of comments which are good to read. You also have http://library.gnome.org/admin/gdm/2.32/ for more optins.

    By default gdm will start /usr/bin/X :0 which is the first virtual scren on your physical screen (the HDMI output). You can get the other with Ctrl-Alt-F1 to Ctrl-Alt-F7, just try. It works without running the grafical environment (X11).

    Section server in /etc/gdm/gdm.conf, which is after a line that looks like this:
    [servers]
    tells you which servers will be run.

    If you want gmd to start a vncserver, add this section (untested, so test but be aware it could be spelling errors).

    [server-vncserver]
    # Definition of how to start vncserver from gdm
    name=VNC Server
    command=/usr/bin/tightvncserver
    flexible=true

    Now you can ADD this line to select vncserver as second graphical to start by gdm in /etc/gdm/gdm.conf. It will run with DISPLAY set to :1 instead of standard :0
    If you don't want to start /usr/bin/X at all from gdm, just set 0=vncserver to overwrite the setting that start the Standard server, 0=Standard that is.

    [servers]
    # Start standard server as first one
    0=Standard
    # Start vnc server as second one
    1=vncserver

    Now, to see all services status, try

    sudo service –status-all

    There you should see that gdm istn't started.
    To see status of only gdm try this

    sudo service gdm status

    To start or stop you just add these words after gdm in the command above. But this will just work this session. To make it permanent, you need to tell Debian than (it makes symbolic links from /etc/init.d/gdm to some directories /etc/rc[0-6S].d, try 'ls /etc/rc[0-6S].d').

    As they have removed the links from /etc/rc?.d, we need to install them again. You should not remove links, you should disable the service. Anyway, this restores the links.

    sudo update-rc.d gdm defaults

    This line set so Debian starts gdm each time the computer boots. To disable gdm, just change enable to disable. 🙂

    sudo update-rc.d gdm enable

    Good manual pages (RTFM, Read The Fine Manual)
    man gdm
    man xstart
    man service
    man update-rc

    Some good links:
    http://wiki.debian.org/DisplayManager
    http://wiki.debian.org/WindowManager
    http://wiki.debian.org/DesktopEnvironment
    http://wiki.debian.org/XWindowSystem
    http://library.gnome.org/admin/gdm/2.32/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.