Tag Archives: VNC server

Setting-Up Raspberry Pi for Headless Mode with X11VNC

If you own a Raspberry Pi and want to use it in “headless” mode (without a display) you’ll probably want more than just an SSH command shell to administer it.

Many people install TightVNC however this doesn’t provide connectivity to the root display interface, only to virtual secondary interfaces. Only the root interface behaves like a real remote control session. And there are limitations of the secondary interfaces, e.g. you cannot connect before a user has logged on and the desktop has been loaded.

After a searching around a bit I found a better solution which provides root display connectivity called X11VNC. Here is how you install and configure it:

  1. Logon as the default user “pi”.
  2. Download and install X11VNC using the following command:
    sudo apt-get install x11vnc
  3. Set the password required for VNC clients to connect by entering the following command. It’s important you do NOT run this command elevated (do not use sudo) because it writes the encrypted password in the current user’s home directory, which must be the default user if you want to connect before logon and desktop start-up:
    x11vnc -storepasswd
  4. Create/edit the VNC start-up configuration file, stored in your home directory:
    nano ~/.xsessionrc
  5. Enter/edit the text as follows:
    # Start X11VNC
    x11vnc -bg -nevershared -forever -tightfilexfer -usepw -display :0
  6. Press CTRL+O then ENTER to write (save) the file then CTRL+X to exit.
  7. Make the file executable:
    chmod 775 ~/.xsessionrc
  8. Edit the Raspberry Pi boot configuration to set HDMI as the standard output and set the default resolution, used when no physical display is detected. If you do not do this the default is the analogue output which is an extremely low resolution.
    sudo nano /boot/config.txt
  9. Set the following line to force HDMI to be the only detected connection, i.e. disable the analogue video default:
    hdmi_force_hotplug=1
  10. Set the HDMI “group” and “mode” number to select the default resolution. You can find these codes on Wikipedia or internet searches. To start with, a couple of useful modes:
    1. SVGA 1024×768@60Hz:
      hdmi_group=2
      hdmi_mode=16
    2. Full HD 1920×1080@60Hz:
      hdmi_group=2
      hdmi_mode=82
  11. There are other useful settings here you may wish to play with, such as overscan and CPU overclocking. 800Mhz works well, at least with my board which has custom heat sinks stuck on top of the three main chips.
  12. Press CTRL+O then ENTER to write (save) the file then CTRL+X to exit.
  13. Reboot:
    sudo reboot
  14. Test connectivity with any VNC client, e.g. TightVNC client (even though the server does not satisfy our needs it’s still a great client).
  15. Power-off and disconnect the monitor. Power-on and after a few seconds you should still be able to connect via VNC with the correct display resolution.

Running a Raspberry Pi in headless mode really demonstrates the power of these little devices. You can hide them away with no monitor or keyboard, just provide a little power and network connectivity.

SANYO DIGITAL CAMERA

Add a USB wireless adapter to eliminate the network cable. Add a battery pack to go mobile. You can run them anywhere, even on the go! I’d recommend setting-up headless mode even if you don’t plan to use it immediately. Because it also provides a great way to quickly get GUI access from your other systems. You can even download VNC clients for mobile phones, allowing you to fully control them from anywhere.