Helpful Hints & Companies to help your Customers

Monday, July 18, 2005

Defragmenting Your Drive

Posted: Mon, 18 Jul 2005 01:06:41 GMT

Defragmenting Your Drive

highlight box So what exactly is disk fragmentation, and what does Windows' Disk Defragmenter do about it? Here's a nice description from The Elder Geek: "As advanced as hard drives have become, one item they are not very good at is housekeeping, or maybe that should be drive keeping. When files are created, deleted, or modified it's almost a certainty they will become fragmented. Fragmented simply means the file is not stored in one place in its entirety, or what computer folks like to call a contiguous location. Different parts of the file are scattered across the hard disk in noncontiguous pieces. The more fragmented files there are on a drive, the more performance and reliability suffer as the drive heads have to search for all the pieces in different locations. The Disk Defragmenter Utility is designed to reorganize noncontiguous files into contiguous files and optimize their placement on the hard drive for increased reliability and performance."

highlight box If Defragmenter says that your drive is "only" 4% fragmented and doesn't need defragging, do it anyway. 4% of 1 gigabyte is more than you think, and those of us with bigger drives are that much more fragmented. Never let your drive get to 10% fragmentation if you can help it. Once a month is a good rule of thumb; heavy users may want to defrag twice a month. Expect Defrag to take a good while, especially if your drive is heavily fragmented. Take your much-neglected sweetie to dinner, and disable the screen saver before you go. If it seems to hang, leave it alone for a while -- it is probably working on a particularly fragmented section of hard drive and while it seems to have locked, it is actually busy. (One way to tell is to look at the disk-activity light on your computer. If there is hard disk activity, the light will be on, at least intermittently.) Premature shutdown of Defrag can zap your whole file structure. Hands off for at least an hour. Go to dinner, come back, and if it's still hung, then and only then shut it down.

highlight box Some alternative information from PC Magazine: The frequency with which you defrag your computer depends on the type of work you do. Programs that create multiple temporary files (for example, scanning software) require defragging more frequently. Also, if your disk drive is only 20 percent full, there isn't much need to defrag except at regular maintenance intervals. If it's 70 percent full, however, your system will likely benefit from it.

highlight box Ignore the quick defrag options and pick the slowest, most complete mode. Some users start Defrag as their last computer task before bed, letting the beastie wend its way through the disk during the night. It will be done by the morning.

highlight box Win 98/ME users, you have a better Defrag utility than the 16-bit one packed with Win 95. One setting is particularly useful. When you crank up Defrag, click the Settings button and make sure that the option labeled "Rearrange program files so my programs start faster" is selected. This moves the programs and documents that you use most often to the faster parts of your hard drive.

highlight box Win XP users have a "boot defrag" option that places boot files next to each other on the hard drive, thus speeding up startup. Boot defrag should be enabled by default, but to make sure, drill down to the Registry key HKEY_LOCAL_MACHINE \ SOTWARE \ Microsoft \ Dfrg \ BootOptimizeFunction and look in the Name column on the right side of the window. Check that the Data value for Enable is set to Y. If it is, close Regedit. If not, right-click on Enable and choose Modify. Change the value to Y, choose OK, and close Regedit.

highlight box Win XP Pro is a bit inconsistent in its automation of Defrag. It will open the app but apparently won't let you automatically start the process. Since Defrag is quite schedulable, what's the problem? The problem is that Task Scheduler has no connections to Defrag, so you can't use it to schedule automatic defragging. Defrag can run fine with no graphical front end at all and that's the key to using it in an automated fashion. To use Defrag (and other, similar system tools) this way, you launch the tool via a command line plus any "switches" you want to use to modify the file's behavior. Ppen an empty XP "command window" by clicking Start, Run, and typing the word COMMAND in the Run line. Click OK. A command window, usually a mostly black box, will open. In Notepad, enter one line of plain text: DEFRAG C: Now, click to Notepad's File/Save As menu. Navigate to your Desktop in the "Save In" portion of the dialog. In the "Save As Type" scroll box, scroll down to the "All Files" type (instead of the default "Text Documents"). Finally, in the "File Name" area, name your new file DEFRAG C.BAT (or any similar, obvious name ending in ".BAT"). Then, click Save. The file should be added to your desktop with a .BAT extension (instead of a .TXT extension). For example, if you have other drives or partitions, you can either defrag them via separate batch files (a "DEFRAG D.BAT" file could contain just the line DEFRAG D: for example), or you can enter the lines serially into one batch file. You can make a batch file called "DEFRAG_ALL.BAT" for example, containing these lines:

When run, "DEFRAG_ALL.BAT" defrags C, then D, and so on, one after the other until the last command is processed. You can trigger a batch file either by manually clicking on the file, or you can use Task Scheduler to run the batch file whenever you want. Done this way, whatever commands you place in the batch file will run at the designated time, one after the other. Click into your Control Panel, go into the Performance and Maintenance app, and then click on "Scheduled Tasks." Once the Task Scheduler opens, click on "Add Scheduled Task" and a wizard will open to guide you through the process. Click Next. When asked to "Click The Program You Want Windows To Run..." select the Browse button, and navigate to the batch file you just created in the previous step. Once you've selected the batch file, a new dialog will open, asking for a name and rough schedule for the new task you're creating. Enter the name you want, and then select an appropriate rough schedule. For example, if you want your system to defrag every day, select "Daily." Click Next. In the next dialog, you can refine the schedule a bit: pick a start time, a start date, and a frequency. For example, if you want Defrag to run every night in the middle of the night, you'd pick a suitable "Start Time" (say, 3 am), select the "Every Day" option, and then set the start date to be the very next night. Click Next. Depending on how your system is set up, you may then be presented with a dialog asking for your password; this will allow the automated task to get past any logins that may be required to run the scheduled task. Just enter your normal password, as indicated, and click OK. Most system-maintenance tasks run best from an account with Administrator permissions. The Wizard will then tell you that your basic scheduling is done, but also will offer an "Advanced Properties" check-box option. Select this option, and click Finish. When the Advanced Properties opens, click the Settings tab. If this is the only automated task you'll have running, many of the options on the Settings dialog may not matter. But if there's any chance of another task running at or near the same time as the new task you're creating, set the "Idle Time" options accordingly. You'll get better results from setting the task to start "only if the computer has been idle" for at least 10 minutes; and to "retry the task" for four hours, or 240 minutes. Although Task Scheduler isn't great about preventing tasks from competing with each other, these settings will help to prevent such contention. Note the "Power Management" options on the same dialog. For laptops, the "Don't Start if the computer is on batteries" and "Stop task if battery mode begins" may be useful to prevent your system from running itself down when you're not connected to a wall socket. But all systems -- laptops and standard PCs -- can benefit from the "Wake the computer to run this task." This setting will bring your PC out of sleep or standby mode, if necessary, to run the scheduled task. Close out the open dialogs, and click Next. At the end of the day, let your PC's power-control system put the PC into sleep or standby mode (not fully off). At the appropriate time, the PC will wake up, and run the scheduled task to completion.

highlight box Sometimes Defrag hangs, continuing to restart without ever reaching completion. There are numerous reasons why Defrag does this. First, make sure you give it plenty of time to get its job done. It's not unusual for Defrag to seemingly hang around the 10% mark; what it's really doing is figuring out how to reorganize your files and data clusters. If it really does hang, it'll present you with a message something like, "Defrag has been forced to restart 10 times or more...." and give you the option to restart again or cancel. If this happens, run ScanDisk in Throrough mode to ensure that the disk is problem-free (you may need to close Windows and run it from the DOS prompt if ScanDisk, too, hangs -- restart your PC in DOS mode and enter SCANDISK at the C: prompt. Make sure no other programs are running while Defrag is doing its thing -- press Ctrl-Alt-Del to bring up the Task Manager, and click "End Task" for all unnecessary programs (i.e. everything except Explorer and Systray). Disable your screen saver. Finally, clear some of the deadwood from your hard drive; Defrag can work more efficiently without a drive full of clutter and crap. If none of this works, Defrag isn't up to the job of handling your rubbish heap of a hard drive. Try one of the major utilities programs instead, or call for help.

highlight box Run ScanDisk (see above) before running Defrag, to check your file system for errors which could turn perfectly good material into "lost clusters."

highlight box Defrag modifies the drive a good bit, so I would back it up before defragging.

highlight box Windows Help gives a "tip" which could crash your drive. It tells you that you can safely use your computer while it is defragging. Don't do it.

highlight box Knuckleheads: Go to Start/Programs/Accessories/System Tools to find Defrag.

highlight box As noted above, the Win 95 version of Defrag, like its cohort ScanDisk, is an old, rather obsolete 16-bit program. It does what it does quite well, but it really isn't up to handling everything that Windows can throw at it. Another option is to use a commercial product such as Norton Utilities (its Speed Disk defragmenter is highly recommended) or McAfee's (formerly Helix's) Nuts&Bolts (also good, just slower and not up-to-date). Both are 32-bit programs that are safer, more reliable, and more thorough than their freebie counterparts, and less prone to crash. (A crashed defragger is no laughing matter.) (Note: Norton Utilities 2.0 is buggy. Try version 2.03 or later. Version 3.0 is out, and bug-ridden as well; in fact, a Live Update download upgrades it to version 3.05. Check Symantec's Knowledge Base at for articles and patches. Problems with 3.0 include freezing AOL's browser upon exiting, conflicting with Norton's AntiVirus program and causing your A: drive to freeze, conflicting with Diamond's Stealth 3D graphics board drivers, and worst of all, scrambling Windows' Registry, rendering Windows unable to load. Patches are available that address all these bugs except the AOL browser freeze; Symantec is working on that one.) Win 98/ME users, your more modern defrag utility is just fine; see above.

highlight box If you constantly have problems with ScanDisk not completing its run, try rebooting Windows in Safe mode and running ScanDisk from there (restart Windows, then press F8 when you see the words "Starting Windows 95" appear; with Win 98/ME, restart Windows and immediately press and hold the Ctrl key until the Startup menu appears). Chances are good that whatever program is interfering with ScanDisk won't load under Safe mode. Note: switching into Safe Mode from XP is a bit different: XP users need to enter MSCONFIG in the Start menu's Run dialog, then click on the BOOT.INI tab and check the /SAFEBOOT box. Reboot to enter Safe mode. Repeat the process and uncheck the box when you're through with Safe Mode. One caveat: Don't experiment with the other settings on this tab. You could wind up unable to get back into MSConfig to undo your changes.

highlight box Want to automate Disk Defragmenter like you can ScanDisk? Easily done. Right-click the Start button and choose Open or Explore. Locate the Defrag Shortcut, which is in your Start Menu / Programs / Accessories / System Tools folder. (To make a shortcut for your desktop, right-click the Defrag icon, drag it to the desktop, and choose either "Copy Here" or "Create Shortcut(s) Here.") Press Alt+Enter to open the Properties screen, click the Shortcut tab, then click at the end of the command line in the Target box. Then add the appropriate command switches (separated by spaces) to make Defrag perform as you like. Switches are as follows: For scanning a particular drive, type its letter followed by a colon (A:, C:,. etc.). For scanning all (non-networked) drives, don't type any drive letters, just type /ALL. To have Defrag only defragment files without consolidating free space on your hard drive, type /U. To consolidate free space without file degragmentation, type /Q. To do both, type /F. (You can't use more than one of these three switches at a time.) For Defrag to start and stop without your input, type /NOPROMPT. To have Defrag display the disk map that symbolizes the defragging process, type /DETAILED. Otherwise you'll get the small Defrag window. (Like the small window? Use the /CONCISE switch.) Your command line might look something like this: C:\WINDOWS\DEFRAG.EXE /ALL /F /NOPROMPT , to make Defrag defrag and consolidate free space on all local hard drives, and automatically exit when finished.

highlight box In Windows 98 and Windows Me, the Task Monitor tracks which programs are launched and how they load from disk, and it records the info in the Applog folder. The Defrag utility then uses this info to provide special optimization for the program files you use most often. Rather than rearranging the clusters of these files in sequential order, Defrag rearranges them in the order they're loaded when the program launches. This specialized processing reduces the time required to launch certain programs, but you may prefer to trade that speed for disk space. You're perfectly free to delete the entire contents of this folder, but Task Monitor will start refilling the folder right away. To prevent this, you need to tweak a Registry setting. Launch Regedit from the Start menu's Run dialog and navigate to HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Applets \ Defrag \ AppStartParams . In the right-hand pane, find or create a DWORD value named UseProfile, and set its value to 0. For more information, see the Microsoft TechNet article at

highlight box If you've reused a floppy disk numerous times, it probably wouldn't hurt to run it through Defrag.

highlight box Defrag isn't the be-all end-all of repair and "anti-crash" utilities. Several commercial programs are available to prevent crashes, or to rescue your system from a crash. Like anything else, they vary in usefulness. Norton Utilities' CrashGuard didn't fare well in one test run (the testers claimed it caused as many crashes as it saved) but did well in another; neither did Nuts&Bolts' BombShelter, though both outperformed RealHelp in another 'zine's test run. Quarterdeck's RealHelp Extra Strength utility managed to keep the test GPF at bay long enough for the testers to rescue their data, but still did not allow a normal shutdown. First Aid 98, which is one 'zine's Best Buy, also helped to an extent, but did not entirely circumvent a crash (First Aid's proprietory Windows Guardian did score very highly on another magazine's crash test). The old Crash Defender 1.0 was not very effective, but Version 2.0, still in beta as I write this, seems to be better. VT Rescue 95 did little but take up disk space. The new Safe & Sound utility pack, although chock full of goodies like McAfee antivirus software and the PC Retake backup program, is buggy and could do more damage than the problems it purports to repair. Upshot: None of the "anti-crash" programs currently available do the job as advertised. The best bet might be to go with Win 98/ME and let its included crash avoidance software do its job. Note that the information in this paragraph is a bit outdated, and some of the above utilities may no longer be available.

highlight box Give yourself a little light entertainment by having Disk Defrag "Show Details" while it's doing its thing. It will show you a graphical representation of how it's rearranging and repositioning data bits. Cool.

highlight box Microsoft has released a new KB article for Defrag XP users: Description of the New Command Line Defrag.exe Included with Windows XP at;EN-US;Q283080. This article outlines and explains all of the command line parameters for the DEFRAG.EXE utility included with Microsoft Windows XP. Keep in mind that you need to have at least fifteen percent free space on your hard drive for Defrag to run properly, otherwise it will only partially defragment your hard drive.


Post a Comment

<< Home