Building a Swap Partition
A lot of the documentation available about Linux, especially
the older writings, stress the importance of a SWAP file
or partition in computers with limited memory. The examples
often cited are computers with 8 or 16 megabytes of RAM,
a reasonable enough amount a couple of years ago. These
documents seem to indicate that if you have much more RAM
than that, you won't need a swap file/partition. For instance,
I recently installed Linux on a machine with 96 megs of
RAM, and didn't worry about swapping at all, until I stopped
to monitor my memory usage for a couple of days. I realized
that I'd allowed myself to be mislead, in spite of years
of experience with multi-tasking operating systems, and
that I desparately needed some swap space. This is how I
created it.
Linux will allow you to use a file for your swap space,
but this is by far an inferior solution to setting aside
a partition on one of your hard disk drives. Files are more
fragile, and are subject to fragmentation (a frequent cause
of slow swapping in Windows operating systems). Setting
aside a partition is preferable; there will be nothing on
that partition save for the swapped information, eliminating
the possibility of fragments.
First I needed an empty partition to use, since swap partitions
don't use a standard file system. That meant finding the
hard drive with the most unused space on it, and shrinking
the partition to free a chunk for my swap space. There are
a number of tools around that can be used for this. DiskDruid
comes with the Red Hat and Mandrake distros, while fips,
a DOS program, is freely available at a number of FTP sites.
I'm lucky though, in that I have a copy of Partition Magic,
from PowerQuest, which recognizes all flavors
of FAT (File Allocation Table, the DOS/Windows file systems)
partitions, as well as NTFS (NT file system, for Windows
NT), HPFS (High Performance file system, for OS/2 users)
and, of course, the Linux native ext2fs.
With Partition Magic (as I would have been with fips or
DiskDruid), I was able to resize one of my extant NTFS partitions,
and set aside about 150 megs for use as my swap partition.
I wanted at least as much swap space as I had physical memory,
and I tend to be conservative and overestimate what I actually
will need. 100 megs would probably have been enough for
my system, as that's about equal to the physical memory.
I prefer to overcommit swap space though, preferring 1 1/2
to 2 times as much swap space as physical RAM. I left it
unformatted, as there's a file system type that's designed
for such use (all file systems have a hexadecimal number
assigned to them - ext2fs is 83, and the Linux swap file
system number is 82) and I knew that I'd be setting that
from within the Linux version of the fdisk utility.
My next step was to boot into Linux from my bootdisk. If
you don't have one of these, then MAKE ONE NOW!!!! It's
easily done - type
"mke2fs -c /dev/fd0 at the
command line then type cp /vmlinuz
without quotation marksof course. ohand do be sure to have
a floppy disk in drive first.
Once Linux was running on my system, I ran fdisk. That
was the easy part. I knew which disk drive it was on - in
my case, /dev/hdc, which DOS/Windows
would report as drive 2 (starting from 0). So, I typed "fdisk
/dev/hdc". Fdisk opened, and I was able to look at
the partitions on the disk, and chose the correct one, hdc6.
(Partition naming is a separate topic altogether.)
|