Saturday, January 5, 2008

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


BlocksizeRate in MB/s
512 B7.9
1 KB8.4
2 KB37.8
4 KB32.6
8 KB32.8
16 KB32.8
32 KB32.8
64 KB32.9
128 KB32.9
256 KB32.9
512 KB32.9
1 MB32.8
2 MB32.7
4 MB32.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.

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


0 comments:

CrossLoop

About Me

My Photo
Jack Briner
I'm a Texan who is living in South Carolina. I love living in Charleston with its history and proximity to the water. I'm married to a Lutheran pastor. We have two teenagers and two dogs.
View my complete profile

Some of my sites