shredding files on a flash drive

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Fri Jan 18 17:51:23 UTC 2008


On Thu, Jan 17, 2008 at 08:20:03PM -0500, D. Hugh Redelmeier wrote:
> I was using sneakernet to transfer confidential files.  In particular,
> I put them on a "USB key" flash memory.
> 
> That got me thinking.  I would like to remove those files from the USB
> device.  How can I do that?  As I understand it, flash memory devices
> use "wear leveling".  I think that this is done by always writing to a
> new physical flash block, leaving the old physical block fallow until
> its turn comes.
> 
> This means that shred(1) won't do the job unless it is told to
> rewrite a great number of times, something that is quite hard on flash
> units.  It isn't even clear that we could guess what that number would
> have to be.
> 
> (It is likely that shred would also not work on a journalling file
> system.)
> 
> Any recommendation?  Perhaps one should never consider a flash device
> cleaned.

Well you could fill the device with a file (or multiple) containing all
zeros.  That would at least fill all the free space with data which you
could then delete.

That still leaves whatever percentage of spare blocks the device has as
a potential place to still have valid data that you intended to delete,
although I believe most if not all flash devices will erase the spare
blocks whenever they are not in use since that way they are pre erased
and ready for use when needed.  flash memory has to be erased to all 1s
before you can write to it (by changing some of the bits to zeros), at
least on the types of flash memory I have looked at.  erase is done by
block, and it would make sense to issue an erase on a block whenever it
is no longer being used as a current block in the flash.

So I believe this means that if you will the flash after deleting your
file, then every block will have been overwritten or erased.  If your
overwrite file happens to contain all 1s (0xFF) then it should even
avoid causing excess writes to those blocks since you are not actually
changing their contents away from the erased state.

--
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list