Windows DevCenter    
 Published on Windows DevCenter (http://www.windowsdevcenter.com/)
 See this if you're having trouble printing code examples


O'Reilly Book Excerpts: PC Hacks

PC Hacks for Windows

by Jim Aspinwall

Jim Aspinwall, author of PC Hacks, has hand-selected three must-have hacks for Windows. Jim will show you how to give your Plug and Play a lesson in playing well with others by tweaking your BIOS parameters; how to pick up CPU speed by applying proper CPU cooling techniques; and how to help your hard drive perform better with less wasted space by setting it up the way you want it.

Related Reading

PC Hacks
100 Industrial-Strength Tips & Tools
By Jim Aspinwall

Hack #18. Reeducate Plug and Play

Get Plug and Play back in sync with reality and Windows by forcing it to rethink what it knows about your PC and peripherals.

The Microsoft Windows Plug and Play BIOS extension generally knows when a new device is installed, as you can see in Microsoft Windows when a “New hardware found” dialog appears, but it doesn’t know if you’ve changed the configuration of a device through its configuration/setup program or using Windows Device Manager.

It is possible, depending on the capabilities of the respective device drivers (usually for PCI network and SCSI cards), to reconfigure an I/O device through Device Manager. This reconfiguration is not dynamic: Windows won’t really know about it until Plug and Play BIOS tells it things have changed. That only happens at bootup, and sometimes only if the BIOS is told to look for the change. Merely changing a device’s internal configuration does not constitute a new or removed device in Plug and Play’s “mind,” and it never gets it without some help.

To tell Plug and Play that things have changed by adding or removing an I/O device, or by “soft” changes you made within Windows, you have to reboot your system, enter the BIOS setup, and then force Plug and Play to reassess the system configuration. This gets the BIOS to reconfigure the system properly, and informs the operating system of the changes.

Reeducating Plug and Play is done by a parameter most often named “Reset Configuration Data” or “Reset NVRAM” (non-volatile RAM). NVRAM is an area of memory on the system board that stores Plug and Play data. Make sure that Plug and Play OS is set to Yes (provided you have a Plug and Play–compliant operating system, such as Windows), set the Reset value to Yes, and then restart your PC. The BIOS will reevaluate the system configuration, store any new data, and make it available to the operating system (see Figure 2-9).

Figure 2-9
Figure 2-9. Resetting the configuration data forces Plug and Play to roll the dice again to reset device configurations based on new settings

Hack #24. Keep It Cool

Better to overcool than undercool. A CPU survives best with adequate cooling to keep it stable.

Hackability of the CPU and system board is not the only consideration for a CPU speed tweak. As the CPU goes faster, the internal temperature rises, stressing the incredibly small wires and component structures inside. With excessive heat comes random lockups of the system and possibly catastrophic failures, with some spectacular but short-lived fireworks as the CPU melts down. To counteract excessive heat requires significant cooling capability attached to the CPU chip, so you will see a lot of heat-sink and cooling fan gimmicks and gadgets for sale with CPUs. Check the documentation that comes with the CPU chips, and you will find recommendations and warnings about ensuring proper CPU-to-heat-sink contact and adequate ventilation. Figure 3-10 shows an example of a specially milled heavy-duty supercooling heat sink from an HP server with an integrated fan. HP engineers lay claim to inventing this style of cooling device, and it either works very well or just looks cool as heck! This design has been cloned by many aftermarket vendors.

Figure 3-10
Figure 3-10. This bolt-down heavy-duty heat sink from an HP server keeps the CPU quite cool

WARNING: Never run your CPU without a heat sink, especially the ultra-hot AMD processors!

Anyone who has run an AMD Athlon or Duron CPU—any version at any speed, overclocked or not—will tell you that the chip must be fitted with a decent heat sink and fan before any power is turned on, or the CPU will almost certainly fail. Figure 3-11 shows two CPU chips that have suffered catastrophic thermal failure when operated without a heat sink. Try as you might, you cannot put the “magic smoke” back in the chip and have it work again.

WARNING: Avoid inhaling the smoke or fumes from a “flamed-out” chip. When the internal elements of a CPU or other semiconductor melt or burn, they give off very foul-smelling and possibly toxic fumes. If a CPU does burn up, ventilate the area well to clear the air and be wary of nausea, dizziness, or other ill effects of toxic contamination.

Figure 3-11
Figure 3-11. Fried CPUs with evidence of explosive damage along the near edges of the cover over the CPU

The stock heat sink that comes with your CPU is adequate for operating the CPU at its rated speed, but overclocking and voltage adjustments can raise CPU temperature dramatically. In most cases of moderate (10–20%) clock or voltage (5–10%) increase, a slightly bigger heat sink and better ventilation will suffice to keep the chip temperature within safe operating range. In the rare cases when you can kick the CPU speed up by 25–200% or more, you need to provide some serious heat removal.

Current CPU types provide internal temperature sensors that can be read by the system BIOS and by some utility programs like SiSoft Sandra. Reading the temperature of your system running normally will give you a baseline operating temperature to compare with as you overclock. You must avoid reaching or exceeding the thermal limits of your CPU.

Although the maximum idle temperature on many AMD CPUs can be as high as 95 degrees Centigrade, the actual running temperature is 30–40 degrees C. Many BIOS versions provide CPU temperature alarms at 60, 65, and 70 degrees C. Your heat sink and ventilation should keep the CPU’s running temperature well below 60 degrees C, and you should overclock your CPU no more than 25%. The secret to heat removal is to have a large mass of material with low thermal resistance to conduct heat away from the chip into the surrounding cooler air. Alternatively, you can attach a device with a circulating coolant that draws the excess heat away quickly and dumps away from the system components, like the radiator in your car or home air conditioner does.

Aluminum is the ideal metal for most heat sinks. It has low thermal resistance, so it can accept and dissipate thermal energy very efficiently. It is inexpensive and easily manufactured into a variety of shapes that provide fast thermal dissipation and contact with almost any surface that needs cooling. Copper, also used in some heat sinks, is more expensive but is the material of choice for water-cooled devices.

In addition to using a highly thermal-conductive material, that material must be as tightly attached to the CPU as possible. It is not adequate to merely place the material next to the CPU: the bond must be as close to being a part of the CPU as possible. The bond is usually made with a very thin layer of thermally conductive grease or epoxy adhesive specifically for heat-sink bonding.

The layer must be very thin because the compound or adhesive is intended to improve the metal-to-metal contact by filling in minute imperfections in both surfaces to provide optimal contact and thermal transfer. If the layer can be made thin enough, it will only cover the imperfections and leave metal-to-metal contact at the high spots common to both surfaces.

TIP: An often neglected attribute of using a thin layer of thermal compound is that it eliminates air bubbles between the surfaces that may trap a small amount of moisture. Moisture trapped between a hot device and its heat sink does not constitute water cooling; instead it could be a small water bomb waiting to go off. See Step 11 in the instructions that follow.

If the temperature of the moisture bubble exceeds 100 degrees Celsius or 212 degrees Fahrenheit (the boiling point of water)—and it can with a souped-up CPU—the water will expand to 2,700 times its volume as steam and demand to go someplace. That will likely be in the direction of destroying the CPU chip or at least weakening the overall thermal bond, causing the CPU to overheat and self-destruct.

If you’ve removed a heat sink from a CPU (best done with either a slight twisting motion to separate heat sink and CPU or very light prying between the two), beware that some are glued on with high-temp epoxy and cannot be removed without destroying the CPU. You’ve probably experienced this thermal grease or heat-sink compound—a tenacious white material that looks and feels like toothpaste but stains like red wine in the middle of a new white carpet. Thermal compound is typically a mixture of aluminum oxide for thermal conduction and a silicon paste to hold the aluminum oxide together (see Figure 3-12).

Figure 3-12
Figure 3-12. Thermal compound fills the gaps between heat sink and CPU

Two new compound mixtures have emerged: one containing aluminum oxide in a fine ceramic form, the other silver and silver oxide. According to product documentation at http://www.articsilver.com, the typical aluminum oxide–based white paste provides the lowest thermal conductivity and the least CPU temperature drop (2–7 degrees), the ceramic compound is next in the order of effectiveness (2–10 degree drop), and the silver-based compound the most efficient, providing a 3–12 degree drop in CPU temperature. The effectiveness is also represented in the cost of the compound— between $4 and $9 per tube. Unless you see your CPU temperature rising towards its maximum limits, the typical aluminum oxide, and certainly the ceramic paste, are more than adequate for the task.

TIP: For a time, Intel prebonded heat sinks to some versions of their Pentium I CPUs using thermal epoxy, making it impossible to separate the two if you wanted to add a larger heat sink.

To speed production processes and make applying thermal bonding cleaner, many vendors have chosen to use thermal pads, as shown in Figure 3-13. Thermal pads are fine in lower-temperature applications, but, while they certainly fill gaps between surfaces, they do not give way to allow direct surface contact between high spots. If you separate a CPU and heat sink that were bonded with a thermal pad, it is acceptable to replace the pad with thermal paste instead, unless the warranty on your CPU requires the use of the supplied thermal pad and heat sink.

Figure 3-13
Figure 3-13. Two forms of thermal pads used on CPU heat sinks

No matter which compound you choose, the technique for properly applying thermal compound to obtain optimal thermal bonding between a cooling device and a CPU involves a few very simple items and steps.

Figure 3-14
Figure 3-14. Basic items needed to bond CPU and heat sink

Use these items to install your heat sink as follows:

  1. Remove the CPU from its socket and set it pins-down on the antistatic material.

  2. Maintain cleanliness! Apply a few drops of isopropyl alcohol to the clean cloth and wipe the contact surface area of your heat sink and the top cap of the CPU core. Alcohol will remove most oils and help evaporate moisture from the surfaces.

  3. Apply a small bead/drop of thermal compound to the area of the heat sink that will contact the CPU, as shown in Figure 3-15.

  4. Protecting your fingers with the vinyl glove or plastic wrap, smear the compound around and into the surface of the heat sink, as shown in Figure 3-16. This will help fill imperfections in the metal surface.

  5. Using a clean, dry portion of the cloth, wipe the excess thermal compound off the surface of the heat sink, as shown in Figure 3-17. If the compound is especially thick and hard to wipe off, scrape the excess off with the straightedge and then wipe clean. You should not expect to remove all evidence of the compound, but leave minute amounts on the surface. Do not use alcohol to clean the surface.

    Figure 3-15
    Figure 3-15. Apply thermal compound sparingly

    Figure 3-16
    Figure 3-16. Rubbing thermal compound into the heat sink surface

  6. Apply a small bead of thermal compound to a corner of the CPU’s metal die/cap, as you did in Step 1.

  7. Using the straightedge, distribute the compound evenly across the surface of the top of the CPU as shown in Figure 3-18.

    Figure 3-18
    Figure 3-18. Spreading thermal compound on the CPU

  8. Remove as much excess as possible but leave a thin layer of compound, as shown in Figure 3-19.

    Figure 3-19
    Figure 3-19. CPU with thermal compound ready for installation

  9. Install the CPU in its socket on your system board. Be careful not to disturb the thermal compound.

  10. Align and place the heat sink as squarely and accurately in its final placement above the CPU as possible.

  11. Apply a slight downward pressure evenly on the heat sink, then twist the heat sink to the left and right of its final placement position and back to its final centered position, as in Figure 3-20. This action will press out excess compound and fill in any gaps, reducing any bubbles and the surface-to-surface distance between the heat sink and CPU.

  12. Secure the heat sink in place with its bracket (usually clipping in the back-end bracket slots and then the side with the “handle”), plug in the fan if your heat sink is equipped with one, and begin to enjoy your cooler CPU.

    Figure 3-20
    Figure 3-20. Slight pressure and twisting bonds the heat sink to the CPU

TIP: Follow the directions carefully for heat-sink fastening. The mechanics and fastening system for your heat sink, CPU, and system-board socket may be different than the one shown.

Hack #40. Partition and Format Wisely

Partition your drive for efficient file play.

Do you know how much of your hard disk space you’re wasting? If you are using Windows 95, 98, 98SE, or ME (even 2000 or XP without NTFS), you could be wasting at least 10% and possibly up to 30% of your hard drive space due to suboptimal allocation unit sizes.

Disk partitions are logical regions of a disk drive containing a filesystem. Partitioning a hard disk is like subdividing parcels of land and dictating how those parcels will be further subdivided into lots or common areas. Partitioning establishes how big the parcel of land to be used will be. The filesystem within a partition contains files and directories that are organized in what we see as a hierarchical tree structure.

We use the filesystem and the tools and support for it within an operating system to put things into and take them out of the “parcels” (called clusters) of space allocated in the partition. If we put a small house in a large parcel (cluster) we have a lot of empty space. In terms of land, we could landscape or farm that space, but in terms of filesystems, we get only one “house” per cluster. One house may occupy many clusters, but nothing else can use that cluster, even if there is empty space within it.

The Different Partition Types

The different operating systems available for PCs provide support for various partition types and filesystems. There are five types of partitions you will encounter on x86 machines:

Primary

A primary partition is the first and often the only partition on a hard disk drive, occupying all available disk space. A primary partition is required for DOS and Windows 9x-Me, but Windows NT and later, as well as Linux, can boot from an extended partition. The primary partition can contain only one logical drive. You may have up to four primary partitions, or a maximum of three primary and one extended partition.

Extended

An extended partition can only exist if there is at least one primary partition. This partition may occupy the remainder of the drive’s free space or only a portion of it; the remainder may contain either NTFS or non- DOS partitions. The extended partition may contain one or more logical drives.

Logical

Within an extended partition, at least one logical partition must be made if a DOS or Windows filesystem will access the space as a drive letter. If the extended partition is created but no logical partitions are created within it, any operating system may lay claim to the space or change the extended partition into a non-DOS partition.

NTFS

An NTFS partition is typically created and used by Windows NT, 2000, XP, or 2003. DOS and Windows 9x-Me utilities have no direct control over or access to NTFS partitions. Each NTFS partition may contain logical partitions and drives of their own.

Non-DOS

A non-DOS partition is any partition type not supported by DOS or Windows, which could be any of the different versions of Linux, FreeBSD, SunOS, or others. Those specific operating systems may allocate space and filesystem support through numerous other filesystem types.

TIP: The FDISK utility that comes with MS-DOS and Windows 95, 98, and Me refers to filesystems created by other operating systems (such as Linux or FreeBSD) as non-DOS partitions.

On most IBM, HP, Compaq, and Dell systems, the first partition may be a non-DOS rather than a primary partition, may have an MBR, and may be made Active, but instead of an operating system may contain a boot loader to access diagnostic, system setup, and recovery files. This partition may consume a few tens of megabytes to a few gigabytes, depending on what the vendor wants to store in it for later use.

The BIOS in these systems will present a boot loader option to press a specific key to access these features and boot from this partition, and if that key is not pressed within a preset amount of time the BIOS will set another partition (primary, NTFS, or other non-DOS partition) to Active to load the operating system. Alternatively, some systems require use of a recovery boot diskette or CD that provides access to the recovery files on the recovery partition.

Each partition type may be either the Active (bootable) partition or not. An Active partition is not automatically a system or bootable partition, but must be made into a system or bootable partition by whichever operating system you install.

The Active partition is the one the PC system BIOS looks for in order to find bootable files and an operating system. To be bootable, the Active partition must have a Master Boot Record and must contain the bootable operating system files to start. The remainder of the operating system’s non-boot files may reside on another partition and logical drive. DOS and Windows 9x– Me will only boot from an Active and primary partition.

TIP: Third-party multiboot utilities like BootMagic, LILO, GRUB and System Commander change the Active partition to select which operating system will boot up.

The boot loader in Windows NT through Windows Server 2003 can boot DOS or other versions of Windows in the same Active partition.

Windows 2000 and Windows Server 2003 support two types of disk configurations —Basic and Dynamic—created with Windows Disk Management console. A Basic disk can use the partition tables supported by respective versions of Windows, MS-DOS, and Windows NT. A Basic disk, the typical type of partition you use, can hold primary partitions, extended partitions, or logical drives.

Basic volumes include partitions and logical drives and may contain volumes created using Windows NT 4.0 or earlier, such as volume sets, stripe sets, mirror sets, and stripe sets with parity. In Windows 2000, these volumes are called spanned volumes, striped volumes, mirrored volumes, and RAID-5 volumes, respectively.

Like a Basic volume, a Dynamic disk can hold simple volumes, spanned volumes, mirrored volumes, striped volumes, and RAID-5 volumes. However, with Dynamic storage, you can perform disk and volume management without having to restart the operating system.

In most cases, you will encounter only primary and extended partitions, or NTFS partitions with Basic disks.

The Different Filesystems

After you’ve partitioned a drive, you need to decide which filesystems will actually live on it. There are dozens of different filesystems you may encounter in the wild. Here are a few:

DOS FAT-12, FAT-16, FAT-32

DOS filesystems known as FAT-12, FAT-16, and FAT-32 (although no version of DOS supports FAT-32) have evolved from the early days (when only diskettes were available) to support increasingly larger hard drives. The “FAT” in the filesystem names stands for File Allocation Table, which is something every filesystem has in some form but that stuck as the exclusive name for DOS filesystems. The numeric designation refers to how many bits of information are available to identify the clusters where files are stored: 12 bits allows 4,096 clusters/files (including directories), 16 allows 65,536 clusters/files to be kept track of, and 32 bits allows up to 4.2 billion clusters/files to be kept track of in a single partition. The directory entry in a FAT filesystem keeps track of start and end clusters for each portion of a file that is stored, as well as the filesystem attributes—Read-Only, Archive status, Hidden, and System files. No file access security is provided for in a DOS/FAT file system.

NTFS

One or more NTFS partitions may exist on a hard drive, with or without Primary and Extended or Non-DOS partitions. NTFS is a journaling filesystem, meaning that it records information about filesystem activity to improve recoverability in the event of a system crash. NTFS uses two methods to keep track of directories and files: first, a Master File Table (MFT) that “knows all” about the directories or folders and files on the disk and, second, the files themselves, which store information about the files. In fact, if a file is small enough, it is contained within the MFT itself rather than on a separate area of the disk. Directories in NTFS store information about the directory, not the files in them. The information about a file in an NTFS filesystem stores not only filename, location, and attributes, but also security information. The number of files and directories NTFS can store is almost limitless, unless the Master File Tables grow so large from keeping track of so many files that they consume all the free space on the drive.

ext, ext2, and ext3

The ext filesystems are used by Linux. ext supports drives and individual files as large as 2 GB. ext2 supports partitions as large as 4 Terabytes and files as large as 2 GB (Linux 2.2) and over 2 GB for Linux 2.4 and above. ext3 is a journaling filesystem compatible with ext2. A journaling filesystems makes a record of filesystem changes before they are made, which adds greater reliability to the file activity.

reiserfs

reiserfs is a journaling filesystem with exceptional granular security capabilities suitable for military applications, developed under DARPA (Defense Advanced Research Projects Agency) sponsorship. Significant information on reiserfs can be found at http://www.namesys.com.

jfs

jfs is a journaling filesystem for Linux servers developed by IBM. More information about jfs can be found at http://oss.software.ibm.com/developerworks/opensource/jfs/.

The FAT and NTFS filesystems track disk space use in predefined allocations of clusters. Clusters are made up of one or more 512-byte units of storage space. Under the FAT-16 filesystem, the maximum number of clusters is determined by a 16-bit numbering system and a predetermined maximum number of 512-byte sectors of space per cluster. These days, the only place you are likely to encounter FAT-16 partitions is on much older computers, flash memory cards, and embedded systems, but you can still create a FAT-16 filesystem if you need to access the space through an older (6.22 and earlier) version of DOS.

Under these design constraints and limitations, the largest possible disk partition in a FAT-16 filesystem may consist of 65,536 clusters of data. The maximum allowable cluster data size is 64 sectors per cluster, or 32,768 bytes. In total, the maximum size of a FAT-16 disk partition is approximately 2,048 megabytes (2 gigabytes). (The previous partition size limitation under early DOS versions using the FAT-12 filesystem was a meager 32 megabytes.) Table 5-1 lists the FAT-16 cluster sizes for various partition sizes. By the way, a cluster may contain only one file reference, so there is also a limitation on the total number of files a FAT filesystem can keep track of: 65,536 files for FAT-16.

Table 5-1. Cluster sizes for FAT-16 partitions

Partition size FAT-16 cluster size
0–127 MB 2 KB = 2,048 Bytes (4 sectors)
128–255 MB 4 KB = 4,096 Bytes (8 sectors)
256–511 MB 8 KB = 8,192 Bytes (16 sectors)
512–1,023 MB 16 KB = 16,384 Bytes (32 sectors)
1,024–2,047 MB 32 KB = 32,768 Bytes (64 sectors)

TIP: With a FAT filesystem it is possible under any filesystem to run out of disk space not because you’ve filled up your entire drive with files but because you’ve used up the number of file allocations the filesystem provides, so the more clusters you have, the higher the total number of files you can store.

The FAT-32 filesystem supported under Windows 95 OEM SR2, 98, 98SE, Me, NT (SP4 and later), 2000, and XP can accommodate disk drives up to 4 terabytes in size (32 GB under Windows 2000), with as many as 4 billion clusters/files with cluster sizes of 32 KB. For very small (512-byte) files this results in less than 2% file storage efficiency and a gross waste of space, indicating that partitioning your drive to use smaller cluster sizes is advisable for many of us. FAT-32 limits the maximum file size to 2 GB, which is adequate for most of us, but if you expect to work with larger files—large databases for example—you must use NTFS. Table 5-2 lists the cluster sizes for FAT-32 partitions.

Table 5-2. Cluster sizes for FAT-32 partitions

Partition size FAT-32 cluster size
0-259 MB 512 bytes (1 sector)
260-511 MB 4 KB (8 sectors)
512-8,191 MB 8 KB (16 sectors)
8,192-16,383 MB 16 KB (32 sectors)
32,768 MB-2 Terabytes 32 KB (64 sectors)

The NTFS also allocates disk space in increments or units as little as 512 bytes—which, coincidentally, is the size of a single sector of disk space. Like the FAT filesystem, unless you select an allocation unit of 512 bytes when partitioning and formatting, sectors are usually combined to make up clusters, but NTFS has a large enough numeric range to keep track of a lot of clusters, so clusters can be as small as a single 512-byte sector or made up of multiple sectors. The maximum number of nits—clusters or sectors—that NTFS can keep track of provides for maximum disk space capacities in the order of terabytes. The most space any file will waste is only some portion of the clusters—as is evident with FAT filesystems. As shown in Table 5-3, NTFS uses clusters to track file storage, but these clusters are much smaller than the clusters of FAT-16 or FAT-32 filesystems. It is possible to reformat NTFS partitions using XP’s Disk Management console to use smaller or larger cluster sizes at your discretion.

Table 5-3. Cluster sizes for Windows NTFS partitions

Partition size NTFS cluster size
0–512 MB 512 bytes (1 sector)
512–1,024 MB 1,024 bytes (2 sectors)
1,024–2,048 MB 2,048 bytes (4 sectors)
2,048–4,096 MB 4,096 bytes (8 sectors); 8,192 bytes and larger possible
4,096–8,192 MB 8,192 bytes (16 sectors)
8,192–16,384 MB 16,384 bytes (32 sectors)
16,384–32,768 MB 32,768 bytes (64 sectors)
> 32,768 MB 65,536 bytes (128 sectors)

In most cases, when you cannot predict the general size or types of files you will be saving, large or small, it is preferable for storage efficiency to use the smallest cluster size possible. By large files I mean those measured in tens or hundreds of megabytes, something that really chews up disk space that you want to access with as few repetitive disk operations as possible (such as huge database files that may be found on servers, or video files). Most of us, unless we collect a lot of audio and video files, have mostly small datafiles— far less than a megabyte—including all the text and graphics from web pages, email, and average documents and spreadsheets.

Depending on the disk-caching read-ahead method and amount of cache used within a specific disk drive, using a 1 KB cluster size under NTFS will require the equivalent of 1,000 discrete disk accesses to read or write a 1 megabyte file versus 250 accesses with a 4 KB cluster size, but the alternative is having your average 1–2 KB web page and little (50–256 byte) graphics files chewing up 2–4 KB more disk space than they need to. A measly 2–4 KB may not seem like much, but if you let Internet Explorer’s Temporary Internet File caching grow to 512 MB or larger, you’re easily wasting 256 MB of disk space on a bunch of web files you may never see again anyway. Figure 5-1 illustrates the size of the datafile on an NTFS volume with 8,192-byte (16-sector) clusters (483 512-byte sectors or 30.1875 8,192-byte clusters) and the amount of disk space the file actually consumes (488 512-byte sectors or 30.5 8,192-byte clusters). This file ends up wasting 0.5 clusters or 4,096 bytes of disk space. If you add up a lot of datafiles wasting half a cluster or more—especially if the cluster sizes are 8, 16, 32, or 64 KB each—you end up with a lot of unusable disk space, also known as “slack” space, occupied by absolutely nothing of value.

Figure 5-1
Figure 5-1. Windows File Properties reveals actual data size versus disk space used

It is important to note that the disk operations and performance seen by the operating system can be significantly different than what goes on inside the drive itself. The drive, of course, has to read or write all sectors containing data the operating system wants and will be doing all of the mechanical work to find each and every sector needed, be they contiguous (unfragmented files) or spread out in different places on the drive (fragmented files).

The operating system’s file and directory scheme keeps track of files in the file tables (the directory of the Master File Table) and tells the drive where to get file fragments from. The drive only knows how to find tracks and sectors and doesn’t know where specific files are. If the drive’s firmware and caching scheme are smart, it will optimize file placement and file reads by itself. If the drive has a large internal cache, it will take in all or most of the operating system’s commands, tell the OS it’s “got it,” and go off and do the work, releasing the OS to do other things. Someday perhaps we’ll have operating- system-aware disk drives or specific disk drives that filesystems offload functions to so the OS can be an OS rather than a file manager, but for now the operating system and driver vendors are responsible for optimizing their file- and disk-handling functions.

TIP: NTFS supports and can be configured to use on-the-fly file compression to save disk space on a drive-by-drive or file-byfile basis. NTFS will not compress files on a drive using a cluster size of 4 KB or less.

Jim Aspinwall has been the Windows Helpdesk columnist and feature editor for CNET.com and is the author of three books on PC maintenance.


Return to WindowsDevCenter.com.

Copyright © 2009 O'Reilly Media, Inc.