To prepare your hard disk for installing Linux, you must allocate the space in which Linux will reside. You'll learn how to do so in this section. First, I'll explain how hard disks are organized, followed by how to view the structure of a hard disk. Finally, I'll describe how to alter, or partition, the structure of your hard disk in preparation for installing Red Hat Linux.
Let's start by reviewing facts you've probably learned by working with Windows. Most operating systems, including Windows 95/98, 2000, and XP, manage hard drives by dividing their storage space into units known as partitions. So that you can access a partition, Windows associates a drive letter (such as C: or D:) with it. Before you can store data on a partition, you must format it. Formatting a partition organizes the associated space into what is called a filesystem, which provides space for storing the names and attributes of files as well as the data they contain. Windows supports several types of filesystems, such as FAT, FAT32, and NTFS.
Partitions comprise the logical structure of a disk drive, the way humans and most computer programs understand the structure. However, disk drives have an underlying physical structure that more closely resembles the actual structure of the hardware. Figure 2-6 shows the logical and physical structure of a disk drive.
Mechanically, a hard disk is constructed of platters that resemble the phonograph records found in an old-fashioned jukebox. Each platter is associated with a read/write head that works much like the read/write head on a VCR, encoding data as a series of electromagnetic pulses. As the platter spins, the heads record data in concentric rings known as tracks, which are numbered beginning with zero. A hard disk may have hundreds or thousands of tracks.
All the tracks with the same radius are known as a cylinder. Like tracks, cylinders are numbered beginning with zero. The number of platters and cylinders of a drive determine the drive's geometry. Some PCs require you to specify the drive geometry in the BIOS setup. Most modern PCs autodetect the drive geometry but let you specify a custom value if you prefer.
Most operating systems prefer to read or write only part of a track, rather than an entire track. Consequently, tracks are divided into a series of sectors, each of which holds a fixed number of bytes, usually 512.
To correctly access a sector, a program needs to know the geometry of the drive. Because it's sometimes inconvenient to specify the geometry of a drive, some PC BIOS programs let you specify logical byte addressing (LBA). LBA sequentially numbers sectors, letting programs read or write a specified sector without the burden of specifying a cylinder or head number.
The first step in preparing your hard disk is viewing its partition information. Once you know how your hard disk is organized, you'll be able to determine how to reorganize it to accommodate Linux. To view the partitions that exist on your Windows 95/98 hard disk drives, you can use the fdisk utility. If your system runs Windows 2000 or XP, you must use the Disk Management tool, which resides within the Computer Management folder of the Administrative Tools control panel applet.
To use fdisk:
Click on the Windows Start menu. The Start pop-up menu appears.
Select Run. The Run dialog box appears.
Type "command" in the text box labelled Open. Then click OK or press Enter.
An MS-DOS Prompt window appears.
Type fdisk and press Enter. The fdisk menu appears, as shown in Figure 2-7.
If your system has only one hard drive, you won't see option 5, titled "Change current fixed disk drive." If option 5 is available, type 5 and press Enter. This takes you to a screen resembling the one shown in Figure 2-8 that lets you specify the current fixed disk drive.
If option 5 is not available, type the number associated with the "Display partition information" option and press Enter. The screen will resemble the one shown in Figure 2-8, though its arrangement will be somewhat different.
The screen shows each hard drive and its size, numbering the drives beginning with 1. If a drive contains free space not allocated to a partition, the screen shows the amount of space available. The screen also shows how much of the drive's space has been allocated to partitions, as a percentage of the total drive space.
Under the information describing a drive, the screen shows the size of each partition that resides on the drive. The screen also shows the associated drive letter, if any.
When you're done viewing partition information, press Esc once or twice to exit fdisk and return to the MS-DOS prompt. You can then close the MS-DOS Prompt window by clicking on the Close icon in the upper-right corner of the window or by typing exit and pressing Enter.
To use the Disk Management tool, click Start Control Panel Administrative Tools Disk Management. The tool graphically depicts your system's drives and the partitions and free space they contain, as shown in Figure 2-9.
Like Windows, Red Hat Linux requires special partitions on which to store its filesystems and swap data. You must devote two?or preferably three?partitions to Linux. By viewing the partitions on your hard drive, you can determine which of the following two cases best describes your system:
Do you have enough free (unpartitioned) disk space to accommodate Linux? (You need 400 MB to 4.5 GB, depending on the type of installation you want and the number of packages you want to install.)
In this case, make a note of the drive that holds the free disk space. You can then begin the installation process described in Chapter 3. However, see the tip on PC BIOS limitations, later in this section.
Do you lack enough free (unpartitioned) disk space to accommodate Linux?
If you don't have sufficient disk space, you have several options:
If your system has room for an additional disk drive, you can install a new drive and use it to hold Linux. The upcoming Section 18.104.22.168 offers some considerations and tips on installing a new drive. This is generally the best option, because it sidesteps problems arising due to PC BIOS limitations.
If you have one or more unused partitions, you can delete them and use the space you gain to hold Linux. Section 22.214.171.124 shows how to identify an unused partition.
If you have one or more partitions that are larger than needed, you can shrink them and use the space you gain to hold Linux. Section 126.96.36.199 shows you how to determine whether a partition is larger than needed and how to free the excess space.
If you're unsure whether your free space satisfies these criteria, simply begin the installation; the installation program will notify you if it is unable to proceed. In that case, you can return to this chapter to learn how to gain or add additional disk space.
Often, the easiest way to install Linux is to install a new disk drive. If your system has only a single hard drive, you can probably install a second drive and place Linux on the new drive. Before purchasing a drive, you should make sure that the system provides room to mount the new drive and that you have the proper data and power cables. Be sure to install both disk drives on the primary disk controller so they can be booted; if you have an IDE CD-ROM drive, you should move it to the secondary controller.
If your system already has two disk drives, you probably can't simply add a third disk drive: the BIOS of most PCs lets you boot the system from only the first or second hard drive on the primary controller. In such a case, you can probably replace one of your existing drives with a larger drive adequate to support your existing needs and Linux.
You can use the drive letter information provided by fdisk to examine the contents of a partition in the Windows Explorer. If you can find a partition that holds no useful data but is large enough to accommodate the type of Linux installation you want, you can delete the partition and use the free space to hold Linux. At least 75 MB of the unused partition should reside within the first 1023 cylinders of the drive; otherwise, you will have to use a boot floppy to load Linux.
 Boot floppies, and how to create them, are discussed in Chapter 3.
The easiest way to delete a partition is to start installing Red Hat from the disks in this book, and then request deletion of the partition when the installation program gives you the opportunity. Make note in Table 2-1 of the partition you wish to delete and then begin the installation process described in Chapter 3.
Even if all of your partitions contain useful data, one or more partitions may be larger than required. In that case, you can reduce the size of each such partition and reorganize the drive to include contiguous unused space to hold Linux. Again, at least 75 MB of the unused space should reside within the first 1023 cylinders of the disk drive; otherwise, you'll have to use a boot floppy to load Linux.
You can use the Windows Explorer to determine the amount of free disk space in a partition. Simply right-click on the drive icon and click on Properties in the pop-up menu. The Properties dialog box shows the amount of used and free disk space associated with the drive.
If you are able to find one or more FAT or FAT32 partitions that have sufficient free space for a Linux installation, you can use a special utility to split the used and unused portions of a partition into separate partitions. Disc 1 of Red Hat Linux includes the unsupported fips utility, which can split FAT and FAT32 partitions. For information on using fips, see the documentation in the dosutils directory of the CD-ROM.
Many Linux users find commercial partitioning tools?such as PowerQuest's PartitionMagic or VCOM's Partition Commander?helpful. Both tools are relatively inexpensive (approximately $40-$70) and support partition types and operations not supported by fips. For example, they can split NTFS and Linux ext3 partitions. This is important, because you may not initially create Linux partitions of exactly the right size. Using fips, you'd be stuck; but, using PartitionMagic or Partition Commander, you can change your system's partition structure as many times as you like until you get it just right. For information on PartitionMagic, see the PowerQuest web site at http://www.powerquest.com/partitionmagic. For information on Partition Commander, see the VCOM web site at http://www.v-com.com/product/pc_ind.html.