Older Operating Systems

Class Notes # 13 Hard Drive Performance November 13, 2003

Your computer’s performance is strongly influenced by the characteristics of your hard disk. These characteristics of your hard disk include the following: • The speed of your hard disk influences the speed of your system. • The amount of space on your hard disk. • The reliability of the hard disk to store data.

DOS provides several techniques to increase the speed at which programs can access information. These techniques are: • Disk Cache • Fastopen • Ram Disk • Defragmenting

Disk Cache The most significant way to enhance the performance of your hard disk is to use a disk- caching program. Most programs access the same programs and data repeatedly. Disk cache takes advantage of this by allocating some of the memory for temporary data storage. For example, if a program accesses data, the disk-caching program saves that data in memory (e.g. RAM), on the assumption that the same data will be used again. If a program requires access to the same data again, the disk-caching program intercepts the disk access and gives the program the data stored in memory. The program receives the data quicker since DOS doesn’t require reading the data from hard disk; instead, the disk- caching program finds the data in its cache buffer.

The disk-caching program that comes with DOS is called SMARTDRV.EXE, or SMARTdrive. SMARTdrive builds its buffer area in XMS ( specification) or EMS ( specification) memory, using very little .

When DOS reads information from the disk, it places that information in the cache (due to SMARTdrive), and sends the requested information to the program that requested it. SMARTdrive reads more information than the program requests and stores that information in memory. If the program later requests information that is already in memory, then cache supplies that information faster than DOS can retrieve the information from hard disk.

SMARTdrive also eliminates redundant disk writing by placing information on disk only when the data differs from data already stored. The program also accumulates information, writing out data to the hard disk only when a certain amount has accumulated. If you use write caching and a power failure occurs while SMARTdrive is accumulating data, you lose the data that it has not yet written to disk.

1 When the cache must be recycled (new data stored in the cache), the program retains the data in the most frequently used areas and discards the data in the less frequently used area. A cache tends to keep in memory the most heavily used areas of the disk.

To start SMARTdrive, enter a in your autoexec.bat file that has the following syntax:

SMARTDRV /X drive± … initsize winsize /E:esize /B:bsize /switches

/X: specifies that you want to disable write-behind cache for all drives by default. You can then enable or disable individual drives with the drive± parameter. drive±: If you just specify the drive letter then this will enable read caching and disable write caching. If you specify the drive+ parameter then this will enable read and write caching. If you specify the drive- parameter then this will disable the cache for that drive. initsize: The size (kilobytes) of the cache when SMARTdrive starts. The default values for this parameter is given in table one. winsize: The size (kilobytes) by which SMARTdrive reduces its cache when windows starts, freeing that memory for Windows to use. When you quit Windows, that memory is returned to SMARTdrive and defaults to the values listed in table one.

Table one: The default memory values for initsize and winsize Extended Memory initsize (cache) winsize (cache) Up to 1 Mbytes All XMS Zero (no caching) Up to 2 Mbytes 1 Mbyte 256 kbytes Up to 4 Mbytes 1 Mbyte 512 kbytes Up to 6 Mbytes 2 Mbyte 1 Mbyte More than 6 Mbytes 2 Mbyte 2 Mbyte

/E:esize The element size (bytes), which the amount of cache data that SMARTdrive moves in one operation. Values can be 1024 bytes, 2048 bytes, 4096 bytes, 8192 bytes. The default is 8192 bytes. The smaller the number, the less memory SMARTdrive takes and the slower the performance.

/B:bsize The size of the read ahead buffer (bytes that are a multiple of esize), which is how much SMARTdrive reads beyond a disk request. The default is 16384 bytes. The smaller the number, the less conventional memory SMARTdrive takes and the slower the performance.

2 Table two: SMARTdrive switches Switch Description /U If you specify this switch, then SMARTdrive will not load the CD-ROM caching module. /C Clears SMARTdrive by writing all write buffers to disk. /R Resets SMARTdrive by clearing all caches and restarting SMARTdrive /F Writes cached data to the disk after each command finishes, before the DOS command prompts reappears. /N Writes cached data to the disk whenever the system is idle. /V Forces “verbose” mode, so status messages appear when SMARTdrive starts. You cannot use this switch with /Q /Q Forces quite mode, so status messages do not appear when SMARTdrive starts. Only error messages will appear. /Q is the default /S Displays SMARTdrive’s status, including what and how drives are cached and a cache hit statistic. /L Forces SMARTdrive to load into low (conventional) memory even if room exists in upper memory.

For SMARTdrive to use extended memory, you must load HIMEM.SYS or some other extended memory manager. Also, if you want SMARTdrive to cache a CD-ROM drive, you have to load MSCDEX into memory before SMARTdrive.

Example: To enable read caching for drive C, read and write caching for drive D, and using a 4Mbyte cache for DOS that can get no smaller than 2Mbytes when is running, issue the following command:

C:\DOS\SMARTDRV C D+ 4096 2048

FASTOPEN Another way to improve hard disk performance is to use the FASTOPEN program. FASTOPEN is an executable program that you can include in AUTOEXEC.BAT. You can also load FASTOPEN through CONFIG.SYS using the install command. You can use FASTOPEN only with hard drives. FASTOPEN caches directory information, holding in memory the locations of frequently used files and directories.

DOS typically holds the (FAT) in the disk buffers, FASTOPEN was developed to hold directory entries in memory. FASTOPEN’s syntax is:

FASTOPEN.EXE C:= n /X

The C: parameter is the name of the first hard drive that you want FASTOPEN to track. You can specify up to 24 hard disk or hard disk partitions at one time. The /X switch enables FASTOPEN information to reside in EMS. By default, FASTOPEN uses conventional memory. The n parameter is the number of directory entries that FASTOPEN should cache. Each file or subdirectory requires one directory entry. You

3 can enter a value ranging from 10 through 999. If you do not specify a value for n, DOS uses a default value of 48.

Each directory entry stored in memory takes 48 bytes. Therefore, the practical range for n is between 100 and 200 per disk. Using too small a number for n also can be a disadvantage. FASTOPEN discards the least recently used entry when it needs space for a new entry. If the n value is too small, DOS discards entries that it still may need. The objective is to have enough entries in memory so that FASTOPEN operates efficiently, but not so many entries that FASTOPEN wastes time searching through directory entries.

To load FASTOPEN as part of your regular configuration, use the INSTALL command in your CONFIG.SYS file, as follows:

INSTALL = FASTOPEN.EXE C:

To load FASTOPEN in upper memory, use LOADHIGH in AUTOEXEC.BAT. For example, LOADHIGH C:\DOS\FASTOPEN C:

Note: you must disable FASTOPEN to run the defrag program. Also do not use FASTOPEN with Windows.

RAM Disk A RAM disk is a that uses a portion of your computer’s memory to emulate a disk drive. You can use RAM drive as you use any other disk drive. A RAM disk is extremely fast compared with a real disk drive. You must, however, give up a significant amount of memory to create a useful RAM disk. Also you cannot store anything permanent like the disk drive, since the contents of RAM disk disappears when you turn off your computer.

The RAM disk driver that comes with DOS is named RAMDRIVE.SYS. To install RAMDRIVE and create a virtual disk, include RAMDRIVE.SYS as a device driver in CONFIG.SYS. The syntax for including RAMDRIVE is:

DEVICE = RAMDRIVE.SYS disksize sectorsize entries /E /A

The disksize parameter indicates the size of the RAM disk in kilobytes. This number can range from 16 kbytes to 32,767 kbytes. The default is 64 kbytes.

The sectorsize parameter represents the size of the sectors used in the virtual disk. You can specify one of three sector sizes: 128 bytes, 256 bytes, or 512 bytes (default = 512 bytes).

The entries parameter determines the maximum number of directory entries permitted in the RAM disk’s root directory. This parameter can be a value ranging from 2 through 1024. The default value is 64.

4 Normally, DOS creates a RAM disk in conventional memory. You can include the /E switch to cause the RAM disk to be created in XMS memory. Even with this switch, RAMDRIVE still uses some conventional memory, so you may want to try loading the RAMDRIVE.SYS device driver into upper memory. The following command (in CONFIG.SYS) creates a 1024kbyte RAM disk in XMS memory and loads the device driver into upper memory:

DEVICEHIGH = C:\DOS\RAMDRIVE.SYS 1024 /E

The /A switch creates the RAM disk in EMS memory. To use this switch, you must load an expanded memory manager (e.g. EMM386.EXE) before loading RAMDRIVE.SYS.

To assign the TEMP directory to RAM disk, you first have to determine a name for the virtual disk and then use the SET command. Assign the TEMP variable to a subdirectory rather than to the RAM disk’s root directory. Assuming that the RAM disk becomes drive D, use the following commands in AUTOEXEC.BAT to create a directory on the virtual disk and to cause temporary files to be written to that directory:

MD D:\TempData SET TEMP = D:\TempData

Defragmentation When you use your hard drive, you add new files, delete existing files, and add new data to existing files. Over time, data becomes scattered over the disk, and even the data within a single file may reside in chunks throughout the disk. This scattering of data is called fragmentation.

The more fragmented your disk, the slower your computer runs. If data is spread across the disk, and a program requires this data, then the disk heads have to travel this path to retrieve the data. The longer movements require more time to access the data.

Fragmentation is almost inevitable and tends to increase the longer you use your hard disk. Defragmentation implies, moving the data to the beginning of the disk and store each file’s data in the same location. DOS has a built in defragmentation program named DEFRAG. You execute DEFRAG by typing the following at the DOS prompt:

C:\>DEFRAG

A dialog box will appear asking which drive you want to defragment. Once you have selected a drive letter and selected OK, DEFRAG scans the selected drive and displays a map of the used and unused portions. DEFRAG suggests one of the following: • Do nothing • Unfragment files only. If most of the data in the used area of the disk is stored together but the individual files are scattered throughout that area, DEFRAG recommends that you defragment the files.

5 • Full optimization. If the used area of the disk is scattered across the disk, DEFRAG recommends that you perform a full optimization, meaning that you defragment the entire disk.

When DEFRAG makes a recommendation, you can click Configure to select various options that control how DEFRAG works. When you click Configure, DEFRAG presents a optimize menu with selections as shown in table three.

Table 3: DEFRAG optimize (Configuration) menu Selection Description Begin Begins optimization of your hard drive, using any configuration options Optimization you have selected. Drive Enables you to choose the drive you want to optimize Optimization Enables you to choose full optimization or file only (may leave empty method space between files) File sort Enables you to choose how files will be sorted within directories Map legend Displays a legend of the symbols DEFRAG uses to show disk usage About Defrag Displays information about the DEFRAG program Exit Exits DEFRAG

When DEFRAG reorganizes your disk, you can tell it to organize the names of the files within the directories in one of five ways: • Unsorted. This option tells DEFRAG to leave the names in the current order. • Name. DEFRAG organizes the directory alphabetically by file name. This option is probably the one you find most useful. • Extension. DEFRAG organizes the directory by extension name. • Data & Time. DEFRAG sorts the directory by the time and date the files were last modified. • Size. DEFRAG organizes files by the amount of disk space they consume.

You can also sort in ascending or descending order. The complete syntax for DEFRAG is:

DEFRAG C: /F /U /S:order /B /skiphigh /LCD /BW /G0 /H

Table 4: DEFRAG switch options Switch Description /F Defragment the disk (leaving no empty spaces between files) /U Defragment files (possibly leaving empty spaces between files) /S:order Sort by order which is shown in table 5 /B Reboot the computer after the defragmentation process is complete /LCD Use a color scheme /BW Use a black and white color scheme /skiphigh Load itself into conventional memory otherwise DEFRAG uses upper memory

6 /G0 Disables the mouse and graphic character set /H Also move hidden files

Table 5: Sort order options Sort order Description N Alphabetical order by name E Alphabetical order by extension D By time and date, with the oldest dates listed first S By size, with the smallest files listed first

DoubleSpace DoubleSpace is a program. DoubleSpace enables DOS to compress data automatically when you store the data on disk and to uncompress the data when you use it. DoubleSpace works transparently – you have no indication that the program is compressing your files, except that your disk can hold more data than before.

DoubleSpace makes the drive appear as though it were two drives, with two distinct drive letters. DoubleSpace divides the disk into a compressed drive and an uncompressed drive so that you can store some of your files in an uncompressed format. DOS assigns a new drive letter to one of the areas so that you can access either areas by using the appropriate drive letter.

To install DoubleSpace, type the following command at the DOS prompt:

DBLSPACE

You cannot have any other programs running when you first issue this command (i.e. Windows). DoubleSpace will ask you if you want an Express or Custom setup; the default is Express. In Express setup, DoubleSpace compresses the existing files on drive C. Choose Custom setup if you want to select the drive to compress. DBLSPACE then installs the DoubleSpace driver in the DOS kernel and reboots your machine.

DoubleSpace may alos add to the CONFIG.SYS file, such as:

DEVICEHIGH = C:\DOS\DBLSPACE.SYS /MOVE

This will only load DBLSPACE.SYS to upper memory.

You can run DoubleSpace at any time to get information about compression on your disk or to control various facets of DoubleSpace’s operation. You run DoubleSpace simply by typing the following command:

DBLSPACE

When DoubleSpace starts, it lists all the available drives that employ compression. For each drive, DoubleSpace displays the total amount of space and the current free space.

7 To display information about a compressed drive, select the compressed drive, choose Drive from the menu bar, and then choose info from the resulting menu. To change the size of the uncompressed area, click the size button. In the main screen, select Drive, than change size.

To change the compression ratio estimate method, from the Compressed Drive Information dialog box, click the Ratio button. DoubleSpace displays the current ratio that it is using for estimates and the actual ratio that it has been able to achieve in compressing the files. You can enter a new estimate compression ratio and then select OK.

You cannot format a compressed file using the standard DOS format. To format a compressed drive, select the drive you want to format from the list of compressed drives, and then choose the Drive menu and then select Format.

To delete a compressed drive, choose the drive you want to delete from the list of compressed drives, and then choose the Drive menu and then select Delete.

To create a new compressed drive, choose the compress menu. DoubleSpace displays a menu from which you can select either of two ways of compressing the disk.

To compress an existing disk and all the data stored on it, follow this procedure: 1. From the compress menu, choose Existing drive. DoubleSpace displays a dialog box listing existing uncompressed drives, along with their current free space and projected free space. 2. Select the drive to which you want to apply compression. DoubleSpace displays a dialog box showing the drive letter that it will assign to the uncompressed drive and the amount of space it will allocate to that drive. DoubleSpace allocates the rest of the space to the compressed drive. You must allocate at least 0.14 Mbytes to the uncompressed drive; use this value if you do not expect to need any uncompressed space. If you want to change either of these values, select the value that you want to change. When you are ready to proceed, choose continue or press enter. 3. DoubleSpace displays a screen informing you that it is ready to compress the drive. DoubleSpace then prompts you to press C. If you press C, the program creates the compressed drive and compresses existing files in that drive. The new compressed drive uses the original drive letter, and the uncompressed drive receives the new drive letter.

If you want to leave existing files in the uncompressed drive and create a new compressed drive from the free portion of the existing drive, follow this procedure: 1. From the compress menu, choose Create new drive. DoubleSpace displays a dialog box listing existing uncompressed drives, along with their current free space and projected free space. 2. Select the drive to which you want to apply compression. DoubleSpace displays the drive letter it will assign to the compressed drive, the compression ratio it will

8 use to estimate fee space, and the amount of free space it will leave in the uncompressed drive, in addition to the space already used by existing files. The program allocates the rest of the space to the compressed drive. You must leave at least 0.14 Mbytes of free space in the uncompressed drive; use this value if you do not expect to need any uncompressed space. If you want to change either of these values, select the value that you want to change. When you are ready to proceed, choose continue or press enter. 3. DoubleSpace tells you how much time the program requires creating the drive and prompts you to press C to continue. The program then creates the compressed drive, which will be empty. All existing files remain in the uncompressed drive. The uncompressed drive retains the original drive letter, and the compressed drive receives the new drive letter.

Two other useful features from the tool menu is: Defragment and Uncompress. The Defragment option, allow you to defragment a compressed volume. You can also use the standard Defragment command from DOS. DoubleSpace allows you to uncompress a previously compressed drive. Uncompressing a DoubleSpace volume can take up to several hours. Make sure your allocate enough free time to complete the procedure.

9