X
Business

Bypass Windows 98's never-ending defrag operation

Greg Shultz shares on how to get around a stalled defrag operation in Win98.
Written by Greg Shultz, Contributor

This article originally appeared in TechProGuild.

If you're supporting the Windows 98 operating system, chances are that you've encountered the mind-numbing problem in which Disk Defragmenter is unable to complete a defrag operation. In this situation, Disk Defragmenter works normally until it gets to about the 10 percent complete marker. Then, it stops and displays a message like the one shown in Figure A.

Figure A: Disk Defragmenter never gets past the 10 percent complete marker before it starts all over again.

When this happens, the logical thing to do is to stop Disk Defragmenter and make sure all open applications are shut down, even those that run in the background, and then rerun Disk Defragmenter. However, once Disk Defragmenter hits the 10 percent complete marker, it again displays the same message and starts all over at the beginning of the hard disk. At this point, you may even restart the system in Safe Mode and try running Disk Defragmenter from there. Again, Disk Defragmenter starts over when it hits the 10 percent complete marker. This scenario plays over and over no matter what you do.

Fortunately, I've discovered an interesting technique that takes advantage of a hidden tool buried on the Windows 98 CD. This technique will bypass all these drive contents change interruptions and allow Disk Defragmenter to perform a full defragmentation operation on a Windows 98 system that is experiencing the never-ending defrag operation. In this article, I'll examine the cause of this problem in more detail, as well as introduce you to my full defrag technique and explain how it works.

A theory for the never-ending defrag operation
While many of my IT colleagues have offered all sorts of theories on what causes Disk Defragmenter to choke at the 10 percent complete marker--everything from a Microsoft plot to drive users nuts to the tidal effects of the moon--I’ve never been able to find a definite answer. And, yes, I even investigated the Microsoft Knowledge Base, which roots the problem in active applications accessing the hard disk and suggests shutting down all running programs. However, I’ve experienced this problem firsthand many times and found that none of the obvious explanations seems to offer a solution to the problem of the never-ending defrag operation.

Over the years, I developed my own theory and solution, which after time-tested examination, seems to be as good an explanation as I’ve encountered. In order to get a handle on what is causing Windows 98’s Disk Defragmenter to choke at the 10 percent marker, I began to investigate how this utility goes about doing its job.

There are basically three stages that Disk Defragmenter goes through when defragmenting your disk. Each of these stages can be demarcated at the percent complete values that Disk Defragmenter displays in its status bar. During the 0 and 4 percent complete values, Disk Defragmenter is actually running a special version of ScanDisk for Windows in order to check the disk for errors before doing anything with the files. If an error is found, Disk Defragmenter halts operation and prompts you to run the ScanDisk for Windows. If no problems are found on the hard disk, Disk Defragmenter enters the next stage. During the 5 to 9 percent complete values, Disk Defragmenter is essentially plotting out a road map of the best locations on the hard disk to use when it actually begins moving the files.

Once these preliminaries are complete, Disk Defragmenter begins moving the files and placing them in contiguous order on the disk. This stage begins at the 10 percent complete value and continues on to the 100 percent complete value. When Disk Defragmenter has a problem at or around the 10 percent complete value (which causes the utility to stop, display the error message, and start all over), it’s apparent that Disk Defragmenter is encountering a problem when it begins moving chunks of data that it finds somewhere towards the beginning of the hard disk.


A quick restart
When Disk Defragmenter encounters a problem that causes it to restart, you’ll notice that it very quickly moves past 0 to 4 percent complete values and picks up where it left off. This is because the ScanDisk activity occurs only when Disk Defragmenter is started and is not repeated if Disk Defragmenter is forced to restart because of disk activity.


In almost all cases, the chunks of data at the beginning of the hard disk are unmovable areas belonging to the swap file associated with Windows 98’s Virtual Memory management scheme. My research and the success of my solution leads me to believe that the cause of the “Drive contents changed: restarting…” message is a combination of Disk Defragmenter itself and Windows 98’s Dynamic Virtual Memory management scheme.

When Disk Defragmenter encounters the swap file, it will bump into a very large chunk of the hard disk marked as unmovable and will have to begin moving large chunks of data all around it in order to place files that fall before and after the swap file in contiguous order. As this occurs, Disk Defragmenter seems to depend on the swap file to assist the utility in the data move operation. If the swap file itself is heavily fragmented, then Windows 98, with its Dynamic Virtual Memory management scheme, must make adjustments to the size of the swap file. When this occurs, there is obviously hard disk activity that causes the drive contents to change and thus causes Disk Defragmenter to start all over.


Configuring Disk Defragmenter to automatically disable screen saver
If you want to ensure that the screen saver does not launch while you are defragmenting your hard disk, you can configure Disk Defragmenter to automatically disable the screen saver when it is running by adding a little setting to the registry. To begin, you’ll launch the Registry Editor by typing Regedit.exe in the Run dialog box. Once the Registry Editor is up and running, navigate through the following subkeys:

  • HKEY_CURRENT_USER
  • Software
  • Microsoft
  • Windows
  • CurrentVersion
  • Applets
Now, right-click the Applets key and select New | Key. Name the new key Defrag. Next, right-click the newly created Defrag key and select New | String and name it Settings. At this point, double-click the Default value inside the Settings key and change the value to YES. To complete the operation, close the Registry Editor and restart Windows 98. Once Windows 98 restarts, you will be able to run Disk Defragmenter without worrying about interference caused by the screen saver.

The solution: An overview
Working with this theory in mind, I discovered this solution to the problem of the never-ending defrag operation. To begin, disable virtual memory completely. Then use the hidden tool to configure Windows 98 to automatically run Disk Defragmenter on startup, but before the operating system is completely initialized. Once Disk Defragmenter completely defragments the hard disk, all the empty space is at the end of the disk. You then reenable virtual memory, which forces Windows to put the swap file at the very end of the hard disk. Here are directions on all of these steps.

Disabling virtual memory
Disabling virtual memory is a relatively simple operation. To begin, open Control Panel and double-click on the System icon. Then, select the Performance tab and click the Virtual Memory button near the bottom of the tab. At this point, you’ll see the Virtual Memory dialog box shown in Figure B.

Figure B: The Virtual Memory dialog box allows you to alter the swap file.

Next, select the Let Me Specify My Own Virtual Memory Settings option. When you do, you’ll see that the settings below it become active, as shown in Figure C.

Figure C: When you select the Let Me Specify My Own Virtual Memory Settings option, the settings are enabled.

Now, select the Disable Virtual Memory check box. To complete the operation, click OK to close the Virtual Memory dialog box. As soon as you do, you’ll see the Confirm Virtual Memory Settings dialog box, as shown in Figure D.

Figure D: You’ll be prompted to confirm the change you made to the virtual memory settings.

You’ll notice that this confirmation dialog box carries a stern warning about completely disabling virtual memory. In addition to the warning that computer performance may decrease significantly, the message also warns that you may be unable to restart your computer.

As far as the performance warning is concerned, yes, your system will not be performing optimally. However, since for this technique it's only a temporary change, that isn’t a big concern. As to the warning about not being able to restart your computer, I can tell you that I’ve never encountered this situation. However, that’s not to say that it won’t happen. Just in case, you should be prepared to work through this scenario. Having a Windows 98 Startup Disk on hand should be all you need to get the system back up and running.

Once you click Yes to confirm that you do indeed want to continue, you’ll return to the System Properties dialog box. To continue, click Close. You’ll then be prompted to restart your computer. However, you need to click No.

Installing the hidden tool
In order to install the hidden tool, you’ll need to have on hand a Windows 98 CD. Once you insert the CD in the drive, you’ll see the Windows 98 CD-ROM menu. Select the Browse This CD option. When you see Windows Explorer, drill down to the Tools\Mtsutil folder. At this point, locate and right-click the Defrag.inf file. Then, select the Install command from the shortcut menu. When you do, you won’t notice anything happening. However, in the background, the install operation adds the special command, Defrag/All, to the RunServicesOnce key in the Registry.


It’s a one-time deal
Keep in mind that, as the name implies, the change to the registry implemented by the Defrag.inf tool will only be effective once. It will be automatically removed after the command is launched.


To continue, close Windows Explorer, the Windows 98 CD-ROM menu, and any other open windows. Then, restart Windows 98. When you do, Windows 98 will begin to start normally, but then before the operating system is completely initialized, Disk Defragmenter will launch before anything else loads from the registry, the StartUp folder, or the Win.ini file. It will then be able to complete the defragmentation operation uninterrupted. Once Disk Defragmenter completes its job, close it down and let the system start normally. You’ll then need to reenable virtual memory.

Reenabling virtual memory
To reenable virtual memory, return to the Virtual Memory dialog box, as described earlier. Then, select the Let Me Specify My Own Virtual Memory Settings option and click OK. When you do, you’ll see the Confirm Virtual Memory Settings dialog box and will want to click Yes. To complete the operation, close the System Properties dialog box, and click Yes when you’re prompted to restart your system.


Copy the shortcut
If you’d like to be able to defragment your hard drive regularly using this technique, you can copy the Defrag.inf file to a folder on your hard drive. That way you can access it quickly and easily the next time you want to perform a defragmentation operation.


Editorial standards