Network Swap

Helping thin clients with smaller amounts of ram

Just like on a full fledged workstation, it helps to have swap defined for your thin client. "Swap" is an area of disk space set aside to allow you to transfer information out of ram, and temporarily store it on a hard drive until it's needed again. It makes the workstation look like it has more memory than it actually does. For instance, if your workstation has 64 Megabytes of ram and you configure 64 Megabytes of swap, it's theoretically possible to load a 128 Megabyte program.

I say, "theoretically", because in practice, you want to avoid swapping as much as possible. A hard drive is several orders of magnatude slower than ram, and, of course, on a thin client, you don't even have a hard drive! You have to first push the data through the network to the server's hard drive, thus making your swapping even slower. In practice, it's best to make sure you have enough ram in your thin client to handle all your average memory needs.

However, sometimes that's not possible. Sometimes, you're re-using old hardware, or you've simply got a program that isn't normally used, but does consume a lot of ram on the thin client when it does. Fortunately, LTSP supports swapping over the network via NBD, or Network Block Devices. We include a small shell script called nbdswapd, which is started via inetd. It handles creating the swap file, and setting up the swapping, and removing the swap file when it's no longer needed, after the terminal shuts down.

By default, swap files are 32 Megabytes in size. This was chosen to give your workstation a little extra ram, but not use up too much disk space. If you get some random odd behaviour, such as Firefox crashing when viewing web pages with a lot of large pictures, you may want to try increasing the size of the swap files. You can do so by creating a file in the directory /etc/ltsp on the Edubuntu server, called nbdswapd.conf. In it, you can set the SIZE variable to the number of Megabytes you wish the file to be sized to. For instance, to create 128 Megabyte files, you'll want:

SIZE=128
            

in the nbdswapd.conf file.

Please note that this is a global setting for all swap files. If your server has 40 thin clients, each using 128 Megs of memory, you'll need 128 * 40 = 5120, or a little over 5 Gigabytes of space in your /tmp directory, where the swapfiles are stored.