[OpenBSD]

11-2.5 - OpenBSD 2.5 Specific Information


11.1 - Swapping in OpenBSD 2.5

(Note: if you are looking to swap to a file because you are getting "virtual memory exhausted" errors, you should try raising the per-process limits first with csh's unlimit(1), or sh's ulimit(1).)

OpenBSD 2.5 uses swapon to deal with swapping. Swapping to a file doesn't require a custom built kernel, although that can still be done, this faq will show you how to add swap space both ways.

Swapping to a file.

Swapping to a file is easiest and quickest way to get extra swap area's setup. This is not for users who are currently using Softupdates. (Which isn't enabled by default). To start out, you can see how much swap you are currently have and how much you are using with the pstat(8) utility. You can do this by using the command:

This shows the devices currently being used for swapping and their current statistics. In the above example there is only one device named "swap_device". This is the predefined area on disk that is used for swapping. (Shows up as partition b when viewing disklabels) As you can also see in the above example, that device isn't getting much use at the moment. But for the purposes of this document, we will act as if an extra 32M is needed.

The first step to setting up a file as a swap device is to create the file. It's best to do this with the dd(1) utility. Here is an example of creating the file /var/swap that is 32M large.

Once this has been done, we can turn on swapping to that device. Use the following command to turn on swapping to this device

Now we need to check to see if it has been correctly added to the list of our swap devices.

Now that the file is setup and swapping is being done, you need to add a line to your /etc/fstab file so that this file is configured on the next boot time also. If this line is not added, your won't have this swap device configured.

Swapping via a vnode device

This is a more permanent solution to adding more swap space. To swap to a file permanently, first make a kernel with vnd0c as swap. If you have wd0a as root filesystem, wd0b is the previous swap, use this line in the kernel configuration file (refer to compiling a new kernel if in doubt):

After this is done, the file which will be used for swapping needs to be created. You should do this by using the same command as in the above examples.

Now your file is in place, you need to add the file to you /etc/fstab. Here is a sample line to boot with this device as swap on boot.

At this point your computer needs to be rebooted so that the kernel changes can take place. Once this has been done it's time to configure the device as swap. To do this you will use vnconfig(1).

Now for the last step, turning on swapping to that device. We will do this just like in the above examples, using swapon(8). Then we will check to see if it was correctly added to our list of swap devices.

11.2 - Tuning kmem

If you are running 2.5 (these steps are not necessary for OpenBSD 2.6), and if you start using the performance tuning measures, you may start running out of kernel memory. If you start getting panics like "out of space in kmem_map" then you need to try

Note that 8192 is valid for the i386 architecture, but may be too little or too much for others. Look at /usr/include/machine/param.h to see more information.

If you ever get a panic "vm_map_entry_create: out of map entries", you may also want to increase the number of static kernel maps and entries. The default value for these options is architecture dependent and is specified in /sys/vm/vm_map.h. If you are using soft updates, the following values should keep you going!



[back] www@openbsd.org
$OpenBSD: faq11-2.5.html,v 1.7 2001/01/27 22:19:47 ericj Exp $