dd 命令的最大块大小

Highest block size for dd command

我想 运行 dd 通过 SanDisk 32GB micro SD 但我不确定如何决定块大小。

通常我使用 bs=1M,但我可以更高吗?

你可以涨得更高,但这可能不会有任何不同。如果你走得太高,事情实际上可能会变慢。

不同的 SSD 设备具有不同的性能配置文件。没有适用于整个世界上存在的每个 SSD 设备的通用、最终、正确的答案。

获得正确答案的唯一方法是试验各种块大小,并对性能进行基准测试。

试试吧!

#!/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

输出

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)