Inside Windows 98

Previous chapterNext chapterContents


- 15 -

Managing Disks and the File System


Owning and using a computer is in many ways something like owning and using a car. Cars have to be serviced regularly to keep functioning in tip-top shape. A computer is no different, although the type of care required is different and it's easy to forget that care is even needed sometimes. Also, like a car, a PC can be adjusted to run faster and more efficiently. This chapter describes the procedures and utilities in Windows 98 that help you do just that:

The chapter covers the following topics:

Analyzing and Repairing Disks with ScanDisk

MS-DOS 6.x includes a utility called ScanDisk that you can use to scan a disk for defects and repair many of those defects. Windows 98 includes a new version called ScanDisk for Windows that runs as a Windows 98 application. Windows 98 also includes a command-line version of ScanDisk, which is typically run when Windows 98 is being executed in command-line mode only. The command-line version of ScanDisk also appears on the reboot after Windows 98 has been improperly shut down. The Windows 98 version of ScanDisk has support for FAT32 volumes, where the Windows 95 version doesn't.

Using the Windows 98 versions of ScanDisk rather than any previous version you might have on your system is extremely important. Not only does the Windows 98 version of ScanDisk ensure the security of long filenames, but ScanDisk for Windows offers the capability to scan and repair disks as a background task while you work with other applications. Using a previous version of ScanDisk will destroy your system's long filenames if you allow it to repair any disk errors it finds.

ScanDisk can detect and repair a number of types of problems with your computer's file system, including the following:


TIP: ScanDisk performs the functions of the DOS CHKDSK utility, eliminating the need to use CHKDSK. If you run CHKDSK, it will execute and produce a report about your drive, will not fix any error, but will print an advisory note on program termination that ScanDisk does a better job of detecting and fixing a wider range of disk problems.

The graphical user interface (GUI) version, ScanDisk for Windows, is contained in the file SCANDSKW.EXE. The DOS version is contained in the file SCANDISK.EXE. If you open a DOS session in Windows 98 and enter SCANDISK.EXE at the command prompt, Windows 98 starts the GUI version, SCANDSKW.EXE, instead. The two are functionally equivalent, but they support different command-line switches that modify the way ScanDisk runs. These command-line switches are explained later in this chapter, in the section "Using ScanDisk Switches."

Running ScanDisk

All Windows 98 disk utilities are located in the Start/Programs/Accessories/ System Tools menu. To start the GUI version of ScanDisk, click on the Start button; then choose Programs | Accessories | System Tools | ScanDisk. The ScanDisk dialog box appears, as shown in Figure 15.1.

FIGURE 15.1 The ScanDisk dialog box.


TIP: You also can start ScanDisk for a specific disk by opening the disk's property sheet and selecting the Tools page. The Tools page indicates the number of days since you last ran ScanDisk to analyze the disk.

ScanDisk offers two modes for disk detection and repair--Standard and Thorough. The Standard option causes ScanDisk to check the file system structure, including the FAT, directory entries, long filenames, and other file system parameters. The Thorough option causes ScanDisk to perform a surface analysis of the disk in addition to the standard detection and repair.

To check a disk, select it from the drive list; then choose Standard or Thorough. If you choose Thorough, you can choose the Options button to specify options for the additional surface scan. Choosing Options displays the Surface Scan Options dialog box, shown in Figure 15.2.

FIGURE 15.2 The Surface Scan Options dialog box.

The following list explains the options in the Surface Scan Options dialog box:

By default, ScanDisk prompts you with various dialog boxes when it encounters a disk error.

If you prefer that ScanDisk automatically repair all errors without input from you, enable the Automatically fix errors check box and choose Start in the ScanDisk dialog box.


WARNING: Enabling the automatic error repair option is not a good idea if you have never run ScanDisk on a drive before. You will want advance notice of any problems ScanDisk encounters so you can decide whether to correct them manually and take measures to ensure they don't return. For instance, one of the errors that ScanDisk reports is if a complete filename (that is, the pathname plus the MS-DOS filename) is greater than 64 characters, which makes it inaccessible from MS-DOS-based programs. This error generally isn't worth correcting unless you have MS-DOS-based programs that require access to those files (in which case the best solution is to move the problem files up to a folder off the root directory and therefore shorten the pathnames). You can avoid this particular error by unchecking the "Enable MS-DOS mode name errors" box in the Advanced Options dialog box of ScanDisk. In general, don't enable automatic error correction unless you're sure that there will be no untoward circumstances.

Setting Advanced ScanDisk Options

ScanDisk includes a number of advanced options you can set to control the way the program runs, detects errors, and repairs those errors. To set these advanced options, choose the Advanced button to display the ScanDisk Advanced Options dialog box, shown in Figure 15.3.

FIGURE 15.3 The ScanDisk Advanced Options dialog box.

Display Summary

The three options in the Display summary group control whether ScanDisk displays a summary dialog box after it finishes the detection and repair phase. Choose Always if you want ScanDisk to always display a summary report, regardless of whether it detects and fixes any errors. Choose Never if you don't want ScanDisk to display a summary report. Choose the Only if errors found option if you want ScanDisk to generate a summary report only if it detects errors during its scan.

Log File

The three options in the Log file group control the way ScanDisk logs detection and repair information. If you configure ScanDisk to create a log, it will create the file SCANDISK.LOG in the root directory of the disk it checks. This log file contains a report of the errors ScanDisk finds and the actions ScanDisk takes regarding those errors. Log files are useful if, for the sake of troubleshooting, you want to get an idea of what happens during a disk scan.

Choose Replace log if you want ScanDisk to create a new log each time it runs, replacing any existing copy of SCANDISK.LOG. Choose Append to log if you want ScanDisk to append new log entries to the end of the existing log. Choose the No log option if you don't want ScanDisk to create a log.

Cross-Linked Files

A cross-link occurs when two or more files use the same cluster. Typically, the cluster really belongs to only one of the files. Sometimes the cross-linked cluster might really belong to neither file. Therefore, repairing cross-linked files usually results in only one file remaining usable.

The options in the Cross-linked files group control the way ScanDisk handles any cross-linked files it finds during detection. If you choose the Delete option, ScanDisk deletes any files that have cross-linked clusters. Choose the Make copies option if you want ScanDisk to retain the files. ScanDisk will create a separate copy of the cluster for each file. Although this removes the link between the files, it does not ensure that either file ends up usable. Choose the Ignore option if you want ScanDisk to ignore cross-linked files.


TIP: If you decide to let ScanDisk correct the cross-linked files, your best option usually is to choose the Make copies option. By making separate copies of the cross-linked cluster for each file and retaining the files, you make it possible to recover at least one of the files.

Lost File Fragments

Clusters can become "lost," which means that they are not marked in the FAT as being available, although they are not in use. ScanDisk can recover lost clusters and convert cluster chains into files or simply allocate the clusters as free, making them available. Converting the lost cluster chains to files enables you to recover files accidentally lost through disk errors. Most often, however, the lost clusters are simply improperly allocated and can be returned to the pool of available clusters.

The options in the Lost file fragments group enable you to specify how ScanDisk treats lost cluster chains. Choose the Free option if you want ScanDisk to mark the clusters in the lost chains as available for use. Choose the Convert to files option if you want ScanDisk to convert those lost cluster chains to files. If you use the Convert to files option, ScanDisk reads the cluster chains and writes them to the root folder (root directory) of the drive using the filename format FILEnnnn, where nnnn is a number.

"Check Files For"

The check boxes in the Check files for group enable you to specify the types of errors for which ScanDisk scans. If you enable the Invalid file names option, ScanDisk detects invalid filenames and attempts to repair them. Invalid filenames can prevent you from opening the associated file.

The Invalid dates and times option, if enabled, causes ScanDisk to check the creation and modification dates and times of each file. An invalid date or time can cause a file to sort incorrectly and can cause problems with file backup and file restore operations.

The Duplicate Names option, if enabled, makes ScanDisk check for files that have the same names in the same directory, and rename one of the offending files automatically.

"Check Host Drive First"

The option Check host drive first, if enabled, causes ScanDisk to always check the host drive of a DriveSpace- or DoubleSpace-compressed volume before checking the integrity of the compressed volume. If compressed drive F is stored on drive C, for example, and you enable this option, running ScanDisk against drive F causes ScanDisk to first check drive C for errors. Generally, leaving this option enabled is a good idea because errors on the host disk can cause errors in the compressed disk. Usually the only reason to disable this option is if you have just finished checking and repairing the host disk and now want to check the compressed disk.

Report MS-DOS Mode Name Length Errors

The option "Remote MS-DOS mode name length errors" will force ScanDisk to check for files whose total length--the pathname plus the file name--exceeds 63 characters. If you have files living in deeply nested directories, you may have this error. This is important if you are still using MS-DOS-based programs, since they will not be able to read such files. If you're not relying on MS-DOS-based programs, then the 63-character limit doesn't apply, and you can disable this option.

Checking a Compressed Drive

In addition to checking standard disks, ScanDisk also can scan and repair problems with DriveSpace- and DoubleSpace-compressed volumes. DoubleSpace volumes are supported by MS-DOS 6.0, and DriveSpace volumes are supported by MS-DOS 6.2x. Windows 98 also enables you to create and use DriveSpace volumes.

A DriveSpace (and DoubleSpace) volume is a hidden file that resides on a host drive. If your PC contains a single hard disk that has a single partition (containing logical drive C), you can compress some of the free space on drive C to create a new drive D. The compressed drive D actually resides in the hidden file DRVSPACE.001. When the system boots, Windows 98 mounts the hidden file as drive D, enabling you to work with it as if it were a regular, physical disk. A detailed discussion of disk compression can be found in Chapter 14, "Disk and File System Overview."


TIP: You also can use DriveSpace to compress floppy disks and use those disks in any PC. Windows 98 also supports using compressed disks created with DoubleSpace in MS-DOS 6.0. The information in this section refers to DoubleSpace volumes as well as DriveSpace volumes.

As with physical disks, compressed volumes can become corrupted or contain invalid file and directory entries. Therefore, checking your PC's compressed disks is as important as checking the physical disks.

Before checking the compressed volume, you should direct ScanDisk to check the host drive. If the Check host drive first check box is enabled in the ScanDisk Advanced Options dialog box (refer to Figure 15.3), ScanDisk automatically checks the host disk of the DriveSpace volume before it checks the DriveSpace volume. Alternatively, you can manually direct ScanDisk to check the host disk and then direct it to check the compressed volume. Either way, it treats compressed volumes like any other disk. Simply open ScanDisk, select the compressed volume's logical disk ID from the list of mounted disks, and choose Start.

Running ScanDisk Automatically at Startup

Many DOS users run CHKDSK or an equivalent utility each time their PCs start, resulting in a regular check of their computer's hard disk. You might want to run ScanDisk for Windows on a regular basis on a Windows 98 system for the same reason--to ensure that your disks always perform at their best.

To automate ScanDisk so that it runs automatically each time you start Windows 98, you can add it to your Task Scheduler folder. All applications and documents in the Startup folder open automatically when Windows 98 starts.

The process for automating ScanDisk requires two steps. The first step is to place a shortcut to ScanDisk in the Startup folder. To do so, use the following procedure:

1. Right-click on the Taskbar to display its Context menu, choose Properties to display the Taskbar property sheet, and click on the Start Menu Programs tab to display the Start Menu Programs property page.

2. Choose Add to display the Create Shortcut Wizard.

3. Choose Browse, locate and select the file SCANDSKW.EXE in your Windows folder, and choose Open. Or enter C:\WINDOWS\SCANDSKW.EXE in the Command line text box in the Create Shortcut dialog box.

4. In the Create Shortcut dialog box, click on Next to display the Select Program Folder dialog box.

5. In the Select Program Folder dialog box, select the Startup folder; then click on Next. The wizard prompts you for a name for the shortcut. You can leave the existing name and choose Finish to create the shortcut.


TIP: If your PC is not configured for multiple user profiles, your Startup folder is located in \Windows\Start Menu\Programs\Startup. If your PC is configured for multiple user profiles, your Startup folder is located in \Windows\Profiles\your user name\Start Menu\Programs\ Startup.

The second step in running ScanDisk automatically at startup is to add a couple of switches to the command line in the ScanDisk shortcut you just created in the Startup folder. All the ScanDisk command-line switches are explained in the following section. For now, however, just understand that you need to add the /N switch to the ScanDisk command line to cause ScanDisk to start and end automatically.

To add a switch to ScanDisk's command line, open the Startup folder and right-click on the ScanDisk shortcut to display its Context menu; then choose Properties. Click on the Shortcut tab to display the Shortcut property page. Click in the Target text box, move the cursor to the end of the command line, and add the switches so that the command line reads as follows:

C:\WINDOWS\SCANDSKW.EXE /A /N

The preceding command line causes ScanDisk to scan all nonremovable hard disks and to do so noninteractively (automatically). You might want to restrict ScanDisk to analyzing only one or two disks. The following command line would cause ScanDisk to scan drives C and D automatically:

C:\WINDOWS\SCANDSK.EXE C: D: /N

After you set the command line according to your preferences, choose OK to apply the changes to the shortcut. If you want to use other command-line switches with ScanDisk, read the following section, "Using ScanDisk Switches," to learn about the additional switches ScanDisk supports.

TIP: ScanDisk for Windows uses the settings stored in the Registry to determine which options to use when you run the program noninteractively. Therefore, you can run ScanDisk for Windows interactively, set options as you want, and then close ScanDisk. When you run ScanDisk for Windows from the command line, it uses the same settings. For example, if you want ScanDisk to automatically check for invalid file dates and times when you run the program noninteractively, enable the Invalid dates and times check box in the ScanDisk Advanced Options dialog box; then close ScanDisk. The next time you run the program, ScanDisk will check for invalid dates and times.

Using ScanDisk Switches

ScanDisk for Windows supports a number of program switches that modify the way the program works or automates its operation. The format for the ScanDisk for Windows command line is as follows:

SCANDSKW [drive1 drive2 drive3...] /A /N /P

You can add command switches to the command line if you start ScanDisk from a command prompt, or you can create a shortcut to SCANDSKW.EXE and add the switches in the Command line text box on the shortcut's property sheet.

The ScanDisk for Windows switches are summarized in the following list:

Using ScanDisk for Windows at the Command Prompt

You can run ScanDisk for Windows when your computer is running the full Windows 98 operating system and GUI, from the GUI, or at a command prompt. You can run SCANDISK.EXE, however, only from the command prompt and only if the GUI is not running (when you boot the system to the command prompt).


TIP: If you open a command-line session from the GUI and run SCANDISK.EXE, located in the \Windows\Command folder, the GUI version of ScanDisk, SCANDSKW.EXE, starts. The command-line version runs only if you boot the system to the command prompt.

You also can run the command-line version of ScanDisk from a batch file that you run in a DOS box under Windows 98. The following section offers some tips on running ScanDisk for Windows in batch files. Read the section "Using SCANDISK.EXE" later in this chapter for information on using the command-line version of ScanDisk in batch files.


WARNING: If you use a version of ScanDisk from DOS 6.x, you lose your long filenames and also might damage your file system. Use only the Windows 98 versions of ScanDisk on a system that contains Windows 98.

Using ScanDisk for Windows in Batch Files

You can include ScanDisk for Windows in batch files to automate disk scanning and repair. To use ScanDisk in a batch file, simply add the command in the batch file. The following sample batch file uses the START command to start ScanDisk and check drive C noninteractively and returns a message based on ScanDisk's completion code:

echo off
start /w scandskw.exe c: /n
If errorlevel 255 goto termerror
If errorlevel 254 goto cancelled
If errorlevel 253 goto onedrive
If errorlevel 252 goto notfixed
If errorlevel 251 goto memory
If errorlevel 250 goto diskmaint
If errorlevel 1 goto allfixed
If errorlevel 0 goto noerrors
:termerror
echo Check was terminated because of an error
goto end
:cancelled
echo Check was cancelled
goto end
:onedrive
echo At least one drive could not be checked
goto end
:notfixed
echo Errors found, but at least some were not fixed
goto end
:memory
echo Could not start - insufficient memory
goto end
:diskmaint
echo Could not start - cannot load or find diskmaint.dll
goto end
:allfixed
echo Errors found, all fixed
goto end
:noerrors
echo Drive checked, no errors found
goto end
:end


NOTE: Notice in the batch file that the START command is used to issue the ScanDisk command. You can use START to start a Windows or DOS application from the command line. The /w switch, used with the START command, causes the batch file to wait until the called application (in this case, ScanDisk) finishes before it proceeds with the rest of the batch file.

Checking ScanDisk Exit Codes

ScanDisk for Windows generates a result code when it finishes its work. You can base your batch file's conditional operation on the result code ScanDisk generates by testing for errorlevel, as indicated in the batch file in the previous section. Table 15.1 shows the result codes for ScanDisk for Windows.

TABLE 15.1 ScanDisk for Windows Result Codes

RESULT CODE MEANING
0 Drive checked, no errors found
1 Errors found, all fixed
250 Check could not start--cannot load or find DSKMAINT.DLL
251 Check could not start--insufficient memory
252 Errors found, but at least some were not fixed
253 At least one drive could not be checked
254 Check was canceled
255 Check was terminated because of an error

Using SCANDISK.EXE

The Windows 98 DOS version of ScanDisk, SCANDISK.EXE, is useful for checking the disks when you boot the computer to a previous version of DOS or to the Windows 98 command prompt. Using the DOS version of ScanDisk included with Windows 98, rather than the older version of ScanDisk included with DOS, ensures that you retain your long filenames. You also can use SCANDISK.EXE in batch files you run in a previous version of DOS or from the Windows 98 command prompt. The DOS version of ScanDisk included with Windows 98 also supports a number of switches. The format of the SCANDISK.EXE command is as follows:

SCANDISK [drive: | /ALL] [/CHECKONLY | /AUTOFIX [/NOSAVE]]  [/SURFACE]

The switches supported by SCANDISK.EXE are described in the following list:

You also can use SCANDISK.EXE to scan an unmounted DriveSpace volume, something for which you cannot use ScanDisk for Windows. The format for the ScanDisk command to check an unmounted DriveSpace volume is as follows:

SCANDISK drive:\DRVSPACE.nnn [/CHECKONLY | /AUTOFIX[/NOSAVE]]

The drive: parameter specifies the location of the unmounted volume's file, and the DRVSPACE.nnn parameter specifies the actual name of the file. For example, the following command would check the first DriveSpace volume file stored on drive C:

SCANDISK C:\DRVSPACE.001

You also can use ScanDisk to examine a DriveSpace volume file for fragmentation. To do so, use the following syntax:

SCANDISK /FRAGMENT [drive:][path]filename

Include the drive name, pathname, and filename for the DriveSpace volume file on the command line, as in the following example:

SCANDISK /FRAGMENT C:\DRVSPACE.001

Undoing ScanDisk Repairs

When ScanDisk detects an error, it displays a prompt and gives you the opportunity to write a record of the changes to a disk. You can use this record later to undo the changes ScanDisk makes.

To undo repairs ScanDisk makes, use the following syntax:

SCANDISK /UNDO [drive:]

Replace the drive: parameter with the drive ID on which the Undo information is located.

Defragmenting a Disk

Because of the way DOS and Windows 98 allocate space for files on the disk, a file can get fragmented, or scattered around the disk. Instead of residing in contiguous (side-by-side) clusters, the file is spread out to noncontiguous clusters. Fragmentation doesn't pose a problem for DOS or Windows 98 because both are equally capable of following the FAT entries to locate the fragments of the file. The disadvantage of a fragmented disk is that locating and reading an entire file can take considerably longer because Windows 98 must jump around the disk, requiring multiple spins of the disk to locate the file's data. It can't read the entire file in a single pass. Fragmentation, therefore, can greatly impact Windows 98's performance, particularly for applications that access the hard disk extensively.

MS-DOS 6.x includes a utility called DEFRAG that defragments the disk, writing all the files in contiguous clusters and thereby improving disk performance. Windows 98 also includes a utility, appropriately called Disk Defragmenter, to defragment the disk. Disk Defragmenter is a Windows 98 application, which means you can defragment the disk as a background task while you continue to work with other applications. Your ability to continue working while Disk Defragmenter works, however, depends highly on your system's speed. On slower 486 and all 386 systems, continuing to work while Disk Defragmenter works on the disk is unlikely to prove practical. Faster Pentium and Pentium II systems make it easier to do this, thanks to a combination of the speed of the processor and the hard drive; the defrag process can be better interleaved with the rest of the machine's functions.


WARNING: When Setup installs Windows 98 over DOS, it deletes the old DOS DEFRAG program and replaces it with a batch file named DEFRAG.BAT (if you install Windows 98 in your existing Windows 3.x directory). DEFRAG.BAT simply contains instructions on how to run the Windows 98 Disk Defragmenter. Setup deletes DEFRAG from your DOS directory to ensure the security of your long filenames. Therefore, you should never run an old DOS version of DEFRAG on a disk that contains long filenames.

The Disk Defragmenter can defragment local floppy disks and hard disks, including any compressed volumes Windows 98 supports. Disk Defrag-menter cannot defragment CDs, remote network disks, other removable or nonwritable media, locked disks, or disks created using ASSIGN, SUBST, or JOIN.


NOTE: Defragmenting a disk is not a once-only task. File fragmentation is an ever-present problem, and you should periodically defragment the disk to optimize its performance. See the section later in this chapter titled "Using Task Scheduler for Periodic Maintenance" for more on this.

Using Disk Defragmenter

To start Disk Defragmenter, choose Start | Programs | Accessories | System Tools | Disk Defragmenter. The Select Drive dialog box appears, as shown in Figure 15.4. You also can start Disk Defragmenter from a command prompt by typing START DEFRAG in the Run box (available from the Start button).

The Select Drive dialog box lists all the disks Disk Defragmenter can defragment. Select the disk you want to defragment; then choose OK.

FIGURE 15.4 Disk Defragmenter's Select Drive dialog box.


TIP: To defragment all your computer's hard disks, choose All Hard Drives from the Select Drive dialog box.

If fragmentation of the disk remains below a certain percentage, Disk Defragmenter indicates in its prompt that you do not need to defragment the disk. Even so, you can still defragment the disk if you want. Doing so might not improve disk performance significantly, but it will improve it at least slightly. The most noticeable improvement from defragmenting a disk comes when you defragment a heavily fragmented disk.

If you want to defragment the selected disk, choose the Start button. Disk Defragmenter displays a status dialog of its progress, as shown in Figure 15.5. If you prefer a more detailed report, choose Show Details to display an expanded disk window.

FIGURE 15.5 The Disk Defragmenter status dialog box.

Setting Disk Defragmenter Options

You can specify various options that control the way Disk Defragmenter functions. To set these options, choose the Advanced button in the Disk Defragmenter dialog box to display the Advanced Options dialog box (see Figure 15.6).

FIGURE 15.6 The Settings dialog box for Disk Defragmenter.

The Defragmentation method group enables you to specify how Disk Defragmenter defragments the disk. The following list explains the options in the Defragmentation method group:

The two option buttons, This time only and Every time I defragment my hard drive, determine whether to save the Defragmentation method option and the Check drive for errors option for future Disk Defragmenter sessions.

Using Switches with Disk Defragmenter

Like ScanDisk and other Windows 98 utilities, Disk Defragmenter supports a number of command-line switches you can use to modify and automate the way Disk Defragmenter runs. You can create a shortcut to Disk Defragmenter and add these switches to the shortcut's Command line property. Or you can start Disk Defragmenter from the command line and add the switches at the end of the command you use to start Disk Defragmenter.

The syntax of the Disk Defragmenter command line follows:

defrag [drive: | /all] [/F | /U | /Q] [/noprompt]  [/concise | /detailed]

The following list describes the command-line parameters and switches that Disk Defragmenter supports:

You can include the Disk Defragmenter command-line switches in the Command line text box of a shortcut to Disk Defragmenter. Using the shortcut to start Disk Defragmenter uses the switches in the Command line property. You can create multiple shortcuts to Disk Defragmenter, each using different command-line switches, which makes possible running Disk Defragmenter in different ways simply by choosing a particular icon.

You also can use command-line switches when you start Disk Defragmenter from the command line. The following section explains this.

Running Disk Defragmenter from the Command Prompt

As with other Windows 98 utilities, you can start Disk Defragmenter from the Windows 98 command prompt (DOS session started under Windows 98). To start Disk Defragmenter, open a DOS session and enter START DEFRAG, followed by any optional switches. The following example starts Disk Defragmenter to defragment, in unattended mode, only files on drive C:

start defrag c: /u /concise /noprompt

You also can use the DEFRAG command in batch files. If you want the Disk Defragmenter program to complete operation before execution continues in the batch file, use the /w switch with the START command to cause the batch file to wait until Disk Defragmenter completes operation. The following example starts Disk Defragmenter, in Unattended mode, on files and free space on drive D and waits for completion of the operation before continuing execution of the batch file:

start /w 95 defrag d: /f /concise /noprompt

Using Defrag Exit Codes

Like ScanDisk, Disk Defragmenter returns an error code after it's done. You can use the If errorlevel statement to test the value of the return code and conditionally branch in a batch file based on the code. Table 15.2 lists the codes Defrag returns.

TABLE 15.2 Disk Defragmenter Return Codes

RESULT CODE MEANING
0 No errors reported
2 No free clusters, no clusters large enough (16 sectors)
4 General error, run ScanDisk
5 Error reading cluster, run ScanDisk
6 Error writing cluster, run ScanDisk
10 Invalid disk type
15 Write protected
26 Cannot access the drive
103 Locking problem
105 Defrag could not get a lock on a drive
109 Protect mode compression driver is required

Refer to the section "Using ScanDisk for Windows in Batch Files" earlier in this chapter for an example of a batch file that tests error level and conditionally branches according to the value of the return code. You can use a similar batch file for Disk Defragmenter.

Defragmenting Compressed Volumes

Because DriveSpace allocates space sector by sector, a DriveSpace volume can contain relatively small fragments. Because only very small files can fit in these small fragments, DriveSpace volumes suffer performance degradation to a higher degree than do uncompressed disks. For that reason, you need to periodically defragment your DriveSpace volumes to ensure the best possible performance when accessing those volumes.

You don't have to do anything special to defragment a compressed volume. Disk Defragmenter treats the volume just like any other disk, at least in terms of the program interface. Simply select the compressed volume you want to defragment, choose OK, and then choose Start.


NOTE: Unlike ScanDisk, Disk Defragmenter only defragments mounted compressed volumes. You can't defragment an unmounted compressed volume. If you need to defragment the volume, first use DriveSpace to mount the volume.

Using Task Scheduler for Periodic Maintenance

Task Scheduler is a very powerful Windows 98 applet that resides in the System Tray and allows the user to schedule specific programs to run once at a given time or at regular intervals. Task Scheduler is a good way to schedule regular disk scans or defragmentations, and a conscientious user should make use of it to run Disk Defragmenter and ScanDisk at regular intervals. Once a week for a conventional desktop system is a good interval; once every three days for a system where a great many files are constantly being added or deleted is also good. See Chapter 18, "Automating Tasks," for more information on how to make use of Task Scheduler to keep your system tuned.

Improving CD-ROM Performance

Access to CD-ROM drives in MS-DOS is supported by a DOS extension named MSCDEX, which enables the system to read the CD-ROM drive. Like all DOS components, MSCDEX is a 16-bit, real-mode driver. Windows 98 improves CD-ROM performance by providing a 32-bit CD-ROM file system called CDFS. CDFS eliminates the need to use MSCDEX, increasing CD-ROM performance by reducing access time and increasing throughput.

CDFS is a dynamically loadable driver. If Windows 98 detects a CD-ROM drive in the system, it automatically loads CDFS to enable the operating system to read the CD-ROM drive. Like the other disk drivers in Windows 98, CDFS supports long filenames and use of VCACHE to further improve CD-ROM performance by caching often-used data. The cache CDFS uses is separate from the hard disk cache. This allows Windows 98 to store the CDFS cache on the hard drive when the CD-ROM is idle, and thus conserve memory. Using a separate cache also prevents the hard disk cache from being flushed when a large data stream is read from the CD.


NOTE: To further improve performance, CDFS reads ahead of the application that uses the CD, typically resulting in smoother playback and fewer pauses during playback.

Windows 98 enables you to specify the cache size for CDFS and optimize the cache for the type of CD-ROM drive in the system. To set these parameters, open the Control Panel and choose the System object. In the System property sheet, click on the Performance tab to display the Performance page. Then choose the File System button to display the File System Properties dialog box, shown in Figure 15.7.

FIGURE 15.7 The File System Properties dialog box.

The CD-ROM Optimization group of controls enables you to specify the cache size and optimize it for your CD-ROM drive. Use the Optimize access pattern drop-down list to specify whether the CD-ROM drive in your system is a single-, double-, triple-, or quad-speed drive. Then use the Supplemental cache size slider control to change, the size of the cache based on the amount of RAM in your system. Use Table 15.3 as a guide to set the cache size.

TABLE 15.3 CDFS Cache Size versus RAM

Installed RAM Cache Size
8 MB or less 64 KB
8 MB-12MB 626 KB
12 MB or more 1,238 KB

The minimum and maximum cache sizes you can set using the Supplemental cache size slider change, depending on the selection in the Optimize access pattern drop-down list. Choosing a slower CD-ROM speed from this drop-down list results in smaller minimum and maximum cache sizes. Choosing a faster speed results in larger minimum and maximum cache sizes. Therefore, you should specify the CD-ROM drive type first; then specify the cache size.

Although you can set the cache size to the maximum for your type of CD-ROM drive, doing so might not provide significant performance improvements over a smaller cache. If your system contains plenty of RAM, you can set the cache to its maximum. Otherwise, set the cache size to a low or medium setting. When you have the settings the way you want them, choose OK; then choose OK again to close the dialog box and property sheet.

Using Troubleshooting Options

Windows 98 includes a selection of settings that you can turn on and off to troubleshoot file system problems. Because some file system problems can prevent you from starting and running Windows 98, you can use command-line switches to enable some of these troubleshooting options when you start Windows 98. These WIN command-line switches are explained in the section "Using Startup Switches" in Chapter 4, "Troubleshooting Setup and Startup."

You also can turn on and off the troubleshooting options within Windows 98. To do so, open the Control Panel and choose the System object. On the System property sheet, click on the Performance tab to display the Performance page. Choose the File System button to display the File System property sheet. Then choose the Troubleshooting tab to display the Troubleshooting page.

The following list explains the options on the Troubleshooting property page:

For additional help with troubleshooting problems in Windows 98, refer to Chapter 4.

Preserving Long Filenames

All the disk utilities included in Windows 98 support long filenames. Older utilities, such as the DEFRAG utility in MS-DOS 6.x, pre-Windows 98 versions of Norton Utilities and PC Tools, and other pre-Windows 98 disk repair and backup utilities are not compatible with Windows 98's long filenames. What's more, they destroy long filenames if you use these utilities on a Windows 98 system.

Sometimes, however, you might need to use one of these disk repair or backup utilities on a Windows 98 system. With that possibility in mind, Microsoft developed a utility that enables you to back up and restore long filenames: LFNBK, included on the Windows 98 CD in the \tools\reskit\ file\ folder.

How LFNBK Works

LFNBK renames each file that has a long filename to a short filename alias. LFNBK records each file's short name and long filename in file Lfnbk.dat, stored in the root directory of the drive being processed. This data file enables LFNBK to later rename the files using their previous long filenames.

LFNBK does have some limitations. The following list explains these limitations and some issues to remember when you use LFNBK:

Using LFNBK

To protect long filenames with LFNBK, you first run LFNBK to back up the long filenames on the disk. Then you run the incompatible disk utility, which results in the long filenames being lost. You then run LFNBK again to restore the long filenames.

To run LFNBK, first copy the LFNBK.EXE program file from the source disk to the Windows directory. Then you must turn off long filename tunneling, which causes Windows 98 to preserve long filename entries when standard applications read and write to the files. To turn off tunneling, open the Control Panel and choose the System object. In the System property sheet, click on the Performance tab; then choose the File System button. On the File System property sheet, click on the Troubleshooting tab to display the Troubleshooting property page. Then place a check in the Disable long name preservation for old programs check box, choose OK, and choose OK again. The system will prompt you to reboot, and you should allow it to reboot before continuing.

After you turn off tunneling, close all running programs. Open an MS-DOS session and enter an LFNBK command based on the following syntax:

LFNBK [/v] [/b | /r | /pe] [/p] [drive:]

The following list explains the switches and parameters you can specify with LFNBK:


Previous chapterNext chapterContents

© Copyright, Macmillan Computer Publishing. All rights reserved.