Grimoire-
Command
.es

GNU+Linux command memo

dd buffer size `bs=`

Importance du réglage de la taille de buffer lors de l’utilisation de la commande dd.

$ sudo dd status=progress if=a_file.iso of=/dev/sdX
1226833920 octets (1,2 GB, 1,1 GiB) copiés, 495,782 s, 2,5 MB/s
$ sudo dd bs=1M status=progress if=a_file.iso of=/dev/sdX
1226833920 octets (1,2 GB, 1,1 GiB) copiés, 138,725 s, 8,8 MB/s

Default dd buffer size is 512 octets.

Most current storage devices have bigger block sizes (such as 4096 octets).

Using a dd bigger buffer size allow speed up transfers avoiding device block size splitting overhead.

In our case we can see that is speed ups transfers by 3.5 times for a 10 years old USB Key capable of writing at 10 Mo/s. For recent NVME SSD storage, I’ve been reported performances from 129 Mo/s to 1,5 Go/s (approx 10x faster).

Some more rigorous test results can be found here : http://blog.tdg5.com/tuning-dd-block-size/

It shows that at a certain extend, using a big buffer size is helpfull, and too big is not harmless, so 1M is a good compromise for the years to come.

In our example case (copying a .ISO on a USB key) the simple cp command is as fast as a good dd setting, and is way faster to type !