Hardware / Linux : optimize SdCard (nand flash) speed and lifetime

I recently created a new NAS server using a sheevaplug (article to come…) and a 8Gb Sdcard for the system partition.

Maybe you know that partitioning and formatting sdcard should be done carefully to get best speed and lifetime. This require to respect the both erasure block and segment size : this is exactly what I made and what is this article about.

I used the “flashbench tool” from : https://github.com/bradfa/flashbench.


./flashbench -a /dev/mmcblk0  --blocksize=1024


Note that I sometime need top launch it several times to get consistent values (eg: non negative time).
Based on the flashbench author’s explanation, I could find:

  • erasure block : biggest value for which the time become near the double of the previous one. In my case it was 4Mb
  • segment size (block size) : smallest value for which the time become significantly higher than the previous one. For me : 4k

Then, simply calculate all the needed informations to partition with fdisk and format with ext4. I made  an  M$ Excel sheet to define parameters for every SDCard I use (file is attached to this post)… Note that I commented out the file for easier usage… 😉

flash memory settings calculator

Small benchmarks

For Bigfiles :

sync; rm bigfile; sync; time ( dd if=/dev/zero of=bigfile bs=16k count=10000; sync) ; rm bigfile


Before optimization I got : 18.2 and after I had 21.9. Ok, that’s not so much, but look further for small files…

For small files:

sync; rm -rf smallfiles_*; sync; time ( for i in `seq 1 100`; do dd if=/dev/zero of=smallfiles_$i bs=16k count=10; sync; done; ) ; rm -rf smallfiles_*


Before optimization, I got 148 Mb/s and after : 184 Mb/s !

Leave a Reply

Your email address will not be published. Required fields are marked *