LTSP Live server on USB memory sticks

LTSP Live server allows you to boot USB memory stick as a virtual filesystem and publish the virtual filesystem and it’s applications for users. The virtual filesystem also prevents overuse the sticks write/erase cycles, write limit is usually 10,000 to 1,000,000 write operations.

The setup of LTSP Live is easy. It works on Ubuntu 16.04 LTS with upstream LTSP. Setup includes LTSP server and PXE booting and it also enables you to login with local users in temporary environment. Booting the stick requires no extra hardware or software on your computer. LTSP server is available as soon as you plug it into a network dedicated to the clients. Just plug in and boot the clients.

What works?

  1. Boot the stick
  2. Install packages in it
  3. Configure and manage clients and their services in the whole network
  4. Boot a client with only 256MB RAM
  5. Modify the stick
  6. It’s LTSP server

Benefits:

  • Very light operating system/server
  • Minimize sticks writes
  • Minimize RAM when running the LTSP server

Setup

This LTSP setup below supports both thin and fat clients. No chroots are used.

System requirements

For 1 PXE booted thin client, XDMCP session minimum is:

  • x32/x64 machine

    1 GHz (Single CPU)

    2,5 GB RAM 

    8 GB  - 25 GB disk space (USB 2.0/3.0 flash memory or external hard drive) 

    Ubuntu 16.04 LTS

Get the Ubuntu 16.04 LTS from http://www.ubuntu.com/download/desktop.

Install Ubuntu to the USB flash memory or external USB disk. It’s better to install the 32-bit Ubuntu system when you are not 100% sure that all the clients have the 64-bit architecture.

Connect available NIC to a network switch / hub and setup this NIC static in network configuration. You will attach thin clients to the same network with the static NIC. A dual NIC setup is recommended but not required.

1. First enable the Network Manager configuration to allow control of your network adaptor with fixed IP.

Change config file /etc/NetworkManager/NetworkManager.conf:

NetworkManager.conf 
[ifupdown] 
managed=true  

2. Configure the second interface to use IP 192.168.67.1. Set up the IP classic way to ensure the DHCP server starts correctly.

Add this information in/etc/network/interfaces:

auto eth0 
iface eth0 inet static 
address 192.168.67.1 
netmask 255.255.255.0  

If you have setup problems with the NetworkManager and interfaces read the troubleshooting section at the end of this page before you continue. If you think you are ready continue instructions below to install LTSP.


Install LTSP server

apt-get install --yes --install-recommends install ltsp-server-standalone ltsp-client ldm-ubuntu-theme dnsmasq 
ltsp-config dnsmasq 
echo 'IPAPPEND=3' >> /etc/ltsp/update-kernels.conf 
/usr/share/ltsp/update-kernels  

Put this in /etc/lts.conf:

[Default] 
SCREEN_07 = "lightdm" 
 
HOSTNAME=liveltsp 
LDM_SERVER=localhost 
LTSP_FATCLIENT=True 
LDM_SSHOPTIONS="-o StrictHostKeyChecking=no -o CheckHostIP=no -o LogLevel=silent" 
NBD_SWAP=False 
DNS_SERVER="127.0.0.1" 
NET_DEVICE_METHOD="dhcp" 
 
INIT_COMMAND_01="sed 's/if .*stat.*;/if true;/' -i /usr/share/ldm/rc.d/X01-localapps" 
INIT_COMMAND_02="sed 's/\(group = \).*/\1disk/' -i /etc/nbd-server/config" 
 
KEEP_SYSTEM_SERVICES="dnsmasq nbd-server ssh whoopsie x2goserver irqbalance openbsd-inetd virtualbox network-manager epoptes avahi-daemon cron anacron bluetooth rsyslog cups dbus atd acpid upstart-udev-bridge" 

It doesn’t make sense to use local swap from the stick when overlayfs has mounted the whole file system in RAM. Writable data is stored in volatile memory - unless you setup grub to boot permanently in read-write mode

Update the server public ssh keys

ltsp-update-sshkeys –u localhost 

Configure LightDM

Logging in from LightDM requires a screen script. Create file /usr/share/ltsp/screen.d/lightdm with the following contents:

trap cleanup 0 INT QUIT TERM  
cleanup() 
{ 
if [ -f "/tmp/.X${TTY}-lock" ]; then  
rm -f "/tmp/.X${TTY}-lock"  
fi  
if [ -S "/tmp/.X11-unix/X${TTY}" ]; then  
rm -f "/tmp/.X11-unix/X${TTY}"  
fi  
}  
. /usr/share/ltsp/screen-x-common  
/usr/sbin/lightdm  

Add execute permissions to the screen script:

chmod a+x /usr/share/ltsp/screen.d/lightdm 

Update initramfs settings

Booting LTSP server cow mode from localhost needs configuration in /usr/share/initramfs-tools making it boot the LTSP server not over the network (where from the LTSP clients boot)

First make a backup of the original initramfs-tools directory:

cd /usr/share 
cp -r initramfs-tools initramfs-tools_backup 
cd initramfs-tools  

Change scripts/init-premount/udhcp: Find row: # Exit if an LTSP boot was not requested 

Add below that line following text:

# Don’t wait for a network up if localhost is the LTSP server 
 grep -Eqsw "serverip=127.0.0.1" /proc/cmdline && exit 0 

Update the initramfs:

cp /boot/initrd.img-X.X.X-XX-generic /boot/initrd.img-X.X.X-XX-generic_original 
update-initramfs -u 

Configure the server

To create the initial TFTP and NBD configuration you need to run the following command.

ltsp-update-image --cleanup / 

This updates /var/lib/tftpboot directories (i.e. pxelinux.0 and pxelinux.cfg and the latest kernel to /var/lib/tftpboot/ltsp/i386/). This will also configure nbd-server and nbd-client as well as create the first squashfs image for nbd in /opt/ltsp/images.

If it didn’t report creating /etc/nbd-server/conf.d/swap.conf and /etc/nbd-server/conf.d/ltsp_i386.conf, then on the command line run:

ltsp-config nbd-server 

The nbd-server will directly serve the stick as the image for LTSP clients, there is no requirement for the additional /opt/ltsp/images/i386.img. You can just remove the additional image file and replace it with symlink:

rm /opt/ltsp/images/i386.img 

Symlink /opt/ltsp/images/i386.img to /dev/disk/by-uuid/path-to-the-stick-partition:

ln –s /dev/disk/by-uuid/path-to-the-stick-partition  /opt/ltsp/images/i386.img  

Symlink also /opt/ltsp/i386 to /:

ln –s / /opt/ltsp/i386 

Whenever the server is updated – the new software on the usb stick is served to the clients on the network. Remember the stick is in frequent use. To prevent the usb stick from wearing out, configure it to boot by default in cow mode. Read below instructions to configure it.

Configure GRUB

Run command:

dpkg-reconfigure grub-pc 

Follow instructions and add the following to the cmdline

  • init=/sbin/init-ltsp serverip=127.0.0.1 rootflags=noload

Initial lts.conf configuration for thin clients

Create default lts.conf by running:

ltsp-config lts.conf  

The default LTSP configuration is for fat clients which means that the clients will always default to LTSP_FATCLIENT=True. If you want to run a mix of fat and thin clients or only thin clients, you will need to use the parameter FAT_RAM_THRESHOLD. That parameter defaults to 300 (MB).

E.x. force all your clients to boot as thin clients only, edit lts.conf and put:

FAT_RAM_THRESHOLD=8000 

Restrict LTSP services

It's recommended that you don't run LTSP server with too many services exposed to other networks. If possible, the services required by LTSP should be restricted to local network access only.

You can check all running network services running commands:

ss –anup 

netstat –a 

DHCP/TFTP

1. Change config file /etc/dnsmasq.d/ltsp-server-dnsmasq.conf:

listen-address=127.0.0.1,192.168.67.1 

This will restrict TFTP to listen only on these specified addresses. It also restricts dnsmasq to handle DHCP requests only on these specific addresses

2. SSH

Add this information in file /etc/ssh/sshd_config:

ListenAddress 127.0.0.1 
ListenAddress 168.67.1.1 

3. NBD

Create and add this information in file /etc/ltsp/nbd-server.allow: (This would be good without Ubuntu bug #1009393. )

nbd-server 
/etc/ltsp/nbd-server.allow 
127.0.0.1/32 
192.168.67.0  

Due to Ubuntu bug #1009393 trying to use authfile = /etc/nbd-server/allow the nbd-server ignores all configuration in nbd-server. https://bugs.launchpad.net/ubuntu/+source/nbd/+bug/1009393

Reboot your LTSP Live server

At this point your server should be ready to try from client network.


Troubleshooting

1. Cannot use the Network Manager to control the network adaptor with fixed IP

Don’t use NetworkManager to setup the static IP. Use it only to control the ifupdown of the static interface.

2. DNS breaks when port=0 is used in dnsmasq.conf

sudo -i 
sed 's/^dns=dnsmasq/# Commented by ltsp-pnp: dns=dnsmasq/' \ 
    -i /etc/NetworkManager/NetworkManager.conf 
sed 's/^port=0/# Commented by ltsp-pnp: port=0/' -i /etc/dnsmasq.d/ltsp-server-dnsmasq.conf 
service network-manager restart 
service dnsmasq restart 

3. nbd-client causes service ordering cycles in Ubuntu 16.04

sudo dpkg-divert --rename --divert /etc/nbd-client.init /etc/init.d/nbd-client 

4. Sound, localapps or localdev is not working

The problem is usually that you have launched local and remote Xsessions and the other is still open. If Xsession is first launched on the server locally then some time after new Xsession is launched remotely (XMDCP/SSH-X/NX), the still active Xauthority in the home directory is having different magic cookie from the remotely launched Xsession. To fix it the existing $HOME/.Xauthority file needs to be removed manually on the server or the server needs to restart.

See also

  1. LTSP-PNP - The recommended way to install and maintain LTSP on Ubuntu versions >= 12.04


CategoryLtsp

UbuntuLTSP/LTSPLiveUSB (last edited 2017-02-08 21:31:01 by vsuojanen)