Setup a Ubuntu 14.04 LTS (MATE) terminal server with LTSP

In this post I’m going to explain how to set-up a terminal server that you can use at home or in the office; the terminal server (running LTSP) will enable you to run a central terminal server or “mainframe” type network where you can have a large number of “diskless clients” (also know as “dumb terminals” or “thin clients”) connecting to the central server and of which is used to run all the applications.

Once we have set-up our terminal server you can then use any PXE bootable device to connect to our terminal server, you could use a normal desktop PC, a branded “thin client” device and even a Raspberry PI as a super cheap thin client solution!

There are various tutorials on the internet for setting up such an environment but most of them force you to run DHCP on the terminal server itself, in this tutorial I will be configuring a DHCP proxy (dnsmasq) to enable our server to provide PXE boot information whilst still using our existing DHCP server configuration.

So lets get started…

Installing the operating system

I’ve personally chosen to use Ubuntu MATE distribution as I perfect the Gnome 2 style desktop environment but this tutorial should work exactly the same for the standard Ubuntu distribution, Lubuntu, Xubuntu and potentially any other Ubuntu derivative!

So, I’ll assume now that you’ve installed the operating system and logged in using your account that you setup during installation!

At this point it would also be advisable that you set a static IP address on your server!

Installing the LTSP server, dnsmasq and the TFTP server

We need to install the following software of which makes up all the core of what we will need for our setup; lets run the following commands:

sudo apt-get update
sudo apt-get install ltsp-server dnsmasq tftpd-hpa

As you probably noticed we are installing three pieces of software here, firstly we install the ltsp-server package (note that we’re NOT installing the ltsp-server-standalone package as this will force the installation of a DHCP server on our Terminal server of which will break our “existing” DHCP set-up) secondly we’re installing dnsmasq; Dnsmasq will provide us with the DHCP proxy functionality of which will enable us to use our existing DHCP server on our network and then still provide the required PXE boot information and then last but not least we install tftpd-hpa of which provides us with TFPP functionality thus allowing our “thin clients” to download the boot images.

Though Dnsmasq can do both DHCP and TFTP, There has been a crucial bug identified when functioning as a TFTP server specifically with Ubuntu 14.04, so we’ll be using the tftpd-hpa package for managing the TFTP services instead.

Building the “thin client” images

Now that the server has the packages installed, we now need to generate the “thin client” bootable image, this image is based on the current terminal server’s setting and is then served to our “thin clients” via. TFTP when they boot using PXE.

 sudo ltsp-build-client --arch i386

The above command will take some time as it will download all packages for this stripped-down Ubuntu-based “thin client” operating system and install them under: /opt/ltsp/i386/. It will then compress this into /opt/ltsp/images/i386.img, this is the the actual image that will be served to the client via. TFTP.

If you wish to build x64 client images (although these won’t work for older hardware and the Raspberry Pi’s) simply omit the ‘–arch i386‘ from the above command and all other related commands in this post, you’ll also have to pay special attention to the rest of this post as you’ll need to manually updated paths in the configuration files.

It is worth noting that client boot image will be based on your current Ubuntu version using the at the current state of packages in its repositories. Since this is merely a thin client operating system, it shouldn’t really matter if the image is stays “old”, as long as it works. Remember, the software is actually running on your server, not the client!

Enabling DCHP proxy support in our image

The configuration of PXELINUX does not ship with support for DCHP Proxy support by default so we need to fix this by running the following command:

sudo sed -i 's/ipappend 2/ipappend 3/g' /var/lib/tftpboot/ltsp/i386/pxelinux.cfg/default

Note: If you’ve chosen to build the 64bit version of the LTSP client images, you’ll need to replace the i386 directory with amd64.

It is also important to note that if you update your thin client images using the command below (in the Upgrading your “thin client” boot images section) that you’ll have to re-run this command afterwards!

Creating the LTSP configuration for Dnsmasq

Next we need to create a new configuration file so that Dnsmasq will provide the PXE boot information and thus serving our boot image using our new TFTP server.

Create the new configuration file by running this command:

sudo nano /etc/dnsmasq.d/ltsp.conf

….then add the following configuration (copy and paste) to the file:

########################################
# Dnsmasq running as a proxy DHCP
########################################

#
# TFTP
#
#enable-tftp
#tftp-root=/var/lib/tftpboot

#
# DHCP
#
dhcp-range=192.168.1.0,proxy
# Tell PXE clients not to use multicast discovery
# See section 3.2.3.1 in http://tools.ietf.org/html/draft-henry-remote-boot-protocol-00
dhcp-option=vendor:PXEClient,6,2b
# Better support for old or broken DHCP clients
dhcp-no-override
# Enable this for better debugging
#log-dhcp

#
# PXE
#
# Note the file paths are relative to our "tftp-root" and that ".0" will be appended
pxe-prompt="Press F8 for boot menu", 3
pxe-service=x86PC, "Boot from network", /ltsp/i386/pxelinux
pxe-service=x86PC, "Boot from local hard disk"

Before saving the file ensure that you update the dhcp-range setting to match your network settings and, if applicable the “i386” in the /ltsp/i386/pxelinux path and “x86PC” section in the pxe-service section at the bottom of this configuration file.

The last thing we need to do now is to restart the the dnsmasq service using the following command:

sudo service dnsmasq restart

Great, we’re now ready to test it out… You can now either create a virtual machine in Oracle VirtualBox, setting the network adapter type to ‘bridged’ you should now be able to start it (and if Network boot is enabled) and you will, after a few seconds see the LTSP client login screen like so…

Ubuntu LTSP Client Login screen.

 

Upgrading your “thin client” boot images in future….

It is possible to upgrade this image to latest Ubuntu packages this will include updates for hardware drivers too, this something that you might want to do once in a while and for security reasons this is good practice, it’s simply a case of running the following command from the terminal on your server:

# Regenerate the thin client boot image
sudo ltsp-update-image

# As mentioned above we need to reset the PXELINUX DCHP proxy settings:
sudo sed -i 's/ipappend 2/ipappend 3/g' /var/lib/tftpboot/ltsp/i386/pxelinux.cfg/default

For these changes to take affect, you’ll need to reboot your “thin clients” in order for them to download and use the new image.

Changed your server IP address after the initial installation of LTSP?

If after this point you change your IP address on the LTSP  server you need to update your ssh keys and rebuild your client image using the following commands (the first one updates our SSH keys and the following two are our standard “rebuild the client image” commands):

sudo ltsp-update-sshkeys
sudo ltsp-update-image
sudo sed -i 's/ipappend 2/ipappend 3/g' /var/lib/tftpboot/ltsp/i386/pxelinux.cfg/default

…then reboot your “thin clients” for the changes to take affect!

Understanding how the “thin client” devices boot

The network boot process is a two process so in order to download, decompress and boot into the i386.img (or amd64.img depending on your choice during installation) we need a network OS bootloader; so once our thin-client has got it’s IP address from our existing network DHCP server, it will then receive TFTP information from our DHCP Proxy server (provided by our new terminal server) and then load the network OS bootloader of which is provided by PXELINUX, PXELINUX is a tiny Linux-based bootloader. The “ltsp-build-client” command that we ran above created it for us under /var/lib/tftpboot/ltsp/i386/. It is approximately 20MB in size. So, the client gets this pxelinux directly over TFTP and executes it, PXELINUX then downloads the i386.img image files, decompresses it into a RAM drive, and then boots.