Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

As I understand it wear-leveling on USB-sticks / Flash-drives will:

  • help to make the last longer. (reduce the "wear-out", that a physical flash cell can only be writen to XX times)
  • can only really work if there is unused flash-memory cells to switch to. (The more filled the USB-stick is, the less alternative cells to level the wear out are there)

In worst case at one point of time I have used up all and every memory of the USB-Stick. Then it is less likely that some wear leveling can happen still. Can/(How would) I revert this state?

I mean in terms of USB-sticks what is empty

0000 0000 0000 0000 (zero fill) seems to me just to be as valid a data as
1111 1111 1111 1111 or 1010 1110 0011 1111 or any other bit-pattern.

The firmware of the Usb-stick needs somehow to know what is considered an "unused" Flash-cell, so that it can use it for wear leveling again. But after I have one-time eventually filled the whole USB Stick I have trouble to see how the firmware will be able to determine what data can be "overwriten" since it is not containing data?

So my question is: Can zero-filling be a way to reset the wear-leveling a USB-Stick

Allthough I fear that maybe this will often depend on the implementation ("firmware" and "manufacturer") I still think there could be a logic to this approach to assume that "zero-filling" can be reseting the usb-stick on certain -better designed- Usb-Sticks.

The logic I imagine would be, that the firmware's wear leveling would recogize that an entire block (i.e. 512bytes or 2kbytes) would be set to only zeros.

Block before: 1101 1011 1000 0010 ... 0001 0011
Block after: 0000 0000 0000 0000 ... 0000 0000

When I read from this Block I would like to receive of course this information:
Block after: 0000 0000 0000 0000 ... 0000 0000 But this information could be generated on the fly by storing that Block XYZ= empty in a certain flash cell only available to the firmware.

If this would be the case the pool when "reset" (by zero-filling) would be enabled to serve for other purposes, since the information is stored in the BLOCK XYZ=empty firmware memory part of the stick.

I have read that there should be some USB-sticks that have such a firmware and hence can be reset? Can this be true? I would like to know by the question a "tendency" maybe backed up with information from prominent manufacturer. Maybe there exists even a list that lists USB-sticks which can be reset in this way. So that the answer could contain a link to such a list.

Also I assume that there is not "a new firmware" designed by each USB-Stick produced and maybe there is a prominent(often used) USB-firmware that does such a wear leveling. So then the quesiton could be answered with respect to that firmware.

At best there some smart person could come up with a way to answer the question in that form that it contains some instructions that enabled us users (of super-user) to "find out" if this wear leveling is enable or not.

some background to my question

USB-sticks / Flash-drives are a nice things sure. But the problem is that the way they store the data wears out, which means after only XX Writes to a data cell !BINGO! your Stick is dead!

A way to aliviate the problem (that Flash memory cells can only be writen to quite small number of times) is "wear leveling". Which will care that -if possible- the data is not always writen to the same flash memory cells.

The way that works is that instead of writing the data always to the same physical cells the data (when changed) is writen to some other new physical cells. This reduces the "stress" because in best case this will go on like this.

To help understand some basic of wear leveling I included this concept below, which shows how the information of "hello","salut","hola" and "hi" is subsequently stored in a logical data cell named data, which is actually writen to a different physical flash memory each time (hence a small "concept" of wear leveling).


state 1:
[CELL1: e-m-p-t-y] [CELL2:e-m-p-t-y] [CELL3: e-m-p-t-y]


=> write data "hello"


state 2:
[CELL1: hello]     [CELL2:e-m-p-t-y] [CELL3: e-m-p-t-y]
 data=CELL1

=> update data to "salut"


state 3:
[CELL1: hello]     [CELL2: salut]    [CELL3: e-m-p-t-y]
 data=CELL2

=> update data to "hola"

state 4:
[CELL1: hello]     [CELL2: salut]    [CELL3: hola]
 data=CELL3

=> update data to "hi"

state5
[CELL1: hi]     [CELL2: salut]    [CELL3: hola]
 data=CELL1 


Observe how after writing 4 times data each cell in average was only writen 1.33 times. Also observe that the information which cell contains the "logical data" is to be also stored and updated (which requires the firmware to do this accounting -using some reserved memory for this also)

share|improve this question

3 Answers 3

Some flash drives can check if written data is all zeroes and just unmap that region instead of programming flash memory. Though I don't know how common it is.

Currently I am working at MMC controller (can't tell you whose, this is a secret :-) ) and its firmware checks data content, not on write, but later during erase and GC. It unmaps all found zero regions.

As to how to

"find out" if this wear leveling is enable or not.

You can try to compare reading speed of previosly written zero-filled data block and random-filled data block (better to poweroff you drive after write to avoid cache using). If your flash drive checks content of incoming data and just unmaps written region, then reading this region should be much faster because controller can skip actual reading from flash (which is a long operation).

share|improve this answer
    
Since a 2k block (which seems to be a common unit of size for a block) of data can be all zeros the could be reduced in a way that might resample TRIM and the information (even all zero is information) can be stored in a 1byte infomration else in memory. Those "zero" blocks could be used for wear-out cycling. Of course the block cannot be used for data writing as this else would virtually increase the memory and fail once the blocks again are filled with data. But the logik to special trade a certain patter ("all zero is just one pattern in 2k") it could be used to boost wear-out-protection. –  humanityANDpeace Jan 30 at 8:04

But after I have one-time eventually filled the whole USB Stick I have trouble to see how the firmware will be able to determine what data can be "overwriten" since it is not containing data?

TRIM is meant to solve this problem, by providing a mechanism where the OS can tell the drive that it's not expecting a sector to hold data. TRIM is an SAS/SATA spec and not a USB spec, so this doesn't work for USB flash drives, unfortunately.

Without TRIM, it's not safe for the drive to assume data is not needed.

Can zero-filling be a way to reset the wear-leveling a USB-Stick

Sure, if the firmware works this way. No way to know for sure without the firmware's source code or developer documentation. Flash chips work in pages and blocks. The chip can erase only entire blocks at once (128KB e.g.), which consist of many pages (2KB e.g.) which are usually larger than traditional hard drive sectors whch USB drives emulate (512 bytes).

Maybe there exists even a list that lists USB-sticks which can be reset in this way. So that the answer could contain a link to such a list.

It's very likely, given that USB flash drives are dirt cheap these days, not really worth it to the manufacturer to provide this information.

Also I assume that there is not "a new firmware" designed by each USB-Stick produced and maybe there is a prominent(often used) USB-firmware that does such a wear leveling. So then the quesiton could be answered with respect to that firmware.

Each USB flash drive has a microcontroller (microcontroller = CPU + ROM or firmware). You can open the flash drive up and search based on the numbers on the chip to try to find out the type. There are probably a limited number of these compared with the total number of flash drives produced, but it wouldn't surprise me that there'd be very many variations of a few core types. Certainly there isn't any single standard firmware or anything like that.

There are chip utilities that let you reprogram the microcontroller on some of these to create virtual CD-ROMs and such on certain types of flash drives. This is a wildly undocumented area and hard to find information on. I haven't had much luck.

But the problem is that the way they store the data wears out, which means after only XX Writes to a data cell !BINGO! your Stick is dead!

Nope, just that cell. SSDs (and SD cards and flash drives) are overprovisioned, meaning they have more flash than advertised on the package. This extra flash is used as a "spare" area to cover blocks that wear out. It also covers manufacturer defects - no flash has 100% guaranteed working blocks except for the first block.

share|improve this answer
    
In your last paragraph you say "Nope, just that cell." ... before you state that the most flash/USB memories sticks work on 2k Blocks. What do you mean by cell. loss of 1 byte (=1 cell) or loss of 2k bytes (=1 cell = 1 2kblock)? Besides I think you state much truth sticks are not really user-distinghisable to their quality and hence smarter solutions like some sort of TRIM or else zero-field resetting technique (as stated in another answer) is not incentivated... –  humanityANDpeace Jan 30 at 7:58
    
Well, only one byte in the page might be bad (i.e. it won't flip back to 1 when erased), but since algorithms likely work on the page or even block level it results in the effective loss of the page or block. –  ultrasawblade Jan 30 at 14:15

USB storage is neither mechanical (like the early beads on a grid) nor magnetic (like on tape) nor optical (like CDs) but electrical. Consider each location as a small battery cell that over time (a long time) discharges. All writing causes degradation. Zero filling will only make matters worse. The chip itself either has a controller that uses wear levelling or it does not - a user can't change this. In simple terms, wear levelling just ensures that different parts of the USB get a fair share of the storage requirement burden.

share|improve this answer
    
thank you. I cannot understand why you explain to me that it is not mechanical/magnetic? (My question surely was not as dumb as to provoke I would not know this already). The question is actually about the specifics of the "wear leveling" and how a zero-fill (assuming a certain firmware) would indeed be able to reset the device. I just cannot accept that once writen to all blocks a stupid "wear-leveling" would never recover. Hence I think there must be something like a "TRIM" or reset (via zero-fill) for "good Usb-sticks" –  humanityANDpeace Jan 13 '13 at 12:14
    
@humanityANDpeace Whether 1 or 0 is like Yes or No answers to 20 Questions – they use up ‘lives’ equally. Re taking you for an idiot, please note that answers here are intended to be of potential use to many more that simply the one who asked the question. But life can be extended by ensuring the USB device is powered up often enough. –  pnuts Jan 13 '13 at 12:26
    
thank you for explaining the part (that questions are intented for a broader audience) and I am sorry I took it wrong. Indeed I really enjoy that there has been at least an attempt to answer the question. Is this "power USB on often" related to the "height increases flash-cell lifetime" issue, or how did you mean it? thanks –  humanityANDpeace Jan 13 '13 at 18:02
    
@humanityANDpeace Apologies for delay. I am not sure what you mean by "height increases flash-cell lifetime" and feel in any case that does not really address the OP (nor indeed did my comment about powered up often enough - but that makes the digression worse). Maybe start again with a new posting? –  pnuts Mar 13 '13 at 18:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.