Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions




2.3 Preparing Your Hard Disk

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, you'll learn how hard disks are organized, then you'll learn how to view the structure of a hard disk. Finally, you'll learn how to alter the structure of a hard disk.

2.3.1 How Hard Disks are Organized

Let's start by reviewing facts you've probably learned by working with Microsoft Windows. Most operating systems, including Microsoft Windows 95 and Windows 98, manage hard disk drives by dividing their storage space into units known as partitions. So that you can access a partition, Windows 95 and Windows 98 associate 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. Microsoft Windows supports several types of filesystems, such as FAT and FAT32, a newer filesystem type that provides more efficient storage, launches programs faster, and supports very large hard disk drives.

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.3 shows the logical and physical structure of a disk drive.

Figure 2.3: The structure of a hard disk

Figure 2.3

Mechanically, a hard disk is constructed of platters that resemble the phonograph records found in a old-fashioned juke box. 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. Most PCs require you to specify the geometry of a drive in the BIOS setup.

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 block addressing (LBA). LBA sequentially numbers sectors, letting programs read or write a specified sector without the burden of specifying a cylinder or head number.

2.3.2 Viewing Partition Information

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 hard disk drives, you can use the fdisk utility:

  1. Click on the Start menu. The Start popup menu appears.

  2. Select Programs. The Programs submenu appears.

  3. From the Programs submenu, click on MS-DOS Prompt. An MS-DOS Prompt window appears.

  4. Type fdisk and press Enter. The fdisk menu appears, as shown in Figure 2.4.

    The fdisk menu may not appear immediately. Instead, Windows may ask if you want to enable large disk support. If this occurs, type N and press Enter. You don't need to enable large disk support to view partition information.

    Figure 2.4: The fdisk Options screen

    Figure 2.4
  5. Type 5 and press Enter. This takes you to a screen, resembling the one shown in Figure 2.5, that lets you specify the current fixed disk drive. This screen displays partition information in a more readable format than the screen you obtain by using menu item 4, "Display Partition Information."

    The screen shows each hard disk 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 free 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.

    Figure 2.5: The fdisk Change Current Fixed Disk Drive screen

    Figure 2.5
  6. When you're done viewing partition information, press Esc twice to exit fdisk and return to an 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.

2.3.3 Obtaining Sufficient Disk Space

You cannot install Linux to a partition already in use. By viewing the partitions on your hard drive, you can determine which of the following two cases best describes your system:

  • You have available free (unpartitioned) disk space large enough to accommodate Linux (600 MB to 1.6 GB, depending on the type of installation you want).

    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, Installing Linux. However, see the following tip on PC BIOS limitations.

  • You don't have enough free (unpartitioned) disk space to accommodate Linux.

    The procedures given in this section will help you obtain the necessary free space.

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 section titled " Section, "Installing a new disk drive" offers some considerations and tips on installing a new drive.

  • If you have one or more unneeded partitions, you can delete them and use the space you gain to hold Linux. The section titled " Section, "Identifying an unused partition" shows you 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. The section titled " Section, "Shrinking a partition" shows you how to determine whether a partition is larger than needed and how to free the excess space. Installing a new disk drive

Often, the easiest way to install Linux is to install a new disk drive. If your system has only a single hard disk 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. You'll also need to plan how to move data from your existing hard drive to the new hard drive. Consult your system vendor for assistance, if necessary.

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. 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. Identifying an unused partition

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 that 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.

The easiest way to delete a partition is to use Debian's cfdisk utility. Make note of the partition you wish to delete and then simply begin the installation process described in the next chapter. Shrinking a partition

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 that you can use to hold 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 popup menu. The Properties dialog box that appears shows the amount of used and free disk space associated with the drive.

If you are able to find one or more 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. The Linux CD-ROM includes the GPL fips utility, which can split FAT and FAT32 partitions. For information on using fips, see the next section.

WARNING: If you make a mistake while attempting to shrink a partition or if the software malfunctions, you may lose all data in one or more partitions. You should not attempt to shrink a partition until you've completely backed up your system and made sure that your backup is usable.

Many Linux users find PowerQuest's PartitionMagic utility helpful. Unlike fips, PartitionMagic is commercial software; however, it supports partition types and operations not supported by fips. For example, PartitionMagic can split NTFS, HPFS, and Linux ext2 partitions. Using the fips utility

The fips utility lets you split a FAT partition into two partitions, one containing the data of the original partition and the other containing no data. Version 2 of the fips utility lets you split a FAT or FAT32 partition. Once you've run fips, you can use the fdisk program to delete the new empty partition, creating free space for installing Linux.

The fips utility will not split a partition unless there is at least about 10 MB of free space at the end of the drive. Moreover, fips requires a free entry in the disk's partition table; it will not work if your drive already contains four partitions.

This section describes the procedure for using fips. It assumes that you're running Microsoft Windows 9x. If you're running another operating system, consult the fips documentation for special instructions.

WARNING: In the words of its author, fips is "somewhat experimental." Neither the author of this book nor the publisher can accept responsibility or liability for damage resulting from your use or misuse of fips. You should not attempt to use fips until you've completely backed up your system and made sure that your backup is usable.

Also, your Microsoft operating system may assign different letters to drives after you use fips to split a partition. For example, your D: drive may become E:. The fips utility ensures that the C: drive remains C: so that you will generally be able to boot your system; however, you may not be able to properly access programs or files that reside on drives other than C:.

Before running fips, you should check the condition of your hard drive by running chkdsk, ScanDisk, Norton Disk Doctor, or a similar program. To launch the ScanDisk program, click Start -> Programs -> Accessories -> System Tools -> ScanDisk. If your program reports errors, you should not attempt to split the partition until you resolve them.

Next, you must defragment your hard drive. Defragmenting a drive moves all its data to the beginning of the drive, leaving all the free space at the end. You can defragment your drive by using the Microsoft defrag utility. Simply click Start -> Programs -> Accessories -> System Tools -> Disk Defragmenter. However, you can use another defragmentation program if you prefer; the Norton Speedisk program, PCTool's Compress program, and various shareware programs are suitable.

The Microsoft defrag program doesn't always defragment a drive as thoroughly as possible. It sometimes erroneously regards some disk blocks as bad or immovable, and thus can fail to clear space that another program would successfully reclaim. If you find the results of using defrag disappointing, you should consider using a different program.

Next, you should disable virtual memory. Launch the Control Panel by clicking Start -> Settings -> Control Panel. Then, double click on the System icon. The System Properties dialog box appears. Select the Performance tab and click on "Virtual Memory..." The Virtual Memory dialog box appears. Make a note of the current setting. Then, click on "Let me specify my own virtual memory settings" and then click on "Disable virtual memory." Click on OK to dismiss the Virtual Memory dialog box. Finally, click on OK to dismiss the System Properties dialog box.

Next, create a boot floppy, by using the Add/Remove Programs control panel applet. Double click on the Add/Remove Programs icon in the Control Panel. The Add/Remove Program Properties dialog box appears. Click on the Startup Disk tab and then click the Create Disk button. A progress bar appears on the Add/Remove Program Properties dialog box. When prompted by the program, insert your Windows 9x CD-ROM. After reading from the CD-ROM, the program will prompt you to insert a formatted floppy disk into your system's floppy drive. Label a floppy disk "FIPS" and insert it into the drive. As the boot disk is being written, the progress bar informs you of the task's status. After a few minutes, the progress bar will disappear, informing you that the boot disk has been created. Click on OK to dismiss the Add/Remove Program Properties dialog box.

Do not remove the diskette from the drive. Instead, copy the following files from the CD-ROM onto the floppy disk:


If you use IMAGE or MIRROR or if your config.sys or autoexec.bat file invokes programs that write to your hard disk, use the Windows Explorer to temporarily rename config.sys to config.fip and autoexec.bat to autoexec.fip. If you're unsure what programs your config.sys and autoexec.bat files invoke, play it safe by renaming both files.

Now, boot your system by using the floppy diskette you created. When the MS-DOS command prompt appears, type fips and press Enter to launch the fips utility. If you have more than one hard disk drive, fips asks which disk it should access. Respond by identifying the appropriate disk drive.

Next, fips gives you the opportunity to create a backup file on your A: drive. You should allow fips to create the file. Then, if something goes wrong in using fips, you can boot from your floppy diskette and run the restorrb program to return your hard drive to its original state.

The fips utility then displays the partitions found on your hard disk. You need pay attention to only the first and last columns of the display, which indicate the number and size of each partition.

The fips utility performs some analysis of your hard drive. Then, if your hard drive contains more than one partition, fips asks you which partition you wish to split. Type the number of the partition and press Enter.

After performing some further analysis, fips asks you to enter the number of the cylinder on which the new partition should begin. Use the left cursor key to decrease the number and the right cursor key to increase it. As you increase or decrease the cylinder number, fips displays the size of the two partitions it will create. After setting the proper cylinder number, press Enter.

You may find that the maximum size of the empty partition is much smaller than you expected. If so, this is probably due to the presence of a hidden file that your defragmentation program was unable to move.

To identify such files, open an MS-DOS Prompt window, type the command dir /a:h /s and press Enter. Ignore any files with names similar to or Try to determine what program created any remaining hidden files. If you can identify the program, you may be able to create a larger empty partition by uninstalling the program, splitting the partition, and reinstalling the program.

The fips utility displays the new partition information. You can type Y to save your changes and exit, or type C to make additional changes.

After exiting fips, you should immediately boot Windows 9 x and run ScanDisk to verify that the partitions created by fips are valid. Do not write anything to the disk before rebooting; otherwise, you may destroy information on your hard drive.

Next, you should re-enable virtual memory. To do so, launch the Control Panel by clicking Start -> Settings -> Control Panel. Then, double click on the System icon. The System Properties dialog box appears. Select the Performance tab and click on Virtual Memory. Return the settings to the values you earlier noted, then click on OK to dismiss the Virtual Memory dialog box. Then, click on OK to dismiss the System Properties dialog box.

If you renamed your config.sys and autoexec.bat files, restore the original names by using Windows Explorer.

Finally, reboot your system so that the changes to your system's virtual memory settings become active. Now you're ready to install Linux to the new empty partition.

  Learning Debian GNU/Linux Next: 3. Installing Linux
  Book Index 3. Installing Linux

  Published under the terms of the Creative Commons License Design by Interspire