Swapping over NBD
Overview
Swap space is important to a thin client. There are a number of ways of configuring it and is not a difficult thing to get working correctly with the latest version of LTSP.
Any thin client with less than 32Mb will need some swap. Thin clients running
LocalApps or a printer will require more swap space than those that don't.
There are 3 known ways of configuring swap in the terminals:
- SwapHardDisk in the thin client: This can be useful if the computer doubles as a Windows computer.
- 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.
- 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.
- Slimline server purpose built for serving blocks to the clients ideal for Linux swap space.
- Speed should be faster.
- More Reliable.
- More Secure because the terminal can't write to anything but the one file created for the swap space, and so it can't write rubbish to your harddisk.
Configuring Swap over NBD in LTSP-4.2 and Later
To configure swap in LTSP-4.2 and Later, see
the main Swap topic in the
LTSP 4.2 and Later section.
--
JohnNew - 2 Nov 2006
Configuring Swap over NBD in LTSP-4.1 and Earlier
I'm trying to collect some comments on how to set this up as I go the formatting should improve.
This is the current job list to get nbd swap working:
Startup nbd-server on your server
nbd-server 3000 /var/opt/ltsp/swapfiles/%s.swap 32m
ought to work 3000 (is a port number), %s gets changed to the clients ip address. 32m is the size and its optional. I use debian and these settings can be entered into dpkg-configure.
I've had a problem with this freezing after the first client disconnects, It seams that nbd-server is a little unstable. needs more testing.
--
KarlBowden - 23 Mar 2006 - I have tested this on debian with nbd-server-2.8.3 without any crashes or freezing.
--
DanielMusketa - 18 Jun 2006 - There's a syslog filling infinite loop when the client disconnects in nbd-server-2.8.3-_1_ which is used in ubuntu Dapper and could be fixed by a one-liner from Debian's 1:2.8.3-2.
--
DanielMusketa - 22 Jun 2006 - The fix is now available in dapper-updates.
Create the swapfiles
dd if=/dev/zero of=/var/opt/ltsp/swapfiles/%s.swap bs=1M count=32
might be worth modifying nbd-server to auto create the swapfiles if they don't exsist of the correct size since it knows all the details required already. modifing it should be easy but I'll might work on this once its completly working. it would create a ndb-swap-server!
Format the swapfiles
mkswap does this this it can be left till you have them on the client but the web sites that says anything on nbd say this should not work (it seams to?) but this could also be done by nbd-server when it creates them and hence speed up boot time of the client.
mkswap /var/opt/ltsp/swapfiles/%s.swap
should do the trick, you will need to replace %s with the correct ip in each of the two previos tasks.
Modify your ltsp client server to include the nbd swap patch
After a lot of checking you don't need to patch your kernel at all if blkdev_swap is compiled as a module you need to ensure it is loaded before you use swap, a call to modprobe blkdev_swap does that. The internet is not partically clear on this feature.
Add nbd-client to your client files
Its a very small utility like mount, or swap on for mounting the nbd devices I need to check it compiles on lbe.
modify the startup scripts
Note:: modprobe blkdev_swap is not needed on ltsp-kernel-2.6.9 --
KarlBowden - 23 Mar 2006
The startup scripts need to be modified to do the following:
- modprobe nbd
- modprobe blkdev_swap
- nbd-client server 3000 /dev/nbd/0
- swapon /dev/nbd/0
The docs seam to think that you need to call nbd-client with a -swap parameter however this causes Step 3 freeze. So if you leave the -swap off it seams to work however the few comment on the internet seam to say this could cause nbd to swap its self out and crash.
Ok The patch to the startup scripts this goes in /opt/ltsp/i386/etc/rc.sysinit just before or after the bit about nfsswap.
if [ "${USE_NBD_SWAP}" = "Y" ]; then
modprobe nbd
modprobe blkdev_swap
SWAP_SERVER=${SWAP_SERVER:-${DEFAULT_SERVER}}
SWAP_PORT=${SWAP_PORT:-3000}
nbd-client ${SWAP_SERVER} ${SWAP_PORT} /dev/nbd/0
swapon /dev/nbd/0
fi
It is possible to drop the need for nfs at all if you create your ltsp root as a nbd and pivot root to that instead, however I've never tried this and it sounds like a major job and updating you client files would be alot more hard work. But if you wanted to lock down your clients it would work.
--
PeterChilds - 5 Apr 2005
Also confirming this all works great with clients with 2.6 series kernels. (Espically handy as
NfsSwap? does not work on 2.6 kernels). --
KarlBowden - 23 Mar 2006