Okay, so what partitions do you need? Well, some operating
systems do not believe in booting from logical partitions for
reasons that are beyond the scope of any sane mind. So you
probably want to reserve your primary partitions as boot
partitions for your MS-DOS, OS/2 and Linux or whatever you are
using. Remember that one primary partition is needed as an
extended partition, which acts as a container for the rest of
your disk with logical partitions.
Booting operating systems is a real-mode thing involving BIOSes
and 1024 cylinder limitations. So you probably want to put all
your boot partitions into the first 1024 cylinders of your hard
disk, just to avoid problems. Again, read the "large-disk"
Mini-Howto for the gory details.
To install Linux, you will need at least one partition. If the
kernel is loaded from this partition (for example by LILO),
this partition must be readable by your BIOS. If you are using
other means to load your kernel (for example a boot disk or the
LOADLIN.EXE MS-DOS based Linux loader) the partition can be
anywhere. In any case this partition will be of type 0x83
"Linux native".
Your system will need some swap space. Unless you swap to files
you will need a dedicated swap partition. Since this partition
is only accessed by the Linux kernel and the Linux kernel does
not suffer from PC BIOS deficiencies, the swap partition may be
positioned anywhere. I recommed using a logical partition for
it (/dev/?d?5 and higher). Dedicated Linux swap partitions are
of type 0x82 "Linux swap".
These are minimal partition requirements. It may be useful to
create more partitions for Linux. Read on.
If you have decided to use a dedicated swap partition, which is
generally a Good Idea [tm], follow these guidelines for
estimating its size:
- In Linux RAM and swap space add up (This is not true for all
Unices). For example, if you have 8 MB of RAM and 12 MB swap
space, you have a total of about 20 MB virtual memory.
- When sizing your swap space, you should have at least 16 MB
of total virtual memory. So for 4 MB of RAM consider at least
12 MB of swap, for 8 MB of RAM consider at least 8 MB of
swap.
- In Linux, a single swap partition can not be larger than 128
MB. That is, the partition may be larger than 128 MB, but
excess space is never used. If you want more than 128 MB of
swap, you have to create multiple swap partitions.
- When sizing swap space, keep in mind that too much swap space
may not be useful at all.
Every process has a "working set". This is a set of in-memory
pages which will be referenced by the processor in the very
near future. Linux tries to predict these memory accesses
(assuming that recently used pages will be used again in the
near future) and keeps these pages in RAM if possible. If the
program has a good "locality of reference" this assumption
will be true and prediction algorithm will work.
Holding a working set in main memory does only work if there
is enough main memory. If you have too many processes running
on a machine, the kernel is forced to put pages on disk that
it will reference again in the very near future (forcing a
page-out of a page from another working set and then a
page-in of the page referenced). Usually this results in a
very heavy increase in paging activity and in a sustantial
drop of performance. A machine in this state is said to be
"thrashing" (For you German readers: That's "thrashing"
("dreschen", "schlagen", "haemmern") and not trashing
("muellen")).
On a thrashing machine the processes are essentially running
from disk and not from RAM. Expect performance to drop by
approximately the ratio between memory access speed and disk
access speed.
A very old rule of thumb in the days of the PDP and the Vax
was that the size of the working set of a program is about
25% of its virtual size. Thus it is probably useless to
provide more swap than three times your RAM.
But keep in mind that this is just a rule of thumb. It is
easily possible to create scenarios where programs have
extremely large or extremely small working sets. For example,
a simulation program with a large data set that is accessed
in a very random fashion would have almost no noticeable
locality of reference in its data segment, so its working set
would be quite large.
On the other hand, an xv with many simultaneously opened
JPEGs, all but one iconified, would have a very large data
segment. But image transformations are all done on one single
image, most of the memory occupied by xv is never touched.
The same is true for an editor with many editor windows
where only one window is being modified at a time. These
programs have - if they are designed properly - a very high
locality of reference and large parts of them can be kept
swapped out without too severe performance impact.
One could suspect that the 25% number from the age of the
command line is no longer true for modern GUI programs
editing multiple documents, but I know of no newer papers
that try to verify these numbers.
So for a configuration with 16 MB RAM, no swap is needed for a
minimal configuration and more than 48 MB of swap are probably
useless. The exact amount of memory needed depends on the
application mix on the machine (what did you expect?).
- Mechanics are slow, electronics are fast.
Modern hard disks have many heads. Switching between heads of
the same track is fast, since it is purely electronic.
Switching between tracks is slow, since it involves moving
real world matter.
So if you have a disk with many heads and one with less heads
and both are identical in other parameters, the disk with
many heads will be faster.
Splitting swap and putting it on both disks will be even
faster, though.
- Older disks have the same number of sectors on all tracks.
With this disks it will be fastest to put your swap in the
middle of the disks, assuming that your disk head will move
from a random track towards the swap area.
- Newer disks use ZBR (zone bit recording). They have more
sectors on the outer tracks. With a constant number of rpms,
this yields a far greater performance on the outer tracks
than on the inner ones. Put your swap on the fast tracks.
- Of course your disk head will not move randomly. If you have
swap space in the middle of a disk between a constantly busy
home partition and an almost unused archive partition, you
would be better of if your swap were in the middle of the
home partition for even shorter head movements. You would be
even better off, if you had your swap on another otherwise
unused disk, though.
Summary: Put your swap on a fast disk with many heads that is
not busy doing other things. If you have multiple disks: Split
swap and scatter it over all your disks or even different
controllers.
Even better: Buy more RAM.