From the HALNet Support Desk, by "Bob the modem guy"

Behind the Scenes with Disk Defragmenter

Have you ever wondered what happens with Disk Defragmenter with its reorganizing of files? We will try to reveal some of what takes place, "behind the scenes."

NOTE!!! This article is written primarily for Windows 98 and ME in mind, but may apply to other versions as well. It is also written for those that are knowledgeable with Windows. If you have trouble understanding who article, you might want to get a friend or your "computer guru" to help you.

Disclaimer: You should have a current backup of your computer's data. With the changing of system settings, if it's done wrong, or if a computer "glitch" (or power outage) happens at the wrong moment, it could lead to lost data or system problems. Make any changes to your system at your own risk. Therefore, make sure you have backups of your data and programs in the event something goes wrong.

Most people know about Scandisk and Disk Defragmenter. Scandisk will scan your disk for hard drive allocation (hard drive file management) errors in the Boot Sector, File Allocation Table (FAT) and Root Directory. Scandisk "thorough" can also be used to scan the entire drive for read errors in the data area of the drive. It looks for errors in the assigning of files, and can also scan over the entire drive for "bad spots" on the hard drive's disk platters and writes this to the FAT to tell the operating system not to use those areas of the drive. The "Standard" scan should be done every week or two; the "Thorough" should be done once or twice a year.

Disk Defragmenter is a disk maintenance program that reorganizes your hard drive by putting different parts of a file that may be scattered all over the disk into one spot. Under many conditions the files on your hard drive will become fragmented and broken up into several parts. This is normal as one uses the computer adding, changing, and deleting files and as the operating system creates then deletes temporary files. The Disk Defragmenter "defragments" and places all the pieces of a specific file together into one "contiguous" file.

Go to Start, Programs, Accessories, System Tools, Disk Defragmenter. Choose the C: Drive. If you have more than one drive, you can click the down arrow on the right side and pick "All Hard drives" to defragment all of your drives. Run Disk Defragmenter even if it says that 0% is fragmented. Disk Defragmenter will move files as it sees fit and newer versions of Disk Defragmenter will actually move your most-used files to the front of the hard drive for faster access and loading. How this is done "behind the scene" is what this article is about and will be discussed shortly.

Disk Defragmenter should be run at least once every 2 weeks. If you have not run Disk Defragmenter for several months, or have never run it, it may take an hour or even several hours to run. Note: It is advised that you run scandisk prior to running Disk Defragmenter to clear the drive of any errors.

Beginning with Windows 98, Disk Defragmenter had a program added to help it called Task Monitor (taskmon.exe). Task Monitor works with Defrag to help reduce the time it takes for frequently used programs to start. When you open a program the first time, Task Monitor will closely watch and log the files needed to fully open the program you requested. It will log this information in a subdirectory called APPLOG, located in C:\WINDOWS\. Within this subdirectory are several log files used by Defrag. Defrag looks at these logs to see what is used the most and tries to place them on the disk for faster access.

Some of the files in the Applog folder are: Applog.dt? (where ? is the drive letter), Applog.ind, and optlog.txt. The Applog files are like indexes, and Applog.dt? contains cluster placement information for defrag and the optlog.txt is a text version file of those indexes. These files are "logs" of the names and subfiles needed to start the program that you requested. As you run your computer, Task Monitor watches the programs (applications) you open and close and these files are updated at the time of shutdown.

When you run Disk Defragmenter it asks for a file called Cvtaplog.exe to get the information that has been stored in the C:\WINDOWS\APPLOG subdirectory so it will know how to sort the files on the hard drive as it defragments. It has been said that defrag may even fragment a file, so when an application is started, it loads the files IN ORDER as the application needs them during its startup. This means one file may be loading, but an overlay or required DLL file may be needed to "fill in" extra information, then it will go back to the original file continuing the program loading.

Also, have you ever noticed on a PC that when you start defrag all of a sudden the "A:" drive light comes on and the drive chatters for a few seconds? Why would that be? Why is it looking at the "A:" Drive anyway? Well here is what's causing it.

If you look in C:\WINDOWS\APPLOG you will see a list of files. You will see some of the files mentioned above such as applog.ind or optlog.txt. Look closely at the extensions. Do you see the files (probably many of them) that have the extension .LGC??? Are any .LGA??? They will probably be in lower case but it doesn't matter (they are put in upper case here to make it easy to read). These log files are the applications you ran with information of what files are needed to start them. The extension .lgc refers to an application that was run on the "C:" Drive. A file with the extension .lga would be an application or even a file like a document or spreadsheet that you opened on the "A:" Drive. When you opened a file from the "A:" Drive, Task Monitor recorded the application that had to open the file on another drive, the "A:" Drive in this case, and logged it. If you happen to see .lgd, you probably have a "D:" Drive that you used to open an application or file from. As can be seen, the last letter of the ".lg?" files points to the drive letter. If you want to stop the "A:" Drive from chattering when you start defrag, just delete the file(s) that has the .lga extension. For example, if it had notepad.lga in the list, delete it and place it in the recycling bin. Now reopen defrag and if there are no more .lga files left, it should not chatter the "A:" drive.

Have you ever run defrag and afterwards thought the computer actually ran slower?? This typically does not happen too often, but could happen if the defrag had moved very large, rarely used files, to the front of the drive. Look in the APPLOG folder, and you will see familiar names of many of the programs you have. If you see an xyz.lgc file (xyz being any file name) that you really don't want to have moved to the front of the disk, for faster access simply delete the file and place it in the recycling bin.

For example if you see in the APPLOG folder, calc.lgc and notepad.lgc, yet you only ran Calculator and Notepad one time in the last few months, it might be good to delete calc.lgc and notepad.lgc so defrag will not waste time processing and moving them to the front of the drive. This will allow more frequently used programs to be place closer to the front of the drive for faster access for them. The optlog.txt file does have the frequency of program use in it, but why waste time reorganizing for a file you really don't care about?

Be careful to not accidentally delete the indexing files mentioned previously (Applog.dtc, Applog.ind, and optlog.txt). If you do, you may get a Defrag error. If you did, restore them from the recycling bin. If you really messed up and can't get the files back you accidentally deleted, or you now get an error message ID No:DEFRAG00205, you still have one way out to normalcy. Go and delete ALL the files in the C:\WINDOWS\APPLOG subdirectory and then reboot. The indexing files will be recreated when you run the programs as you normally do.

For more information on Disk Defragmenter, see the links below:

- "Bob the modem guy" HALNet support team