Measuring block size of flash

How to measure block size?

This is how I did it on an USB flash memory. The block size was found to be 8 kB, not 4 kB as many claim. Unfortunately, many programs have 4 kB as an upper limit.

So, how did I do it?
By dumping a copy of the flash back to the flash, with different blocksizes, and timing it.

First the flash was read, under Linux as root, like this:

 time dd of=q if=/dev/sdb bs=8k 
That also gives the memory's reading bandwidth, which is always faster than the writing bandwidth, since writing takes time.
Then I copy it back, like this:
 time dd if=q of=/dev/sdb bs=8k 
This example has a blocksize of 8 kB, and /dev/sdb is the USB flash on my machine.

Results:

blocksize seconds time histogram
512 B 2559
1 kB 2514
2 kB 2335
4 kB 2005
8 kB 835
16 kB 772
32 kB 747
64 kB 736
128 kB 750
256 kB 724
512 kB 748
1 MB 793
2 MB 776

The blocksize is obviously 8 kB, since this is the smallest blocksize that gives fast writing. Note that the speedup is about three, so a lot is gained by using this blocksize. Unfortunately, as I said before, many programs and devices have a 4 kB limit, taking about 2.5 times as long.

Other flash memories may have other block sizes and bandwidths.