r4 - 18 Jan 2007 - 11:43:46 - MichaelShigorinYou are here: TWiki >  Ltsp Web  > Swap

Swap

This page is for showing various ways to handle swapping on the client.

Introduction

LTSP includes the ability to swap over the network. This may sound counter-intuitive, but it really does work pretty well. If you have a machine with low memory (32mb or less), enabling swap can make all the difference in the world. Without swap, if the terminal runs out of memory, the kernel will go on a killing spree. There are only a few processes running, and almost always, the Xserver is the first one killed. If that happens, the user loses their session.

So, if you enable swap, you'll have a safety net. The terminal may slow down a bit, but that is certainly better than the user losing their session completely.

There are 2 default ways of configuring swap in the terminals:

  • NBD-Swap: This is the default method of supplying swap over the network in LTSP-4.2 and later. It uses NBD (Network Block Device) and has replaced NFS-Swap, which is not available in the 2.6.x series kernels starting in LTSP-4.2.

  • NFS-Swap: This is the default method of supplying swap over the network in LTSP-4.1 and earlier. It uses NFS (Network File System) and requires a kernel path for the client, but is not supported in the 2.6.x kernels.

Swap for LTSP 4.2 and Later: NBD and ltspswapd

The LTSP Swap Daemon: ltspswapd

A new daemon that runs on the server, ltspswapd, provides NBD swapfile management. It can be installed by installing the LTSP localdev support package. Since it's a hacked nbd-server, no separate nbd package is required on terminal server (in case you wondered).

Installing ltspswapd

Download and install the LTSP localdev support package as described.

OpenSUSE

At least OpenSUSE 10.1 Retail (pls add info for other versions) contains a RPM-Package for NBD-Damon, which can be installed through YAST or the other valid installation-services. You still need to configure it according "Configuring ltspswapd".

-- AlfredPoschmann - 06 Nov 2006

Mandriva 2006 and Some Other RPM-based Distros

If there isn't a rpm package for your distro, you can try cheating and install the Fedora rpm on Mandriva 2006 and some other RPM-based distros. However, some manual configuration may be necessary, covered under "Configuring ltspswapd".

Otherwise, install the localdev support package from the tarball of statically built binaries as described.

Configuring ltspswapd

Configuration of ltspswapd is done in /etc/sysconfig/ltspswapd. The ARGS entry specifies the various options available (don't forget to include the quotes):

ARGS="[-p <portnum>] [-s <path_to_swapfiles>] [-z <swapsize>] [-d]"

where

<portnum>            port number              (default=9210)
<path_to_swapfiles>  swap path on the server  (default=/var/spool/ltspswap) 
<swapsize>           swap file size           (default=64mb)
-d                   enables debugging

Ensure that the path specified by the -s <path_to_swapfile> in /etc/sysconfig/ltspswapd actually exists. If there is no path specified in /etc/sysconfig/ltspswapd, make sure the default path (/var/spool/ltspswap) exists. Ensure that the directory is owned by root:root and set the permissions to 775.

Note: The settings in /etc/sysconfig/ltspswapd apply to all terminals that have swap enabled with USE_NBD_SWAP=Y in lts.conf. Unlike NFS-Swap, different settings cannot be applied on a per-terminal basis.

Mandriva 2006 and Some Other RPM-based Distros

Ensure that the following 3 lines exist in the file /etc/rc.d/init.d/ltspswapd, immediately below the line beginning with #chkconfig. If they don't, then add them:

# description: Enable NBD swapping from ltsp terminals
# processname: ltspswapd
# config: /etc/sysconfig/ltspswapd

Then, as root, run:

chkconfig --add ltspswapd
service ltspswapd start
The first command adds ltspswapd to the /etc/rc[0-6].d directory hierarchy so it starts at server boot, and the second command starts ltspswapd on the server immediately.

Debian

To start the ltspswapd service at boot, as root, run:

update-rc.d ltspswapd defaults

Configuring the terminal

In your lts.conf file, either in the [Default] section, or on a per-terminal basis, add the line:

USE_NBD_SWAP = Y

Boot/Reboot the terminal

Boot/reboot a terminal that is configured for NBD-Swap.

-- JohnNew - 2 Nov 2006

Swap for LTSP 4.1 and Earlier: NFS

There's a couple of parameters that can be set in lts.conf:

USE_NFS_SWAP

This defaults to N. If you set it to Y, it will enable NFS Swap

SWAPFILE_SIZE

This is how you control how large the swap space will be. The default is 64m (megabytes).

SWAP_SERVER

This is how you can control which server on your network will hold the swap files. The default for this setting is NFS_SERVER, which defaults to SERVER.

NFS_SWAPDIR

This controls where on the NFS server the swapfiles directory will reside. The default is /var/opt/ltsp. There needs to be a subdirectory called swapfiles within that location. Also, the location must be exported in the servers /etc/exports file.

-- JimMcQuillan - 16 Mar 2005

Swap for LTSP 4.1 and Earlier: NBD

Peter Childs has written up a document on swapping over NBD. Please note that this method of swapping over NBD is for LTSP 4.1 and earlier. If you are running LTSP 4.2 and later and want to use NBD-Swap, see the section Swap for LTSP 4.2 and Later: NBD and ltspswapd, above.

Confirming Swap is Enabled on a Terminal

You can confirm that a terminal has been set up for swap:

Run free at a shell prompt on the terminal (not an X-session). On the "Swap:" line, under the "total" column, you should see the amount of swap space (in kB) that you have allocated in either /etc/sysconfig/ltspswapd or lts.conf (depending on the swap method used). If this number is 0, then swap has not been enabled.

or

If you are going to be installing and troubleshooting swap on a lot of terminals, consider using ltspinfo. That way you can query any terminal's memory from an X-session. In your lts.conf file, add:

ALLOW_PROCREAD = Y

to the [Default] section. Adding this in the [Default] section allows you to query any terminal. After a client boots, you can then use

ltspinfo –host=<hostname> -proc=meminfo
to query the memory usage of any terminal; replace <hostname> with the hostname of the terminal you are querying. The line labelled SwapTotal in the output should equal the amount of swap space (in kB) that you have allocated in either /etc/sysconfig/ltspswapd or lts.conf (depending on the swap method used). If this number is 0, then swap has not been enabled.

-- JohnNew - 2 Nov 2006

Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r4 < r3 < r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback