Using CHKDSK from the Command Line

XP includes the Check Disk utility as a way to search for and repair file system errors on your hard disks. While the graphical version of the tool is accessible from the Tools tab in the properties of a disk, XP also includes a command-line version of the tool in the form of CHKDSK. When run from the command line, this tool allows you to scan for file system errors, fix those errors, and even specify which specific files should be checked if you don’t want to scan an entire volume.

For example, the command CHKDSK E: /R will scan drive E: for errors, and fix any errors encountered. An example of this command is shown below. As part of your regular maintenance schedule, run CHKDSK at least once per month to ensure good disk and file system health.

Why Is Disk Defragmentation Necessary?

When files are saved to a hard disk, they aren’t necessarily saved in an area of contiguous disk space. For example, a 10 K file might be fragmented and spread over three disparate disk clusters, each 4 K in size. When this file is accessed, the system needs to obtain the contents of each of the clusters to open it, which would involve reading different areas of the disk for a single file. When defragmentation is performed, fragments of the same file are saved in contiguous areas of disk space, thus speeding up read access to the file and improving performance.

Keep Your Hard Tidy with the Disk Cleanup Tool

Over time, your PC will become cluttered with unused programs, temporary files, and deleted items stored in the Recycle Bin. Regardless of their location on your system, all of these files are capable of using up large tracts of your system’s disk space, something which can be detrimental from both a performance and available storage point of view. Quite simply, the more unnecessary files stored on your system, the less valuable disk space you have at your disposal. Disk Cleanup is the native Windows tool provided for the purpose of quickly finding and ridding your PC of unnecessary files, and you’ll want to run it at least monthly as part of your scheduled system maintenance activities.

Disk Cleanup is accessible via the Accessories > System Tools group on the Start menu. When this utility is opened, it will ask you to choose a drive to scan, and then calculate the amount of disk space that is being used by everything from Temporary Internet Files to the contents of your Recycle Bin. By simply checking the checkbox next to the appropriate item, Windows will permanently delete the selected files, allowing you to reclaim the associated disk space. Again, run Disk Cleanup at least once per month on your system, and more often if your usage is extremely high.

Testing For Drive Errors and Health with Check Disk

While defragmenting a partition will speed up disk access by placing files in contiguous disk clusters, another key disk maintenance task that should be performed at least monthly is running Check Disk. On a Windows 2000 or XP system, Check Disk is accessible from the Tools tab in the properties of a drive (like C). To open the tool, press the Check Now button in the Error-checking section.

Check Disk has two main purposes – to check for file system errors, and to scan for bad disk sectors and fix them if possible. As an electromagnetic component, a hard disk is susceptible to surface errors, so it’s important for the system to be aware of them and allocate data to known good sectors. By the same token, file system errors can cause data loss or system instability, so you’ll definitely want to check for them as well. Both tasks are easily configured by selecting the appropriate check boxes in the Check Disk tool.

As a general rule, Check Disk should be run at least once per month on newer systems, and more often (perhaps once every two weeks) on older PCs. If your PC is running an older version of Windows like 98 or ME, Check Disk is not included. Luckily, these systems include an older utility known as Scandisk – while it’s not quite as pretty as Check Disk, Scandisk performs similar disk checking functions on these versions of Windows.

Defragment Your Hard Drive for Better System Performance

While handling everything from the installation of programs to the storage of various data files, your PC’s hard disk drive is a workhorse that takes a great deal of punishment over time. As programs are installed and various data files are added and deleted, a hard disk eventually becomes fragmented, leaving bits and pieces of files spread across different (and non-contiguous) disk clusters. In simple terms, a fragmented hard disk will not perform optimally, since all of the fragments of a file must be assembled when that file is opened. Over time, fragmentation can severely degrade the performance of your hard disk, since individual fragments need to be searched for and reassembled by the system. If your PC seems slow right now, performing disk defragmentation often has a huge impact towards improving system performance.

Operating systems from Windows 95 forward have included a utility called Disk Defragmenter. As its name suggests, the primary role of this tool is to defragment your system’s hard disk on a partition-by-partition basis. The process begins by analyzing a partition to find its current degree of fragmentation, and then suggests whether defragmentation is necessary based on its findings. As a general rule, you should run Disk Defragmenter at least once per month on busy partitions like your C drive. When fully defragmented, your hard disk will be much more responsive, with files and programs opening much more quickly that they otherwise would. For details on how to use the Disk Defragmenter on an XP PC, see the details below. Note that the process can take quite some time on a system with badly fragmented partitions, so you might want to consider running it overnight the first time.

Step 1: Click Start, and select All Programs. Select Accessories > System Tools, and then click Disk Defragmenter. The Disk Defragmenter window will open. All partitions configured on your system will be listed, along with information about available disk space.

Step 2: Click the Analyze button. This will analyze the partition currently selected for fragmentation, and will graphically display the current state of fragmented, contiguous, and unmovable files on your system.

Step 3: Once the analysis is complete, you will be presented with the Disk Defragmenter dialog box. Click the View Report button to view the reported findings of the analysis. Scroll down to view information such as total fragmentation for the partition.

Step 4: If the Disk Defragmenter suggests that the partition need to be defragmented, click the Close button on the Analysis Report dialog box and then click the Defragment button. The defragmentation process can take anywhere from minutes to hours based on your system and its current state, so a little patience will be necessary.

Recovering Data from Hard Drives

It happens to everyone. You’ve accidentally deleted a file, emptied the Recycle bin, and now you don’t have a backup and want the file back. The good news is that a recovery is possible. The bad news is that you shouldn’t get your hopes up. Once data is deleted it can usually be recovered by using any number of undelete utilities, but only if other data has not already overwritten those clusters.

This is another excellent reason to consider saving data to a different partition – the partition with the OS installed is usually written lots of data to disk behind the scenes such as temporary files, which may end up making your data unrecoverable. You best bet is to install an undelete application (like Undelete), before you need to worry about data recovery – installing the undelete utility might actually be what makes the file you just lost unrecoverable if it uses the same disk space.

Checking Hard Drive Health with Scandisk and Chkdsk

Unlike RAM, your hard disk has moving parts, and as such is susceptible to errors. Over time, clusters can become corrupted, part of files can become lost, and a range of other errors can occur. You may have noticed how Windows 98/ME will run Scandisk when you don’t perform a proper shutdown, or how Windows 2000/XP will run Chkdsk in the same situation. In almost all cases, users choose to skip these checks, mainly because they can be somewhat time consuming, especially on large partitions. The truth is that you really should take the time to run both at least occasionally, especially if your system is getting old – it may save you from a whole lot of lost data in the long run.

In general, you should run Scandisk or Chkdsk at least once per month on older systems. ScanDisk is found in the System Tools program group, while Chkdsk can be launched from the Run command by typing chkdsk.exe on Windows XP systems. If you do run ScanDisk on a Windows 98/ME system, be sure to use the “thorough” option, as this will scan the surface of the disk for any errors. It can take a while to complete, so consider running it when you’ve got something else to attend to.

Defragmenting Hard Drives

Like changing the oil in a car, defragmenting partitions is a requirement, not an option. On a heavily used system, you should be defragmenting your disks at least once per month to ensure optimal performance. Remember that files are stored on a disk in clusters. Over time, as files are added and deleted, these clusters can become rearranged on the disk, or stored in non-contiguous block of space.

A badly fragmented disk results in very poor performance, as the drive needs to rebuild the data stored in those clusters when you want to open a file. If your disk seems slow, chances are good that all it needs is a good defragmenting. Use the Disk Defragmenter included with Windows XP to accomplish this, understanding that 3rd party defragmentations tools are generally more robust and provide for better optimization. For those looking to automate, Windows XP includes a command line defrag utility, which could be used to schedule the process automatically.

Partitioning Hard Drives

Given that hard drives sold today usually have a capacity of more than 15 GB, many users choose to split their disks into multiple logical partitions or drives. While partitioning is generally a matter of personal preference, it’s never a bad idea to have at least two partitions available on the disk. If you plan to install multiple operating systems, this is a must, because each really requires it own dedicated space. However, splitting a disk into multiple partitions is also a great way to separate your data from your operating system and applications.

For example, Windows 98 or XP and programs could be installed on the first partition, and all data files (including email and documents) could be stored on the second. The benefit of this model goes beyond simple organized. If this method is used, it’s very easy to use a utility like Norton Ghost to make an image of a fresh Windows installation that also includes your applications and configuration. Then, if you one day decide that you want to return to a clean system, you need only to install that image file again, and all of your data and settings will remain intact. This is a strategy that we’ve been using for ages, and it makes restoring a system a quick 20-minute process when necessary. That’s a whole lot better than a day spent reinstalling everything, not to mention attempting to restore all of your data correctly.

Unfortunately, many systems ship from the manufacturer with one large, single partition that occupies the entire disk. Without deleting this partition and starting from scratch, you would need to use a program like Partition Magic to resize the existing partition to a smaller size, and then create a new partition on the newly freed space. If you’re buying a new PC from a local reseller, ask them to define at least two partitions in advance – it will save you the time and effort later.