Swap space management is part of system configuration and tuning, so

put information about adding swap space to the end of this chapter.

Text taken from the FAQ, with minor glue to Handbook-ize it.
This commit is contained in:
Michael Lucas 2002-01-22 18:39:14 +00:00
parent 2e897de412
commit c4048ad511
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=11816

View file

@ -161,7 +161,7 @@
</sect3>
<sect3>
<sect3 id="swap-design">
<title>Swap Partition</title>
<indexterm><primary>swap sizing</primary></indexterm>
@ -1112,6 +1112,90 @@ kern.maxfiles: 2088 -> 5000</screen>
to multiply by 2, so 32MBx2 = 64MB/2K = 32768.</para>
</sect2>
</sect1>
<sect1>
<title>Adding Swap Space</title>
<para>No matter how well you plan, sometimes a system doesn't run
as you expect. If you find you need more swap space, it's
simple enough to add. You have three ways to increase swap
space: adding a new hard drive, enabling swap over NFS, and
creating a swap file on an existing partition.</para>
<sect2 id="new-drive-swap">
<title>Swap on a New Hard Drive</title>
<para>The best way to add swap, of course, is to use this as an
excuse to add another hard drive. You can always use another
hard drive, after all. If you can do this, go reread the
discussion of <ulink
url="configtuning-initial.html#SWAP-DESIGN">swap space
</ulink> from the <ulink
url="configtuning-initial.html">Initial Configuration</ulink>
section of the Handbook for some suggestions on how to best
arrange your swap.</para>
</sect2>
<sect2 id="nfs-swap">
<title>Swapping over NFS</title>
<para>Swapping over NFS is only recommended if you do not have a
local hard disk to swap to. Swapping over NFS is slow and
inefficient in versions of FreeBSD prior to 4.x. It is
reasonably fast and efficient in 4.0-RELEASE and newer. Even
with newer versions of FreeBSD, NFS swapping will be limited
by the available network bandwidth and puts an additional
burden on the NFS server.</para>
</sect2>
<sect2 id="create-swapfile">
<title>Swapfiles</title>
<para>You can create a file of a specified size to use as a swap
file. In our example here we will use a 64Mb file called
<filename>/usr/swap0</filename>. You can use any name you
want, of course.</para>
<para>First, be certain that your kernel configuration includes
the vnode driver. It is not in recent versions of
GENERIC.</para>
<programlisting>pseudo-device vn 1 #Vnode driver (turns a file into a device)</programlisting>
<orderedlist>
<listitem>
<para>create a vn-device</para>
<screen>&prompt.root; <userinput>cd /dev</userinput> &prompt.root; <userinput>sh MAKEDEV vn0</userinput></screen>
</listitem>
<listitem>
<para>create a swapfile (<filename>/usr/swap0</filename>)</para>
<screen>&prompt.root; <userinput>dd if=/dev/zero of=/usr/swap0 bs=1024k count=64</userinput></screen>
</listitem>
<listitem>
<para>set proper permissions on (<filename>/usr/swap0</filename>)</para>
<screen>&prompt.root; <userinput>chmod 0600 /usr/swap0</userinput></screen>
</listitem>
<listitem>
<para>enable the swap file in <filename>/etc/rc.conf</filename></para>
<programlisting>swapfile="/usr/swap0" # Set to name of swapfile if aux swapfile desired.</programlisting>
</listitem>
<listitem>
<para>reboot the machine</para>
</listitem>
</orderedlist>
<para>To enable the swap file immediately, type</para>
<screen>&prompt.root; <userinput>vnconfig -e /dev/vn0b /usr/swap0 swap</userinput></screen>
</sect2>
</sect1>
</chapter>
<!--