A partition is labeled to host a certain kind of file system (not to be
confused with a volume label). Such a
file system could be the linux standard ext2 file system or linux swap
space, or even foreign file systems like (Microsoft) NTFS or (Sun)
UFS. There is a numerical code associated with each partition
type. For example, the code for ext2 is 0x83 and linux swap is 0x82. To see
a list of partition types and their codes, execute
/sbin/sfdisk -T
Foreign Partition Types
The partition type codes have been
arbitrarily chosen (you can't derive them) and they
are particular to a given operating system. Therefore, it is
theoretically possible that if you use two operating systems with the
same hard drive, the same code might be used to designate two
different partition types.
OS/2 marks its partitions with a 0x07 type and so
does Windows NT's NTFS. MS-DOS allocates several type codes for its
various flavors of FAT file systems: 0x01, 0x04 and 0x06 are known.
DR-DOS used 0x81 to indicate protected FAT partitions, creating a type
clash with Linux/Minix at that time, but neither Linux/Minix nor
DR-DOS are widely used any more.
The number of partitions on an Intel-based system was limited
from the very beginning: The original partition table was
installed as part of the boot sector and held space for only
four partition entries. These partitions are now called primary
partitions.
One primary partition of a hard drive may be subpartitioned. These are
logical partitions. This effectively allows us to skirt the historical
four partition limitation.
drive name
| drive controller
| drive number
| partition type
| partition number |
/dev/hdb1
| 1
| 2
| primary
| 1
|
/dev/hdb2
| 1
| 2
| extended
| NA
|
/dev/hdb5
| 1
| 2
| logical
| 2
|
/dev/hdb6
| 1
| 2
| logical
| 3
| | | | |
The primary partition used to house the logical partitions is called
an extended partition and it has its own file system type (0x05).
Unlike primary partitions, logical partitions must be contiguous. Each
logical partition contains a pointer to the next logical partition,
which implies that the number of logical partitions is
unlimited. However, linux imposes limits on the total number of
partitions on a drive, so this effectively limits the number of
logical partitions. This is 15 partitions total on an SCSI
disk and 63 total on an IDE disk.
Swap Partitions
Every process running on your computer is allocated a number of blocks
of RAM. These blocks are called pages. The set of
in-memory pages which will be referenced by the processor in the very
near future is called a "working set." 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.
In Linux, RAM and swap space add up (This is
not true for all Unices). For example, if you have 256 MB of RAM and 256 MB swap space, you have a total of about 512 MB virtual memory.
If you have too many processes running on a machine, the kernel will try
to free up RAM by writing pages to disk. This is
what swap space is for. It effectively increases the amount of memory
you have available. However, disk I/O is about a hundred times slower
than reading from and writing to RAM. Consider this
emergency memory and not extra memory.
If memory becomes so scarce that the kernel pages out from the working
set of one process in order to page in for another, the machine is said
to be thrashing. Some readers might have inadvertenly experienced this:
the hard drive is grinding away like crazy, but the computer is slow to
the point of being unusable. Swap space is something you need to have,
but it is no substitute for sufficient RAM. See
the discussion in Section 4 for
tips on determining the size of swap space you need.