Friday, April 15, 2005

hdparm is the stuff!

So I've been doing some forensic work lately and have been tinkering with dd. I found the Operator distro (which rocks) and has the AIR (Automated Image & Restore) frontend for dd. As I was testing various scenarios imaging my laptop over to a windows system via nc, I noticed that with AIR I was moving data at 80Mbit or so. Just doing the straight dd command line it was only running at 22Mbit.

Here is the command line I was using:

dd if=/dev/hda conv=noerror,notrunc,sync | nc xxx.xxx.xxx.xxx xxxx

After much tinkering with the command line, thinking it was possibly some of the "conv" options, it turns out that when AIR starts, it does an "hdparm -d1 /dev/xxx" on all devices it finds. This turns on DMA access which does an amazing job at increasing HD performance. Here is a snippet of the performance changes:

root@Operator:/ramdisk/home/knoppix# hdparm -tT /dev/hda

/dev/hda:
Timing cached reads: 1832 MB in 2.00 seconds = 916.00 MB/sec
Timing buffered disk reads: 8 MB in 3.15 seconds = 2.54 MB/sec
root@Operator:/ramdisk/home/knoppix# hdparm -tT /dev/hda

/dev/hda:
Timing cached reads: 1836 MB in 2.00 seconds = 918.00 MB/sec
Timing buffered disk reads: 10 MB in 3.43 seconds = 2.92 MB/sec
root@Operator:/ramdisk/home/knoppix# hdparm -d1 /dev/hda

/dev/hda:
setting using_dma to 1 (on)
using_dma = 1 (on)
root@Operator:/ramdisk/home/knoppix# hdparm -tT /dev/hda

/dev/hda:
Timing cached reads: 1832 MB in 2.00 seconds = 916.00 MB/sec
Timing buffered disk reads: 110 MB in 3.01 seconds = 36.54 MB/sec
root@Operator:/ramdisk/home/knoppix# hdparm -tT /dev/hda

/dev/hda:
Timing cached reads: 1808 MB in 2.00 seconds = 904.00 MB/sec
Timing buffered disk reads: 100 MB in 3.05 seconds = 32.79 MB/sec


As you can see, quite a difference in the buffered disk reads. This allowed me to run dd from the command line at wirespeed!

It should be noted of course that this is only relevant to IDE systems.

Here is a great link on it... Speeding up Linux Using hdparm

Now I have to make sure that DMA is enabled on all my Linux boxes...

0 Comments:

Post a Comment

<< Home