Disk write caching

The old vanishing data trick

Trust me—you really need to know about disk write caching

Take care when removing your external drives. This applies to USB and firewire external drives, to flash cards and to flash drives – otherwise known as pen or thumb drives. If you don’t follow the rules, one of these frosty Fridays your safely backed up data will be toast.

Yeah? Why?

OK, this is mildly complicated. When Windows, or any other operating system, writes stuff onto your storage drives—hard disk drives, DVD and CD drives, or flash drives for instance—there’s a hurdle to jump.

Your computer can process data at speeds which are orders of magnitude faster than the rate at which it can write data to your disks. If Windows sat around and waited for those data to be written, your fancy new 4GHz processor would be spinning its quad-core wheels and your computer would slow to a crawl until writing was completed.

“The cheque’s in the mail”

Clever techie folk solved this problem a long time ago by introducing “write caching”.

The principle is quite simple: you disconnect the fast computer from the slow disk writing process. Instead of writing the data directly to disc in real time, the information is sent to temporary storage in a (fast) memory cache, the cache then reports back to Windows that the data have been written.

This is the IT equivalent of “the cheque’s in the mail”.

You and your computer can get back to playing Space Invaders and writing the great 21st Century novel. Unfortunately however, just like the mythical cheque, the data have quite possibly not arrived at their intended destination. Windows just thinks they have. Under the hood the data are still sitting in the volatile memory cache waiting for a quiet moment to be written to the target drive.

“OK, So what?” I hear you cry

If the postman steps on a landmine, the cheque in the mail will be dog tucker. Same with your cached data. If your PC is in the process of writing stuff (which it often does, whether you initiated it or not) and you:

  • remove a flash drive from its USB socket or;
  • turn off or disconnect an external hard disk or CD-R drive or;
  • have a power cut and you don’t have a UPS (uninterruptable power supply) or even worse;
  • turn off your PC without shutting down Windows first;

you have a significant risk of data corruption because file writing has not been finalised. If this happens you will probably trash the data and possibly your external disk or, if it’s an operating system file being written to, you can corrupt your Windows installation.

Oh dear, that’s a bit of a worry

Too right it is. But never fear, you can protect yourself.

Don’t turn off your PC without closing down the operating system first. In the case of Windows follow the usual routine to shut down, hibernate or sleep. Never—repeat, never—turn off power to your PC before the machine has shut itself down.safely remove icon

Hot tip

Keyboard shortcut for XP users: Windows key » U » U to shut down, Windows key » U » H to hibernate, Windows key » U » S to sleep.

Click on the icon (like the one shown on the right) in the notification area to the right of your taskbar to “safely remove” an external drive before removing it from its socket, turning it off, or removing its connecting cable from its socket. The icon may be hidden and you’ll need to click on the up arrow to reveal it.

To be 100% safe you should also follow that procedure before your computer goes into hibernation or sleep mode if you intend to remove the device.

  • Get a UPS – plug your PC, your monitor and your powered external drive (i.e. if it has its own power supply separate from the USB port) into it. In the event of power failure the UPS’s battery will keep your PC running while you or the USB’s bundled software shut down the PC properly. Not so necessary for laptops because you have a built-in battery.
    As a bonus the UPS will provide additional protection to your PC and connected devices in the event of power spikes and lighting strikes.
  • You can change the properties of individual external drives to disable write-caching. Then you may remove or turn off the device without going the “Safely Remove Hardware” route. Caveats:
    • Setting a drive up in this way affects the performance of your computer during the writing process to a greater or lesser degree dependent upon exactly what you’re doing.
    • But it’s safer for data security on external drives.
    • I set my external drives up with “Quick Removal” enabled, but I still use the “Safely Remove Hardware” icon to be on the safe side. I’ve been bitten.
    • XP can be flaky with this procedure and tell you that you can’t remove the drive because it’s still in use. This can happen even when you think writing is finished. In that case leave the drive connected or shut Windows down before removal. Vista is better in this regard and Windows 7 is better still.
  • The whole process is much less hassle on Apple’s Macs and on Linux computers. Usually you just need to right-click on a drive’s icon and select “unmount” to kill the drive.

Go to the next page to find out how to change the drive properties we’ve discussed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s