Search code examples
linuxlinux-kernellinux-device-driverdd

Flash devices block size limitation


I have made some experiments with flash memory stick. I played with dd and particulary with bs option. Here are the results i have collected:

 Block size(Kb)            Flash write speed(Mb/s)
      1                             2.5
      2                             3.1
      4                             4.4
      8                             5.0
     16                            ~6.3
     32                            ~6.3
     64                            ~6.3

in the first column you can find values of dd ... bs= ... option. Second column is a flash write speed. Here is the example of dd command i used:

dd if=/dev/urandom of=/media/106E99AE6E998D5A/temp oflag=direct bs=32K

So, from the results i can say that there is some saturation at 16Kb block size. It seems that there is a kind of hardware limitation, and flash can't handle more then 16K in one transaction. (Am i right?) Can anybody explain me this saturation in more details? Thanks.


Solution

  • In order to reduce complexity, flash memory is divided into blocks of a given size. When a write is performed, an entire block must be erased and then written to. Since the erase destroys all data in the block, when a partial write is required the contents must be read into a temporary buffer, combined with the new data, the block erased, and the new data written out. When an entire block is written there is no need to read the previous contents, so writes are faster.

    The device you are examining has 16kiB blocks, and so writes are fastest when performed in an exact multiple of that size starting on a block boundary.