dd disk transfer performance
For the second time this year, I had a disk crash. I am getting smarter about making backups. Not as good as I should be, but better.
So, to make a complete backup, I made copies of the disk partitions by using dd to write to our family server. Well that took a long time over the net, but it did it.
I got smart and deleted the network for the install by bringing the USB drive on the server to my computer. However, that was still slow. It was taking hours to move the data over USB to the SATA drive in my computer. So, I began thinking about block-sizes. Why do we always use 512 byte blocks? Seems that is rather archaic since the drives are much faster than they were 30 or so years ago when dd was first created. The OS and the disk controllers will have some optimum performance. So, I did some timing with various values of block sizes, the actual command that I ran was: dd if=copy_sda4 of=/dev/sda2 bs=XXX
| Blocksize | Rate in MB/s |
|---|---|
| 512 B | 7.9 |
| 1 KB | 8.4 |
| 2 KB | 37.8 |
| 4 KB | 32.6 |
| 8 KB | 32.8 |
| 16 KB | 32.8 |
| 32 KB | 32.8 |
| 64 KB | 32.9 |
| 128 KB | 32.9 |
| 256 KB | 32.9 |
| 512 KB | 32.9 |
| 1 MB | 32.8 |
| 2 MB | 32.7 |
| 4 MB | 32.0 |
So, for my USB and SATA setup had the best performance at 2KB. Your mileage may very.
Here this code I used to capture the data.
Here this code I used to capture the data.
#!/bin/bash
size=( 512 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M 2M 4M )
for i in ${size[@]:0} ; do
(dd if=jbriner_sda4 of=/dev/sda2 bs=$i ) & ddPid=$!
echo Blocksize set to $i for $ddPid
sleep 60
sync
kill -SIGUSR1 $ddPid
sleep 4
kill -SIGHUP $ddPid
sleep 2
done
Labels: backup, disk, performance






