85 lines
4.4 KiB
HTML
85 lines
4.4 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
|
<!Converted with LaTeX2HTML 95.1 (Fri Jan 20 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
|
<HEAD>
|
|
<TITLE>4.9 Using a swap file</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<meta name="description" value="4.9 Using a swap file">
|
|
<meta name="keywords" value="gs">
|
|
<meta name="resource-type" value="document">
|
|
<meta name="distribution" value="global">
|
|
<P>
|
|
<BR> <HR><A NAME=tex2html4142 HREF="node188.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html4140 HREF="node155.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html4134 HREF="node186.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html4144 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html4145 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html4143 HREF="node188.html">4.10 Miscellaneous Tasks</A>
|
|
<B>Up:</B> <A NAME=tex2html4141 HREF="node155.html">4 System Administration</A>
|
|
<B> Previous:</B> <A NAME=tex2html4135 HREF="node186.html">4.8.2 Checking filesystems</A>
|
|
<BR> <HR> <P>
|
|
<H1><A NAME=SECTION00690000000000000000>4.9 Using a swap file</A></H1>
|
|
<A NAME=secswapfile> </A>
|
|
<P>
|
|
<A NAME=4991> </A>
|
|
Instead of reserving an individual partition for swap space, you can
|
|
use a file. However, to do so you'll need install the Linux software
|
|
and get everything going <em>before</em> you create the swap file.
|
|
<P>
|
|
If you have a Linux system installed, you can use the following commands
|
|
to create a swap file. Below, we're going to create a swap file of
|
|
size 8208 blocks (about 8 megs).
|
|
<P><TT> # <em>dd if=/dev/zero of=/swap bs=1024 count=8208</em>
|
|
<P></TT>
|
|
This command creates the swap file itself. Replace the ``<tt>count=</tt>''
|
|
with the size of the swap file in blocks.
|
|
<A NAME=5018> </A>
|
|
<P><TT> # <em>mkswap /swap 8208</em>
|
|
<P></TT>
|
|
This command will initialize the swapfile; again, replace the name and size
|
|
of the swapfile with the appropriate values.
|
|
<A NAME=5019> </A>
|
|
<P><TT> # <em>/etc/sync</em> <BR>
|
|
# <em>swapon /swap</em>
|
|
<P></TT>
|
|
Now we are swapping on the file <tt>/swap</tt> which we have created, after
|
|
syncing, which ensures that the file has been written to disk.
|
|
<P>
|
|
The one major drawback to using a swapfile in this manner is that
|
|
all access to the swap file is done through the filesystem. This means
|
|
that the blocks which make up the swap file may not be contiguous. Therefore,
|
|
performance may not be as great as using a swap partition, for which blocks
|
|
are always contiguous and I/O requests are done directly to the device.
|
|
<P>
|
|
Another drawback in using a swapfile is the chance to corrupt your
|
|
filesystem data---when using large swap files, there is the chance that
|
|
you can corrupt your filesystem if something goes wrong. Keeping your
|
|
filesystems and swap partitions separate will prevent this from happening.
|
|
<P>
|
|
<A NAME=5007> </A>
|
|
Using a swap file can be very useful if you have a temporary need for
|
|
more swap space. For example, if you're compiling a large program and
|
|
would like to speed things up somewhat, you can temporarily create a
|
|
swap file and use it in addition to your regular swap space.
|
|
<P>
|
|
<A NAME=5008> </A>
|
|
<A NAME=5020> </A>
|
|
To get rid of a swap file, first use <tt>swapoff</tt>, as in
|
|
<P><TT> # <em>swapoff /swap</em>
|
|
<P></TT>
|
|
And you can safely delete the file.
|
|
<P><TT> # <em>rm /swap</em>
|
|
<P></TT>
|
|
<P>
|
|
Remember that each swap file (or partition) may be as large as 16 megabytes,
|
|
but you may use up to 8 swap files or partitions on your system.
|
|
<A NAME=5017> </A>
|
|
<P>
|
|
<BR> <HR><A NAME=tex2html4142 HREF="node188.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html4140 HREF="node155.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html4134 HREF="node186.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html4144 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html4145 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html4143 HREF="node188.html">4.10 Miscellaneous Tasks</A>
|
|
<B>Up:</B> <A NAME=tex2html4141 HREF="node155.html">4 System Administration</A>
|
|
<B> Previous:</B> <A NAME=tex2html4135 HREF="node186.html">4.8.2 Checking filesystems</A>
|
|
<BR> <HR> <P>
|
|
<BR> <HR>
|
|
<P><ADDRESS>
|
|
<I>Matt Welsh <BR>
|
|
mdw@sunsite.unc.edu</I>
|
|
</ADDRESS>
|
|
</BODY>
|