Add an example for 10.x swap files, clarify the existing examples for 9.x, use

procedure instead of orderedlist, and factor out common parts.

PR:		190759
Submitted by:	p5B2E9A8F@t-online.de
This commit is contained in:
Warren Block 2014-06-09 03:42:29 +00:00
parent 170f31c141
commit 60af047086
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=45036

View file

@ -2757,55 +2757,85 @@ kern.maxvnodes: 100000</screen>
<sect2 xml:id="create-swapfile">
<title>Creating a Swap File</title>
<para>To instead create a swap file, specify its size. The
following example creates a 64MB file named
<filename>/usr/swap0</filename>.</para>
<para>These examples create a 64M swap file
called <filename>/usr/swap0</filename> instead
of using a partition.</para>
<example>
<title>Creating a Swap File on &os;</title>
<para>Using swap files requires that the module needed by
&man.md.4; has either been built into the kernel or has been
loaded before swap is enabled. See
<xref linkend="kernelconfig"/> for information about building
a custom kernel.</para>
<orderedlist>
<listitem>
<para>The <filename>GENERIC</filename> kernel already
includes the required memory disk driver. When building
a custom kernel, make sure to include the following line
in the custom configuration file:</para>
<example xml:id="swapfile-10-and-later">
<title>Creating a Swap File on &os; 10.<replaceable>X</replaceable> and Later</title>
<programlisting>device md</programlisting>
<procedure>
<step>
<para>Create the swap file:</para>
<para>For information on building a custom kernel, refer
to <xref linkend="kernelconfig"/>.</para>
</listitem>
<screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>/usr/swap0</replaceable> bs=1m count=<replaceable>64</replaceable></userinput></screen>
</step>
<listitem>
<step>
<para>Set the proper permissions on the new file:</para>
<screen>&prompt.root; <userinput>chmod 0600 <replaceable>/usr/swap0</replaceable></userinput></screen>
</step>
<step>
<para>Inform the system about the swap file by adding a
line to <filename>/etc/fstab</filename>:</para>
<programlisting>md99 none swap sw,file=/usr/swap0 0 0</programlisting>
<para>The &man.md.4; device <filename>md99</filename> is
used, leaving lower device numbers available for
interactive use.</para>
</step>
<step>
<para>Swap space will be added on system startup. To add
swap space immediately, use &man.swapon.8;:</para>
<screen>&prompt.root; <userinput>swapon -aq</userinput></screen>
</step>
</procedure>
</example>
<example xml:id="swapfile-9-and-earlier">
<title>Creating a Swap File on &os; 9.<replaceable>X</replaceable> and Earlier</title>
<procedure>
<step>
<para>Create the swap file,
<filename>/usr/swap0</filename>:</para>
<screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>/usr/swap0</replaceable> bs=1024k count=<replaceable>64</replaceable></userinput></screen>
</listitem>
<screen>&prompt.root; <userinput>dd if=/dev/zero of=<replaceable>/usr/swap0</replaceable> bs=1m count=<replaceable>64</replaceable></userinput></screen>
</step>
<listitem>
<para>Then, set proper permissions on
<step>
<para>Set the proper permissions on
<filename>/usr/swap0</filename>:</para>
<screen>&prompt.root; <userinput>chmod 0600 <replaceable>/usr/swap0</replaceable></userinput></screen>
</listitem>
</step>
<listitem>
<step>
<para>Enable the swap file in
<filename>/etc/rc.conf</filename>:</para>
<programlisting>swapfile="<replaceable>/usr/swap0</replaceable>" # Set to name of swap file</programlisting>
</listitem>
</step>
<listitem>
<para>To enable the swap file immediately, specify a free
<step>
<para>Swap space will be added on system startup. To enable the swap file immediately, specify a free
memory device. Refer to <xref linkend="disks-virtual"/>
for more information about memory devices.</para>
<screen>&prompt.root; <userinput>mdconfig -a -t vnode -f <replaceable>/usr/swap0</replaceable> -u <replaceable>0</replaceable> &amp;&amp; swapon /dev/md<replaceable>0</replaceable></userinput></screen>
</listitem>
</orderedlist>
</step>
</procedure>
</example>
</sect2>
</sect1>