% Linux Installation and Getting Started    -*- TeX -*-
% mkswap.tex
% Copyright (c) 1992-1994 by Matt Welsh <mdw@sunsite.unc.edu>
%
% This file is freely redistributable, but you must preserve this copyright 
% notice on all copies, and it must be distributed only as part of "Linux 
% Installation and Getting Started". This file's use is covered by the 
% copyright for the entire document, in the file "copyright.tex".

\subsection{Creating the swap space}
\namedlabel{sec-install-linux-mkswap}{Creating the swap space}

\index{mkswap@{\tt mkswap}|(}
\index{installation!mkswap@{\tt mkswap}|(}
\index{swap space!creating|(}

If you are planning to use a swap partition for virtual RAM, you're
ready to prepare it for use.\footnote{Again, some distributions of 
Linux will prepare the swap space automatically for you, or via an 
installation menu option.} In Chapter~\ref{chap-sysadm-num}
we will discuss the preparation of a swap file in case you don't want
to use an individual partition.

Many distributions require you to create and activate swap space before
installing the software. If you have a small amount of physical RAM, 
the installation procedure may not be successful unless you
have some amount of swap space enabled.

\ifodd\igsslack
The Slackware distribution requires you to create swap space,
before installation, if you have 4 megabytes of RAM or less.
If this is not the case, the Slackware installation procedure
can be used to prepare swap space automatically. If in doubt, 
go ahead and follow the procedure described here; it can't hurt.
\fi

The command used to prepare a swap partition is {\tt mkswap}, and it takes 
the form
\begin{tscreen}
mkswap -c \cparam{partition} \cparam{size}
\end{tscreen}
where \cparam{partition} is the name of the swap partition,
and \cparam{size} is the size of the partition, in 
blocks.\footnote{This is the size as reported by {\tt fdisk}, using
the {\tt p} menu option. A block under Linux is 1024 bytes.}
For example, if your swap partition is {\tt /dev/hda3} and is 
10336 blocks in size, use the command
\begin{tscreen}
\# {\em mkswap --c /dev/hda3 10336}
\end{tscreen}
The {\tt -c} option tells {\tt mkswap} to check for bad blocks on the 
partition when creating the swap space.

If you are using multiple swap partitions, you will need to execute the
appropriate {\tt mkswap} command for each partition.

After formatting the swap space, you need to enable it for use by the 
system. Usually, the system automatically enables swap space at boot time.
However, because you have not yet installed the Linux software, you need
to enable it by hand. 

The command to enable swap space is {\tt swapon}, and it takes the form
\begin{tscreen}
swapon \cparam{partition}
\end{tscreen}
In the example above, to enable the swap space on {\tt /dev/hda3}, we use
the command
\begin{tscreen}
\# {\em swapon /dev/hda3}
\end{tscreen}

\index{mkswap@{\tt mkswap}|)}
\index{installation!mkswap@{\tt mkswap}|)}
\index{swap space!creating|)}
