Appendix D: An Introduction to Disk Partitions


Disk partitions are a standard part of the personal computer landscape and have been for quite some time. However, with many people purchasing computers featuring pre-installed operating systems, relatively few people understand how partitions work. This chapter attempts to explain the reasons for and use of disk partitions so your Red Hat Linux installation will be as simple and painless as possible. This chapter also discusses the partition naming scheme used by Linux systems, sharing disk space with other operating systems, and related topics.

Note

If you are reasonably comfortable with disk partitions, you could skip ahead to the “Making Room for Red Hat Linux” section later in this chapter for more information on the process of freeing up disk space to prepare for a Red Hat Linux installation.

Hard Disk Basic Concepts

Hard disks (also called hard drives) perform a very simple function — they store data and reliably retrieve it on command.

When discussing issues such as disk partitioning, it is important to know a bit about the underlying hardware. Unfortunately, it is easy to become bogged down in details. Therefore, this chapter uses a simplified diagram of a disk drive to help explain what is really happening when a disk drive is partitioned.

Figure D-1 shows a brand-new, unused disk drive.


Figure D-1. An Unused Disk Drive

Not much to look at, is it? But if we are talking about disk drives on a basic level, it will do. Say that we would like to store some data on this drive. As things stand now, it will not work. There is something we need to do first, namely formatting the drive (as discussed in the next section).

It's Not What You Write, It's How You Write It

Experienced computer users probably got this one on the first try. We need to format the drive. Formatting (usually known as "making a file system") writes information to the drive, creating order out of the empty space on an unformatted drive.


Figure D-2. Disk Drive with a File System

As Figure D-2 shows, the order imposed by a file system involves some trade-offs, as follows:

  • A small percentage of the drive's available space is used to store file system-related data. This percentage can be considered overhead.

  • A file system splits the remaining space into small, consistently-sized segments. In Linux, these segments are known as blocks.

    Note

    Blocks really are consistently sized, unlike our illustrations. Keep in mind, also, that an average disk drive contains thousands of blocks. But for the purposes of this discussion, please ignore these minor discrepancies.

Given that file systems make things like directories and files possible, these tradeoffs are usually seen as a small price to pay.

It is also worth noting that there is no single, universal file system. As Figure D-3 shows, a disk drive may have one of many different file systems written on it. As you might guess, different file systems tend to be incompatible; that is, an operating system that supports one file system (or a handful of related file system types) may not support another. This last statement is not a hard-and-fast rule, however. For example, Red Hat Linux supports a wide variety of file systems (including many commonly used by other operating systems, such as FAT, which is used by Windows 9x/Me), making data interchange between different file systems easy.


Figure D-3. Disk Drive with a Different File System

Of course, writing a file system to disk is only the beginning. The goal of this process is to actually store and retrieve data. Figure D-4 shows our example drive after some files have been written to it.


Figure D-4. Disk Drive with Data Written to It

As the figure shows, 14 of the previously empty blocks are now holding data. However, we cannot determine exactly how many files reside on this drive by simply looking at this picture. There may be as few as one or as many as 14 files, as all files use at least one block and some files use multiple blocks. Another important point to note is that the used blocks do not have to form a contiguous region; used and unused blocks may be interspersed. This concept is known as fragmentation. Fragmentation can play a part when attempting to resize an existing partition.

As with most computer-related technologies, disk drives changed over time after their introduction. In particular, they got bigger. Not larger in physical size, but bigger in their capacity to store information. This additional capacity drove a fundamental change in the way disk drives were used.

Partitions: Turning One Drive Into Many

As disk drive capacities soared, some people began to wonder if having all of that formatted space in one big chunk was such a great idea. This line of thinking was driven by several issues, some philosophical, some technical. On the philosophical side, above a certain size, it seemed that the additional space provided by a larger drive created more clutter. On the technical side, some file systems were never designed to support anything above a certain capacity. Even if the file systems could support larger drives with a greater capacity, the overhead imposed by the file system to track files could become excessive.

The solution to this problem was to divide disks into partitions. Each partition can be accessed as if it was a separate disk. This is done through the addition of a partition table.

Note

While the diagrams in this chapter show the partition table as being separate from the actual disk drive, this is not entirely accurate. In reality, the partition table is stored at the very start of the disk, before any file system or user data. But for clarity, we keep it separate in the diagrams for this chapter.


Figure D-5. Disk Drive with Partition Table

As Figure D-5 shows, the partition table is divided into four sections. Each section can hold the information necessary to define a single partition, meaning that this particular partition table can define no more than four partitions.

Each partition table entry contains several important characteristics of the partition:

  • The points on the disk where the partition starts and ends — The starting and ending points define the partition's size and location on the disk.

  • Whether the partition is active — The "active" flag is used by some operating systems' boot loaders. In other words, the operating system in the partition that is marked "active" is the partition that will be booted by default.

  • The partition's type — The partition's type can be a bit confusing. The type is a number that identifies the partition's anticipated usage. If that statement sounds a bit vague, that is because the meaning of the partition type is a bit vague. Some operating systems use the partition type to denote a specific file system type, to flag the partition as being associated with a particular operating system, to indicate that the partition contains a bootable operating system, or some combination of the three. Table D-1 contains a listing of some popular (and obscure) partition types along with their corresponding numeric values.

    Table D-1: Partition Types

    Partition Type

    Value

    Partition Type

    Value

    Empty

    00

    Novell Netware 386

    65

    DOS 12-bit FAT

    01

    PIC/IX

    75

    XENIX root

    02

    Old MINIX

    80

    XENIX usr

    03

    Linux/MINUX

    81

    DOS 16-bit<=32M

    04

    Linux swap

    82

    Extended

    05

    Linux native

    83

    DOS 16-bit>=32M

    06

    Linux extended

    85

    OS/2 HPFS

    07

    Amoeba

    93

    AIX

    08

    Amoeba BBT

    94

    AIX bootable

    09

    BSD/386

    a5

    OS/2 Boot Manager

    0a

    OpenBSD

    a6

    Win95 FAT32

    0b

    NEXTSTEP

    a7

    Win95 FAT32 (LBA)

    0c

    BSDI fs

    b7

    Win95 FAT16 (LBA)

    0e

    BSDI swap

    b8

    Win95 Extended (LBA)

    0f

    Syrinx

    c7

    Venix 80286

    40

    CP/M

    Db

    Novell

    51

    DOS access

    e1

    Microport

    52

    DOS R/O

    e3

    GNU HURD

    63

    DOS secondary

    f2

    Novell Netware 286

    64

    BBT

    Ff

By this point, you might be wondering how all this additional complexity is normally used. See Figure D-6 for an example.


Figure D-6. Disk Drive with a Single Partition

In many cases, there is only a single partition spanning the entire disk, essentially duplicating the method used before partitions. The partition table has only one entry used, and it points to the start of the partition.

In the figure, this partition is labeled as being of the "DOS" type. Although it is only one of several possible partition types listed in Table D-1, it is adequate for the purposes of this discussion. This is a typical partition layout for most newly purchased computers that have a consumer version of Microsoft Windows preinstalled.

Partitions within Partitions — An Overview of Extended Partitions

Of course, over time it became obvious that four partitions would not be enough. As disk drives continued to grow, it became more and more likely that a person could configure four reasonably sized partitions and still have disk space left over. There needed to be some way of creating more partitions.

Enter the extended partition. As you can see in Table D-1, there is an "Extended" partition type. When a partition is created and its type is set to "Extended," an extended partition table is created. In essence, the extended partition is like a disk drive in its own right — it has a partition table that points to one or more partitions (now called logical partitions, as opposed to the four primary partitions) contained entirely within the extended partition itself. Figure D-7 shows a disk drive with one primary partition and one extended partition containing two logical partitions (along with some unpartitioned free space).


Figure D-7. Disk Drive with Extended Partition

As the figure implies, there is a difference between primary and logical partitions — there can only be four primary partitions, but there is no fixed limit to the number of logical partitions that can exist.

However, due to the way in which partitions are accessed in Linux, you should avoid defining more than 12 logical partitions on a single disk drive.

Now that we have discussed partitions in general, the next section shows you how to use this knowledge to install Red Hat Linux.




The Red Hat Documentation Team - Official Red Hat Linux User's Guide
The Red Hat Documentation Team - Official Red Hat Linux User's Guide
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 223

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net