Safely Remove Hardware

By Wayne Maruna

 

 

I first wrote about flash drives (also known as thumb drives, key drives, or pen drives) back in October, 2004 (http://pages.suddenlink.net/wamaruna/pendrive.html) so they’re not exactly new on the scene. But they’ve certainly had staying power.  These finger-sized devices store data in solid state memory, which means no fragile moving parts.  These devices are generally a safe and easy way to store or transport data.  I carry a 16GB flash drive with me when making service calls.  I consider it to be my ‘toolbox’ in that it contains a long list of program applications and utilities I regularly use to solve problems or enhance a computer’s capabilities.  In fact, flash drives are so handy and relatively inexpensive that I currently own 21 of them ranging in sizes from 512 megabytes up to 32 gigabytes.  You can currently pick up 4GB flash drives for at or under $10 at your local office supply store.  My 32GB stick set me back $35.  But as the drives get larger from that point, they get proportionately more expensive.  You can buy them up to 256GB currently, but that 256GB gem is crazy expensive at a whopping $700, considering that desktop hard drives with four times that capacity can be had for $50.

 

Flash drives have made floppy diskettes obsolete.  It would take 2,777 floppy disks to hold as much data as a single 4GB flash drive.  The dark side of this is that if you lose or damage a 4GB flash drive, it’s the equivalent of losing 2,777 floppy disks.  Flash drives are, after all, electronic devices, so while they are reasonably robust and relatively reliable, they are not indestructible.

 

Since flash drives have replaced floppy disks due to their utility and low price, I see a lot of them in residential settings.  What is obvious, though, is that few people understand the right way to safely handle a flash drive insofar as using them with a computer.  Let me explain.

 

When you read data from a drive, the data gets moved into a bank of system RAM, a very high speed form of memory which is volatile, meaning that when power is removed, the contents of RAM is lost.  That is why we store data on hard drives or flash drives or CDs, all being ‘non-volatile’ forms of storage.  The data held in the bank of system RAM is said to be in ‘cache’ (pronounced just like ‘cash’) because, you know, you should keep your cache in a bank. (Rim shot, please!)  When you make changes to the data you are working on and want to save the data back to the drive, and if the drive is optimized for speed (explained below), the changes are actually first written to the cached image in RAM.  The data is not actually written back to the drive until the system processor gets freed up to take care of it.  This may be nearly instantaneous, or it may be a bit later.  This write to the drive is called a cache flush. (Let’s not even go there.)

 

Now flash drives can be set up in one of two ways.  In the Properties options for the flash drive under My Computer, you can set the drive up to optimize it for speed or optimize it for quick removal.  When a drive is set up to optimize speed, the write stage is performed as above, which allows the processor to work on whatever is of highest priority and attend to the actual flushing of cache to the drive when it gets a chance.  When set up to optimize for quick removal, the write takes place directly to the drive, avoiding the cache, but also somewhat slowing the processor’s opportunity to engage in other activity.

 

I have seen people just pull a flash drive out of its USB port when they were done with it.  Bad idea, unless you know for certain that the drive has been optimized for quick removal.  If the flash drive gets removed before the system has written the data from cache to the drive, there is risk  - relatively low, but there nonetheless - of data loss and potential for the drive to become corrupted.  This is particularly true if the drive is optimized for speed.  To prevent this, Microsoft provides a process called ‘Safely Remove Hardware’.  Down in the system notification tray by the clock in the lower right corner of the screen, you should see a tiny icon representing a flash drive when one is inserted into a USB port.  (In Windows 7, you will likely need to press the small up-arrow to see the icon.)  When you hover your mouse over the icon, a balloon will pop up and say ‘Safely remove hardware’.  If you right-click that, you should see your flash drive itemized.  You can then click that and choose to eject the drive.  This in effect forces a cache flush, i.e. a write to the drive.  If some other program is still using the drive, you will be told that you cannot safely remove the drive and to retry later.

 

Personally, given the risk involved in pulling the drive out before the cached data gets written, I think Microsoft’s choice of icon is underwhelming. If I were the product manager, I’d toss their little USB icons and replace it with a picture of Clint Eastwood as ‘Dirty Harry’ Callahan, and the pop-up balloon would use his famous movie line:  “You've got to ask yourself one question: Do I feel lucky? Well, do ya, punk?"  Far more effective, I think.

 

So the next time you go to remove your flash drive, think of Dirty Harry, consider your options, and act accordingly.