Now that we have a section in the Handbook on how to add swap space,
point the "add swap space" FAQ there.
This commit is contained in:
parent
9652ca1b74
commit
1f7eb7d649
Notes:
svn2git
2020-12-08 03:00:23 +00:00
svn path=/head/; revision=11818
1 changed files with 6 additions and 85 deletions
|
@ -6365,91 +6365,12 @@ C:\="DOS"</programlisting>
|
|||
</question>
|
||||
|
||||
<answer>
|
||||
|
||||
<para>The best way is to increase the size of your swap partition,
|
||||
or take advantage of this convenient excuse to add another
|
||||
disk. The general rule of thumb is to have around 2x the swap
|
||||
space as you have main memory. However, if you have a very
|
||||
small amount of main memory you may want to configure swap
|
||||
beyond that. It is also a good idea to configure sufficient
|
||||
swap relative to anticipated future memory upgrades so you do
|
||||
not have to futz with your swap configuration later.</para>
|
||||
|
||||
<para>Adding swap onto a separate disk makes things faster than
|
||||
simply adding swap onto the same disk. As an example, if you
|
||||
are compiling source located on one disk, and the swap is on
|
||||
another disk, this is much faster than both swap and compile on
|
||||
the same disk. This is true for SCSI disks specifically.</para>
|
||||
|
||||
<para>When you have several disks, configuring a swap partition on
|
||||
each one is usually beneficial, even if you wind up putting
|
||||
swap on a work disk. Typically, each fast disk in your system
|
||||
should have some swap configured. FreeBSD supports up to 4
|
||||
interleaved swap devices by default. When configuring multiple
|
||||
swap partitions you generally want to make them all about the
|
||||
same size, but people sometimes make their primary swap
|
||||
partition larger in order to accommodate a kernel core dump. Your
|
||||
primary swap partition must be at least as large as main memory
|
||||
in order to be able to accommodate a kernel core.</para>
|
||||
|
||||
<para>IDE drives are not able to allow access to both drives on
|
||||
the same channel at the same time (FreeBSD does not support mode
|
||||
4, so all IDE disk I/O is <quote>programmed</quote>).
|
||||
It is still suggested that you put your swap partition on a
|
||||
separate driver, however: the drives are so cheap, it is not
|
||||
worth worrying about.</para>
|
||||
|
||||
<para>Swapping over NFS is only recommended if you do not have a
|
||||
local disk to swap to. Swapping over NFS is slow and
|
||||
inefficient in FreeBSD releases prior to 4.x, but reasonably
|
||||
fast in releases greater or equal to 4.0. Even so, it will be
|
||||
limited to the network bandwidth available and puts an
|
||||
additional burden on the NFS server.</para>
|
||||
|
||||
<para>Here is an example for 64Mb vn-swap
|
||||
(<filename>/usr/swap0</filename>, though of course you can use
|
||||
any name that you want).</para>
|
||||
|
||||
<para>Make sure your kernel was built with the line</para>
|
||||
|
||||
<programlisting>pseudo-device vn 1 #Vnode driver (turns a file into a device)</programlisting>
|
||||
|
||||
<para>in your config-file. The GENERIC kernel already contains
|
||||
this.</para>
|
||||
|
||||
<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>
|
||||
<para>In the <ulink
|
||||
url="../handbook/config-tuning.html">Configuration and
|
||||
Tuning</ulink> section of the Handbook, you will find a
|
||||
<ulink
|
||||
url="../handbook/adding-swap-space.html">section</ulink>
|
||||
describing how to do this.</para>
|
||||
</answer>
|
||||
</qandaentry>
|
||||
</qandaset>
|
||||
|
|
Loading…
Reference in a new issue