Into the Void


Safely Remove Hardware?!!

Posted in Tech by Scott Baldwin on the June 5th, 2006

Everytime you plug in your USB Flash drive, Windows will mount (i.e., attach) the file system it contains to a drive letter such as E:\, F:\, G:\, etc..  An icon will then appear in the system tray that gives you the option to “Safely Remove Hardware”.  Sometimes however, the device is still in use when you try to safely remove it, and you have to wait and try again.

So you wait.  You try again… still in use.  You wait some more, and try once again… still in use!  In the peak of your frustration, you yank the drive out anyway… then out of curiousity you put it back in.  What’s this?… all your files are still there, perfectly in tact and unharmed.  After months of doing this without consequence, you start to think that safely removing hardware is something that paranoid idiots do for fun.

Well, one of my friends thought the same thing until the other day when about 99% of his file system got corrupted!…  Take a look at what he saw the next time he plugged it in:

More corrupt than a politician!

This drive was formatted with a FAT file system.  FAT (file allocation table) file systems have an index that keeps track of where all the files are located in the logical address space of the device’s memory.  What caused the corruption is that my friend removed the drive while Windows was writing to this index, messing up its pointers and data structures.  The files are still there, but they are lost due to the corrupted FAT.

It’s normally possible to use special file recovery software to recover the lost files, but doing so can be difficult and unreliable.  Using a journaling file system (such as NTFS or EXT3) instead of FAT would have likely avoided the corruption altogether, but fewer operating systems have native support for those file systems.  The good news for my friend is that even though his files are lost, the drive itself is perfectly fine and just needs to be reformatted.

The moral of this story is to always safely remove your Flash and external hard drives, especially if you have written anything to them.  You should do the same with your Wi-Fi cards, MP3 players, and anything else that exchanges data (so pretty much everything).  As my friend will tell you, it’s better to be safe than sorry.

Comments are closed.