Defragmenting Your Hard Drive - February 2002

by Dale Atchison


[ Home Page ]         [ Back to Archive Page ]



First, a word of warning.  I'll try anything once, and I'm never afraid to make changes to my computer, or yours.  If you don't feel confident trying any of the tips found in this article, don't try them.  It won't hurt my feelings.  Take your computer to the Resource Center during one of their Wednesday or Friday clinics, and they'll make the changes for you.  Or, you can keep defragging the way you always have - it won't be the utterly thorough process spelled out here, but any attempt at disk maintenance is better than no attempt at all.

And I should point out that I wrote this article in 2002, when there were a lot more Win 95, '98, and ME computers out there than there are now.  Almost none of the tips and steps in this article apply to Windows XP, except that you should disable Virtual Memory and run Defrag in Safe Mode - but even those things are accomplished by a different sequence of steps than they were in previous versions of Windows.


Today's lesson:

Most of us know our computers run faster if we Defrag (defragment) them regularly.  As files are created, expanded, shrunk, or removed, they tend to spread over the surface of the hard drive - a piece here, a piece there, and lots of empty space between files.  The fragmented files will become even more fragmented as soon as a file arrives that is too large to fit into one of the empty spaces.  Running Microsoft Defrag does a credible job of rearranging all the file fragments so that most files are contiguous (not in pieces), and all stored at the head of the drive.

However, Microsoft did not address some important issues when it licensed the Defrag software for DOS 6, then re-wrote it for Windows 95.  One problem is that files with the System attribute set are not moved.  If they get written to the drive in a fragmented state, they stay fragmented forever.  Further, if during the Defrag process, a file is too big to fit between the last-placed file and the first piece of a file is marked as a System file, the file being moved gets split to accommodate the System file.  Either way, immediately after performing a Defrag operation, you already have files that may not actually have de-fragmented.

Another issue is programs that periodically write to the hard drive or swap data to and from the hard drive in a scheme called virtual memory as they achieve what Microsoft calls their "time slice".  And, when a screen saver program is running, the Defrag process is interrupted each time the screen saver hides or restores the screen.

To get the best Defrag operation imaginable - the absolute fastest file access times your PC is capable of, you must run Defrag in Safe Mode.  Safe Mode marks the bare minimum of files as System files, so more files can be safely moved.  It also runs almost no background programs, which could cause disk writes that would interrupt the Defrag operation.

The following procedure, which I try to perform once a month, is the process that I use.  I do not use Microsoft Task Scheduler to do it since I always turn it off to minimize the number of useless programs running in the background.
  1. (Optional) Disable Virtual Memory to eliminate the huge clump of file space normally occupied by the Windows Swap File and marked as a System file.  To do this:
    • Right-click My Computer, then select Properties.
    • Select the Performance tab, then Virtual Memory.
    • Click in the button that says "Let me specify my own virtual memory settings", then the box that says Disable Virtual Memory (Not - Recommended).  (They are right.  It is not a smart way to run a computer, but it is the best way to fully defragment the disk, and we'll change it back once the process is complete.
    • A box pops up, asking you to confirm the virtual memory settings and recommending against the changes.  Click Yes anyway.
    • When asked to reboot in order to implement the new settings, if you can easily choose Safe Mode in the reboot process (see Step 2, below), select Yes.  Otherwise, select No and use the Safe Mode shortcut described at the end of this article.
  2. Boot in Safe Mode (see Appendix).  There will be a warning screen telling you that you are in Safe Mode (like you couldn't tell from the hideous video!).  Click OK to make the warning blurb go away.
  3. Check your Display Settings (right-click on the desktop, then select Properties) to be sure you're not running a screen saver.  If you are, turn it off by choosing None from the list.
  4. If running Windows 98, run the Disk Cleanup Wizard to delete all unnecessary files:  Start » Programs » Accessories » System Tools » Cleanup Disk.  Be sure to include the Recycle Bin unless you've just added files to it today.
    • If running Windows 95, find all files with the tmp extension and delete them:  Start » Find » Files or Folders » *.TMP » Find Now.  Once Windows stops scanning, click any one of the files found, then press Ctrl-A on the keyboard to highlight all files found, followed by Shift-Del to delete them all, bypassing the Recycle Bin.
    • Empty the following folders:
      • C:\Windows\Temp
      • C:\Windows\Temporary Internet Files
      • C:\Temp (if you have one)
      • Recycle Bin
  5. Run Scandisk with the Thorough option selected to be sure the disk is reliable enough to trust moving your files to new locations:  Start » Programs » Accessories » System Tools » ScanDisk.  This will take a while, but it's necessary if you don't want to lose data.  Besides, this is one reason we do this only once a month.
  6. Run Defrag from the Run dialog box (Start » Run), typing in this command line:
    DEFRAG C: /F /S /H /ALL /DETAILS /NOPROMPT
    • /F causes a Full Defrag, filling spaces and de-fragmenting files.
    • /S allows System files to get moved as needed.
    • /H tells the program it's okay to move files marked as Hidden.
    • /ALL causes All local hard drives to be processed.
    • /DETAILS makes all the pretty little boxes appear on the screen as the defragmentation progresses.  (Guess you could leave off /DETAILS, but then you'd miss out on the best part of owning a Win9x computer.)
    • /NOPROMPT tells Defrag not to stop and ask if it needs to restart, and to exit to the Windows desktop when degragmenting is complete.
  7. When the process is complete:
    • If you turned off Virtual Memory earlier, go back to the Virtual Memory settings and click on the "Let Windows manage my virtual memory settings. [Recommended]" button.
    • If you turned off a screen saver, you could go to Display Settings and turn it back on.  I recommend you leave the Screen Saver turned off, and use the Power Options applet in Control Panel to set the delay before Windows blanks the screen.
  8. Reboot into Normal Mode by clicking Start » Shut Down » Restart » OK.




Appendix:  Booting Into Safe Mode

There are several ways to boot into Safe Mode:
  • On most computers, when the Starting Windows 95 message is displayed, pressing the F8 key will bring up a boot menu.  Select Safe Mode (usually choice #3), and press <Enter>.
  • On some Windows 98 computers (besides the obvious change to the startup message), the boot menu key changes from F8 to the <Ctrl> (Control) key, although some Windows 98 PCs still use F8.  All you can do is experiment to see which key brings up a menu.
  • If using a Compaq, HP, or IBM computer (and maybe others), you probably don't see the startup message because it is obscured by the manufacturer's logo.  When you first see the logo, press and hold the <Esc> (Escape) key for a few seconds.  This may clear the logo and allow you to see the DOS Mode startup messages as your computer boots.
If all else fails, or if you just want the convenience of having an icon in Normal Mode that allows you to boot into Safe Mode, follow these instructions carefully:
  1. Right-click this rough SafeMode icon, and save it in your Windows folder - name it safemode.ico.
  2. In Normal Mode, open Notepad:  Start » Programs » Accessories » Notepad.
  3. Type these lines exactly as shown:
    @echo off
    cd\
    win /d:m
    exit
  4. Save the file as C:\SafeMode.Bat.  Remember to change the Save as Type in the Save As box to All Files or you'll end up with safemode.bat.txt.
  5. Right-click on the desktop, and select New » Shortcut.
  6. For the command line, type c:\safemode.bat.  Title the shortcut REBOOT IN SAFE MODE.  Click Finish to save the new shortcut.
  7. Right-click the new shortcut, and select Properties » Programs » Advanced.
  8. Select "MS-DOS Mode", and deselect "Warn before entering MS-DOS mode".
  9. Click OK to exit the Advanced options screen, and click Change Icon » Browse, navigate to your Windows folder, and select safemode.ico.
  10. Click OK to save the icon and return to the Programs screen, then click OK again to save all changes.
Now, when you want to boot in Safe Mode, just double-click the shortcut, or single-click it if you've set up your computer to open files with a single-click. One last Note:  Some computers built by the 'large-box' vendors (HP, Gateway, etc.) use a convoluted scheme to access MSDOS mode; the shortcut method won't work on them.  You'll know it won't work when you try clicking on the SafeMode shortcut, and Windows stops in DOS and asks you if you'd like to "restart Windows to run this program?"  If you get this message, type N and press <Enter>, and you'll wind up back in Windows - in Normal Mode, not in Safe Mode.  Delete the Safe Mode shortcut, and delete C:\SafeMode.bat - they're not going to work for you.  You'll need to use the Start Menu method described at the beginning of this appendix instead.


[ Home Page ]         [ Back to Archive Page ]

Please email any questions to  DaLe@ComputerRepairShop.biz



I send these guys a few dollars every month... sure wish you would join me.
And 100% of your labor charges go to this rescue, too.