NFS Swapping allows any thin-client workstation to supplement its built in RAM with virtual memory. However, since virtual memory is usually supplied by a secondary storage device (i.e., a hard drive, flash memory, etc.) and the thin-client has no secondary storage devices for this purpose (in a true thin-client sense), the network is the only alternative. "Network swapping" as it is usually called is obviously much slower than having a much faster and more capable secondary storage device for doing virtual memory swapping. In our experience, using LTSP you can get away with having around 32MB of memory on the workstation if you limit yourself to running remotely (i.e., logging into the server instead running local applications) and do not open more than approximately 25 - 30 windows at a time. If your needs exceed these limitations, or you have less than 32MB RAM in your workstation(s), you will most likely need to implement virtual memory to supplement the available RAM. We recommend bringing the total amount of RAM (physical and virtual) to at least 32MB. When implementing virtual memory swapping over the network, you will notice a performance decrease when the swapping actually occurs. But, if the application can completely fit into memory, once it is pulled back into memory, the workstation becomes just as responsive and functional as before the swapping took place. With slow networks (10 Mb/s and even 100 Mb/s, unswitched), the workstation can appear to lockup for a few seconds at a time while swapping occurs. With the correct read-size and write-size options when mounting the NFS swap file, I have not experienced a workstation "lockup" that actually caused the machine to lockup. After a few seconds (typically less than a minute), the machine would come "back to life" and keep working. This only occurs for us on our 486 machines with 8MB RAM. On the Pentium class computers we run as thin-client workstations, network swapping only causes the workstation to slow down momentarily. The faster the network speed and available bandwidth, the less often these "issues" will be experienced. We recommend nothing less than a 100 Mb/s, switched network. :)
Installation
Setting up NFS swapping for your workstations consists of modifying the kernel by patching it with the NFS swapping patch, making sure the correct executables are in the /ltsbin directory for the rc.local script to use, and exporting the proper mount point from the server you wish to handle the swap files for your workstations.
Kernel Changes
To begin with, you have to obtain the patches for NFS swapping from Claus-Justus Heine's website, here. After you have downloaded the patch file for the particular kernel you want to use (it works fine with kernel 2.2.14), patch the kernel source with the NFS swapping patch. Then use your favorite method to make changes to the kernel (make menuconfig, make xconfig, etc.).
You need to make the following changes:
In the "Networking options" section, enable "Swapping via network sockets". Make sure this is compiled in and not a module.
Under the "Network File Systems" section which is found under the "Filesystems" section, say yes to "Swapping via NFS". This feature is now able to be compiled into the kernel instead of only being included as a module.
Make sure that all the settings you need to support the particular hardware you have on your thin-client workstations (network cards, sound cards, floppy/ide support, etc.) are included in your custom kernel configuration.
Compile your kernel.
That's all there is to setting up the necessary changes in the kernel for making NFS swapping a breeze!
Copying Necessary Files to /ltsbin
If you did not download and install our custom root directory, you will need to make sure the following program exists in /ltsbin:
swapon
The swapon command tells the kernel to use the exported file as virtual memory for the workstation.
The Swapping NFS Export Directory
This step consist of modifying /etc/exports for the server on which you wish to store the NFS swap files for each of your workstations. A good default location would be something like /var/swap. This will need to be able to be mounted read-write by any workstation that connects to it.
How It All Works
When a workstation boots up, if USE_NFS_SWAP is enabled for the workstation and the appropriate settings for NFS_SWAP_SERVER and NFS_SWAP_PATH have been set (either on a per workstation basis, or in the Default section of LDAP or lts.conf), the workstation will attempt to use NFS swapping. rc.local mounts the <NFS_SWAP_PATH> exported by the <NFS_SWAP_SERVER> and searches for the file swapfile.<MAC_ADDRESS>. The <MAC_ADDRESS> is the MAC address of the booting workstation (colon separated string of the form AA:BB:CC:DD:EE:FF). If the file exists, then rc.local unmounts the mount point and remounts the /swap directory in the root directory of the workstation with the file that matches the workstation's MAC address. rc.local then issues a swapon on the /swap directory to bring the NFS swap file online for the kernel to swap to.
However, if the file does not exist, rc.local asks the user if they want to create the file. If the user answers "yes" (y/Y), the user will be prompted to enter the size in KB of the swapfile to create on the server. If the size entered is greater than 0, rc.local uses dd to copy the number of bytes from /dev/zero to the swapfile for the workstation. If the user does not want to create the file, the directory is unmounted and the workstation is booted without NFS swapping. After the file has been created, rc.local unmounts the directory and remounts /swap to the swapfile it just created. It then issues a swapon to /swap to make the kernel use the NFS swapfile.