Install NX Server on Raspberry Pi

From TIAO's Wiki
Jump to: navigation, search








Buy Game Console Adapters from http://www.easymg.com or http://www.diygadget.com

Contents


What is Raspberry Pi

The Raspberry Pi is a credit-card sized computer that plugs into your TV and a keyboard. It’s a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word-processing and games. It also plays high-definition video.

The Raspberry Pi has a Broadcom BCM2835 system on a chip (SoC), which includes an ARM1176JZF-S 700 MHz processor, VideoCore IV GPU, and 256 megabytes of RAM. It does not include a built-in hard disk or solid-state drive, but uses an SD card for booting and long-term storage.

  • CPU: 700 MHz ARM1176JZF-S core
  • Video: Broadcom VideoCore IV,[58] OpenGL ES 2.0, 1080p30 h.264/MPEG-4 AVC high-profile decoder
  • Memory: 256 MB (shared with GPU)
  • USB ports: 2 (can be expanded with a usb hub)
  • Video Outputs: Composite RCA (PAL & NTSC), HDMI (rev 1.3 & 1.4), raw LCD Panels via DSI, 14 HDMI resolutions from 640×350 to 1920×1200 plus various PAL and NTSC standards.
  • Audio Outputs: 3.5 mm jack, HDMI
  • Onboard Storage: SD Card Slot ( external USB SSD or HDD can be used)
  • Networking: 10/100 Ethernet (RJ45)
  • Power Rating: 700 mA, 5 V
  • Dimensions: 85.60 × 53.98 mm (3.370 × 2.125 in)
  • Weight: 45 g (1.6 oz)

You can buy Raspberry Pi from our store: Raspberry Pi Mode B - a credit card size ARM GNU/Linux box - with FREE USB card reader

Why you need NX server

NX allows users to create new X11 sessions and forwards all X communication to the remote client. If is a lot faster than VNC.

How to install NX server on Raspberry Pi

Prepare the build and runtime environment

You need the following packages to build NX server. Use apt-get to install them on your pi:

  • xutils-dev
  • expect
  • xorg-dev
  • libjpeg8-dev
  • libpng12-dev

Before you use apt-get, try to run update command first, otherwise you may encounter some 404 not found errors.

sudo apt-get update

Command:

sudo apt-get install xutils-dev expect xorg-dev libjpeg8-dev libpng12-dev

NX server also requires CUPS, xfonts-base and x11-xserver-utils, thus you need to install it as well:

sudo apt-get install cups
sudo apt-get install xfonts-base
sudo apt-get install x11-xserver-utils

Compiling NX components

NoMachine has released the component source here. There is also a official guide to compiling the components and it is a good source of information. The components you need to build the NX servers are (as of Sept 13/2012, you may see a different version, but component name won't change):

  • nxproxy-3.5.0-1
  • nxcomp-3.5.0-2
  • nxcompext-3.5.0-1
  • nxcompshad-3.5.0-2
  • nx-X11-3.5.0-2
  • nxauth-3.5.0-1
  • nxagent-3.5.0-9
  • nxscripts-3.5.0-1


You can SSH to your Pi and use "wget" to download the files.

Now you should have total 8 files:

pi@raspberrypi /work/nx $ ls -l
total 22180
-rw-r--r-- 1 pi pi  1510400 Jul 12 16:40 nxagent-3.5.0-9.tar.gz
-rw-r--r-- 1 pi pi    30671 Jul 12 16:39 nxauth-3.5.0-1.tar.gz
-rw-r--r-- 1 pi pi   532999 Jul 12 16:40 nxcomp-3.5.0-2.tar.gz
-rw-r--r-- 1 pi pi    91725 Jul 12 16:40 nxcompext-3.5.0-1.tar.gz
-rw-r--r-- 1 pi pi    77293 Jul 12 16:39 nxcompshad-3.5.0-2.tar.gz
-rw-r--r-- 1 pi pi    80194 Jul 12 16:39 nxproxy-3.5.0-1.tar.gz
-rw-r--r-- 1 pi pi    25664 Jul 12 16:39 nxscripts-3.5.0-1.tar.gz
-rw-r--r-- 1 pi pi 20345475 Jul 12 16:39 nx-X11-3.5.0-2.tar.gz
pi@raspberrypi /work/nx $

Unpack all files (use "tar -xzvf <filename>" command), you should have the following directories (I moved gz files to a different directory):

pi@raspberrypi /work/nx $ ls -l
total 32
drwxr-xr-x  2 pi pi 12288 Jun 15  2011 nxcomp
drwxr-xr-x  2 pi pi  4096 May  9  2011 nxcompext
drwxr-xr-x  2 pi pi  4096 May  9  2011 nxcompshad
drwxr-xr-x  3 pi pi  4096 May  9  2011 nxproxy
drwxr-xr-x  2 pi pi  4096 May  9  2011 nxscripts
drwxr-xr-x 10 pi pi  4096 Aug  5  2011 nx-X11
pi@raspberrypi /work/nx $

Now compile individual components, it may take a while, so go grab a cup of coffee and relax:

cd nxcomp
./configure
make

cd nxcompext
./configure
make

cd nxcompshad
./configure
make

cd nxproxy
./configure
make

cd nx-X11
make World

Compiling FreeNX Server

The FreeNX Server source can be downloaded from http://freenx.berlios.de/download.php. The last version is freenx-server-0.7.3. (updated in 2008). Unpack the source and patch it with the gentoo-nomachine.diff patch file that is also packaged in the source file:

pi@raspberrypi /work/nxserver/freenx-server-0.7.3 $ ls
AUTHORS                nxcheckload.sample  nxserver
ChangeLog              nxcups-gethost      nxserver-helper
CONTRIB                nxdesktop_helper    nxserver-suid
COPYING                nxdialog            nxserver-usermode
gentoo-nomachine.diff  nxkeygen            nx-session-launcher
init.d                 nxloadconfig        nxsetup
INSTALL                nxnode              nxshadowacl.sample
Makefile               nxnode-login        nxviewer_helper
node.conf.sample       nxprint             nxviewer-passwd
nxacl.sample           nxredir
pi@raspberrypi /work/nxserver/freenx-server-0.7.3 $ patch < gentoo-nomachine.diff
patching file nxloadconfig
pi@raspberrypi /work/nxserver/freenx-server-0.7.3 $

Now, create a new patch file, e.g. nx_3.5.0.patch with the following context:

--- nxloadconfig.orig   2009-05-26 16:13:02.000000000 -1000
+++ nxloadconfig        2009-05-26 16:13:22.000000000 -1000
@@ -606,8 +606,8 @@
        [ -z $(echo "$ENABLE_ROOTLESS_MODE" | egrep "^[0|1]$") ] && \
                ERROR="yes" && echo "Error: Invalid value \"ENABLE_ROOTLESS_MODE=$ENABLE_ROOTLESS_MODE\""

-       [ -z "$(strings $PATH_BIN/nxagent | egrep 'NXAGENT - Version 1.5.0|NXAGENT - Version 2.[01].0|NXAGENT - Version 3.[012].0')" ] && \
-               WARNING="yes" && echo "Error: Could not find 1.5.0 or 2.[01].0 or 3.[01].0 version string in nxagent. NX 1.5.0 or 2.[01].0 or 3.[012].0 backend is needed for this version of FreeNX."
+       [ -z "$(strings $PATH_BIN/nxagent | egrep 'NXAGENT - Version 1.5.0|NXAGENT - Version 2.[01].0|NXAGENT - Version 3.[012345].0')" ] && \
+               WARNING="yes" && echo "Error: Could not find 1.5.0 or 2.[01].0 or 3.[012345].0 version string in nxagent. NX 1.5.0 or 2.[01].0 or 3.[012345].0 backend is needed for this version of FreeNX."

        [ -z $(echo "$ENABLE_USESSION" | egrep "^[0|1]$") ] && \
                ERROR="yes" && echo "Error: Invalid value \"ENABLE_USESSION=$ENABLE_USESSION\""

And run the patch:

pi@raspberrypi /work/nxserver/freenx-server-0.7.3 $ patch < nx_3.5.0.patch
patching file nxloadconfig

And

make

and

sudo make install


Setting up the NX environment

Now copy the library files and binaries compiled in the above steps to the correct locations.

cd /work/nx
sudo cp -a nx-X11/lib/X11/libX11.so* /usr/NX/lib
sudo cp -a nx-X11/lib/Xext/libXext.so* /usr/NX/lib
sudo cp -a nx-X11/lib/Xrender/libXrender.so* /usr/NX/lib
sudo cp -a nxcomp/libXcomp.so* /usr/NX/lib
sudo cp -a nxcompext/libXcompext.so* /usr/NX/lib
sudo cp -a nxcompshad/libXcompshad.so* /usr/NX/lib 
sudo cp -a nx-X11/programs/Xserver/nxagent /usr/NX/bin
sudo cp -a nxproxy/nxproxy /usr/NX/bin

freeNX server expects to have the file libXrender.so.1.2 but the NX components we compiled has a newer version of libXrender.so.1.2.2 so you need to create a soft link that the installer can follow:

sudo ln -s /usr/NX/lib/libXrender.so.1.2.2 /usr/NX/lib/libXrender.so.1.2

Now, install the NX Server:

sudo /usr/NX/bin/nxsetup --install

You will get some warnings, but you shouldn't get any errors. The test output looks like this:

----> Testing your nxserver configuration ...
Warning: Could not find nxdesktop in /usr/NX/bin. RDP sessions won't work.
Warning: Could not find nxviewer in /usr/NX/bin. VNC sessions won't work.
Warning: Invalid value "CUPS_ETC=/etc/cups/"
         Users will not be able to enable printing.
Warning: Invalid value "DEFAULT_X_SESSION=/etc/X11/xdm/Xsession"
         Users might not be able to request a default X session.
Warning: Invalid value "COMMAND_START_KDE=startkde"
         Users will not be able to request a KDE session.
Warning: Invalid value "COMMAND_START_GNOME=gnome-session"
         Users will not be able to request a Gnome session.
Warning: Invalid value "COMMAND_START_CDE=cdwm"
         Users will not be able to request a CDE session.
Warning: Invalid value "COMMAND_XTERM=xterm"
         Users will not be able to request an xterm session.
Warning: Invalid value "COMMAND_SMBMOUNT=smbmount". You'll not be able to use SA                                                                                                             MBA.
Warning: Invalid value "COMMAND_SMBUMOUNT=smbumount". You'll not be able to use                                                                                                              SAMBA.
Warning: Invalid cupsd version of "/usr/sbin/cupsd". Need version 1.2.
         Users will not be able to enable printing.
Warning: Invalid value "COMMAND_SESSREG=sessreg"
         Logged in users will not be registered with sessreg.

  Warnings occured during config check.
  To enable these features please correct the configuration file.

<---- done

----> Testing your nxserver connection ...
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
ECDSA key fingerprint is c8:4b:0f:7b:72:65:da:4a:5d:f9:c4:9d:f7:5a:46:6f.
Are you sure you want to continue connecting (yes/no)?
Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts.
Fatal error: Could not connect to NX Server.

Please check your ssh setup:

The following are _examples_ of what you might need to check.

        - Make sure "nx" is one of the AllowUsers in sshd_config.
    (or that the line is outcommented/not there)
        - Make sure "nx" is one of the AllowGroups in sshd_config.
    (or that the line is outcommented/not there)
        - Make sure your sshd allows public key authentication.
        - Make sure your sshd is really running on port 22.
        - Make sure your sshd_config AuthorizedKeysFile in sshd_config is set to                                                                                                              authorized_keys2.
    (this should be a filename not a pathname+filename)
  - Make sure you allow ssh on localhost, this could come from some
    restriction of:
      -the tcp wrapper. Then add in /etc/hosts.allow: ALL:localhost
      -the iptables. add to it:
         $ iptables -A INPUT  -i lo -j ACCEPT
         $ iptables -A OUTPUT -o lo -j ACCEPT
pi@raspberrypi /usr/NX/bin $


You are not done yet... Now you need to change the default settings in node.conf file, otherwise you will have this error if you try to connect it using NoMachine NX client:

cat: /usr/NX/var/db/running/sessionId{(STDIN)}: No such file or directory

The problem was caused by MD5 checksum command used in NX server. The default command is to get MD5 check sum in NX is "openssl md5" however it has extra outputs which will confuse NX server.

First, you need to copy the sample node.conf to /usr/NX/etc directory:

cp /work/nxserver/freenx-server-0.7.3/node.conf.sample /usr/NX/etc/node.conf

Now, open it in vi:

sudo vi /usr/NX/etc/node.conf

and replace

#COMMAND_MD5SUM="openssl md5"

To:

COMMAND_MD5SUM="md5sum"

Now all configurations are done!

Connect to Raspberry Pi via NX client

Finally, after the long process you can finally connect to it! Download OpenNX from here, install it. Since Raspberry Pi does not have KDE nor GNOME installed, so you need to config the client to use XDCMP, here is the screen shot of my configuration:

Opennx.jpg

(don't forget to change the IP!)

Then connect to it using your id and password. You are done. Here is what it looks like (my laptop's resolution is 1920x1200, the available area for me is 1914x1138, click on picture to enlarge):

Nxconnected.jpg

Now, have fun! You can buy Raspberry Pi from our store, for $49.99 shipped! Here is the link: Raspberry Pi with Free SD Card

Enjoy your new toy!

Buy Game Console Adapters from http://www.easymg.com or http://www.diygadget.com

Reference:

  1. Installing FreeNX server and NX Open Source Components
Personal tools