There does not appear to be a good explanation available on the
newsgroups for how to set up a swap partition on diskless workstation
or server using FreeBSD 4.5x or more recent versions. I'm using a
RAID-5 nfs and dhcp server. It provides the diskless clients with the
O/S via tftpboot/pxeboot and also provides all the software/data used
in serving web pages in my particular case.
I'm not going to go into how to set up the diskless workstations. The
documentation is out there if you look hard enough. Providing swap
space for the diskless clients, however, has proved elusive. I've
read a lot about adding lines to the dhcpd.conf file like:
option swap-path code 128 = string;
option swap-size code 129 = integer 32;
option swap-path "192.168.4.4:/netswapvolume/netswap";
option swap-size 64000 ;
Whatever... - When I add this stuff to dhcpd.conf and restart dhcpd I
get syntax error messages. I assume that worked for earlier versions
of FreeBSD but not with 4.5x from my experience.
Here's how I was able to get it to work without adding any lines to
dhcpd.conf.:
A. Create a swap file in a filesystem of the nfs server that is
mounted read/write (rw) by the diskless workstation. Do not use the
root partition of the dhcp server which provides the O/S and config
files as it is read only.
(The info in the FreeBSD handbook
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/adding-swap-space.html
works just fine. You don't have to create the file with the
diskless workstation but you can if you want it to take a little
longer.)
Example 6-1. Creating a Swapfile on FreeBSD 4.X
1.Be certain that your kernel configuration includes the vnode
driver. It is not in recent versions of GENERIC.
pseudo-device vn 1 #Vnode driver (turns a file into a device)
2.create a vn-device:
# cd /dev
# sh MAKEDEV vn0
3.create a swapfile (/rw_directory/swap0):
# dd if=/dev/zero of=/path_to_mounted_rw_directory/swap0 bs=1024k
count=64
(this creates a 64 megabyte swap. If you want more/less change the
count=)
(where mounted_rw_directory is a directory on the nfs server that gets
mounted rw by the diskless server
for example: /usr/local/mount/swap0 )
4. set proper permissions on (/usr/swap0):
# chmod 0600 /path_to_mounted_rw_directory/swap0
5. enable the swap file in /etc/rc.conf:
swapfile="/path_to_mounted_rw_directory/swap0" # Set to name of
swapfile if aux swapfile desired.
-This line is placed in the rc.conf file used when the diskless
workstation boots. It is located on the dhcpd server.
(In my system it is located in:
/usr/local/diskless/conf/192.168.1.x/etc/rc.conf)
6. Reboot the machine or to enable the swap file immediately, type
(using the diskless workstation):
# vnconfig -e /dev/vn0b /path_to_mounted_rw_directory/swap0 swap
Run top and you should see that swap is now present.
Voila! That wasn't so tough, after all.
-Neil