/X flag was specified by default in MS-DOS 6.22 at least. (See further down for the detailed history.)
/X does is disable the write-back cache in all cases. The write-back cache is used to store data being written to a device, allowing programs to continue working while the data is written. This introduces the risk that, if power is lost or the computer crashes before the data is written, data will be lost, even though the program writing it and the user are under the impression that it’s safe. This is particularly relevant in DOS since there is no enforced shutdown procedure¹ and many users weren’t all that careful with how they powered their computers down (or rebooted them).
There are a number of subtleties which come into play here:
- SMARTDrive disables the write cache on removable devices by default, even without the
/X flag, so writing to a floppy and ejecting it is safe – once the drive light goes off at least;
- SMARTDrive, along with all other well-behaved caches, ensures that all the data waiting to be written is written before returning to the DOS prompt, and this was the documented shutdown procedure: users were supposed to return to the DOS prompt before powering their system down (but see the history below).
Thus, by default (with no flags), SMARTDrive was safe for users following recommended practice, and
SMARTDRV did not have to be started with
/X. Presumably Microsoft realised that that wasn’t sufficient, because even a small number of users not following recommended practice and losing data was too much, and thus added the
/X switch to the default configuration in
On a system running SMARTDrive, invoking
SMARTDRV will show the current configuration, including cache information:
Microsoft SMARTDrive Disk Cache version 5.01
Copyright 1991,1993 Microsoft Corp.
Cache size: 2 097 152 bytes
Cache size while running Windows: 2 097 152 bytes
Disk Caching Status
drive read cache write cache buffering
A: yes no no
B: yes no no
C: yes yes no
Write behind data will be committed before command prompt returns.
For help, type "Smartdrv /?".
/X switch can be used to disable write-back caches even if SMARTDrive was initially loaded with the caches enabled.
To understand why the
/X flag exists, and isn’t the default, some history is necessary. Microsoft provided a brief summary in Q127021: SMARTDrive Version History, and the salient points are as follows:
- write caching was introduced in SMARTDrive 4.0, which shipped with Windows 3.1 and 3.11 (not for Workgroups); this enabled the write cache by default, without any special provisions for flushing it (although the commit cache function was implemented);
- MS-DOS 6.0 shipped with SMARTDrive 4.1, which added support for DoubleSpace, still with no “prompt flushing” and contributed to DoubleSpace’s terrible reputation;
- SMARTDrive 4.2 was released as an interim release (PD0805), adding the
/X flag and ensuring that caches were flushed before the DOS prompt was displayed.
SMARTDRV, with no switches, always enables write caching at least on hard drives; one can only guess why the default wasn’t switched to
/X, and instead the latter was added to the default
AUTOEXEC.BAT invocation (Microsoft’s overriding drive for backwards compatibility presumably plays a role). Significantly, for a little while, waiting for the DOS prompt wasn’t safe.
(Later versions of 4DOS include explicit support for cache flushes, controlled by the
SDFlush configuration setting, and the documentation claims that “Under PC DOS 6.1 and above, and MS-DOS 6.20 and above,
SMARTDRV to write all cached data to the disk before the command prompt is displayed.” I haven’t found any evidence of explicit support in
COMMAND.COM, and I think that the general hook used in SMARTDrive 4.2 is how this was implemented in later versions too. This has been described somewhere but I haven’t found the reference yet.)
Note that all this only describes the cache provided by SMARTDrive itself, i.e. an area of RAM reserved to provide caches for the system’s drives. Drives can have their own caches, which SMARTDrive doesn’t control; back when SMARTDrive was still relevant, hard drives had tiny caches (the 1996 Quantum Fireballs had a whopping 128KiB of cache, which was large at the time; the 1998 IBM DeskStars increased that to 512KiB!) and those caches were write-through.
¹ Enforced meaning that the operating system complains vocally if it isn’t followed.