developius
developius

Reputation: 1262

Highest block size for dd command

I want to run dd over a SanDisk 32GB micro SD but I'm not sure how to decide on the block size.

Usually I use bs=1M, but could I go any higher than that?

Upvotes: 3

Views: 7816

Answers (2)

Mark Setchell
Mark Setchell

Reputation: 207425

Try it!

#!/bin/bash
bs=( 32k 64k 128k 256k 512k 1m 2m 4m )
ct=( 32768 16384 8192 4096 2048 1024 512 256 )
for (( x=0;x<${#bs[@]};x++ )); do
   echo Testing bs=${bs[x]},count=${ct[x]}
   dd if=/dev/zero bs=${bs[x]} count=${ct[x]} of=junk
done

Output

Testing bs=32k,count=32768
32768+0 records in
32768+0 records out
1073741824 bytes transferred in 3.094462 secs (346988217 bytes/sec)
Testing bs=64k,count=16384
16384+0 records in
16384+0 records out
1073741824 bytes transferred in 3.445761 secs (311612394 bytes/sec)
Testing bs=128k,count=8192
8192+0 records in
8192+0 records out
1073741824 bytes transferred in 2.937460 secs (365534116 bytes/sec)
Testing bs=256k,count=4096
4096+0 records in
4096+0 records out
1073741824 bytes transferred in 3.247829 secs (330602946 bytes/sec)
Testing bs=512k,count=2048
2048+0 records in
2048+0 records out
1073741824 bytes transferred in 3.212303 secs (334259206 bytes/sec)
Testing bs=1m,count=1024
1024+0 records in
1024+0 records out
1073741824 bytes transferred in 3.129765 secs (343074260 bytes/sec)
Testing bs=2m,count=512
512+0 records in
512+0 records out
1073741824 bytes transferred in 2.908048 secs (369231132 bytes/sec)
Testing bs=4m,count=256
256+0 records in
256+0 records out
1073741824 bytes transferred in 2.996609 secs (358318964 bytes/sec)

Upvotes: 4

Sam Varshavchik
Sam Varshavchik

Reputation: 118300

You could go higher, but it probably won't make any difference. If you go too high, things might actually slow down.

Different SSD devices have different performance profiles. There is no universal, ultimate, answer that's right for every SSD device that exists in this entire world.

The only way to get the right answer is to experiment with various block sizes, and benchmark the performance.

Upvotes: 0

Related Questions