Scheduling Disk Defrags

Use Windows XP’s defrag.exe command-line utility to automate defrags with a batch file:

Step 1: Open Notepad. On the first line of the, type defrag.exe [drive letter]: -f. The script in this example will force a defragment of drive C. If you only wanted to analyse the disk, you could use the –a switch instead.

Step 2: Save the file as defrag.txt to the location of your choice. Once saved, browse to that directory and rename the file to defrag.bat. If you are not prompted with a message about changing the file extension, you will need to make extensions visible in Folder Options.

Step 3: Test the new script by double-clicking on it. A window will appear as shown above. If you don’t want to complete the defragmentation process at this time, press Ctrl +C to cancel the process.

Step 4: To schedule the script, click Start, All Programs, Accessories, System Tools, and click Scheduled Tasks. The Scheduled Tasks window will open. Double-click the Add Scheduled Task icon to launch the wizard.

Step 5: Click Next, and then click the Browse button. Browse to the location of defrag.bat, select it, and click OK. Select the interval at which defrags should occur, for example Monthly, and click Next. Select time and day settings, and click Next.

Step 6: Scheduled Tasks need to run as a user. Your username will probably already be populated, so enter your password and confirm it. Click Next. Click Finish. Then sit back, relax, and wait for your defrag to occur according to the schedule you set out.

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.

Formatting Drives and Choosing File Systems

Once a disk partition is defined, it needs to be formatted with a file system to be used. Depending on the operating system installed, your choices include FAT, FAT32, and NTFS. For all intents and purposes, stick to FAT 32 if you’re running Windows 98/ME, and NTFS if you’re running XP. The old FAT file system supports much smaller partition sizes, and space is used very inefficiently on the disk as larger partitions are defined. For XP systems, NTFS provides the added benefit of allowing you to set security permissions on individual files and folders. If you’re planning a dual-boot system, remember that Windows 9X/ME systems do not support NTFS – stick with FAT32 if that’s the route you’re planning to take.

When creating a new partition in Windows XP, you have the option of configuring what is known as the allocation unit size. While the operating system will use the default allocation size considered optimal based on the size of the partition, this setting can also be changed.

Generally speaking, a smaller allocation unit size is better is you’re typically saving small files to disk, and a larger (usually the default) size is better when you’re saving large files. The allocation unit chosen can impact available disk space considerably. For example, if a 32K cluster size is used, saving a 1K file to disk would make the other 31K in that cluster unavailable. With a 4K cluster size, that same file would only waste 3K. As a general rule, stick with the default size that Windows suggests, although you can attempt to tweak and tune this setting according to how the partition will be used.

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.