dd flag - choosing appropriate block size
Lennart Sorensen
lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Mon Sep 8 14:50:48 UTC 2008
On Sun, Sep 07, 2008 at 03:09:18PM -0400, D. Hugh Redelmeier wrote:
> That is a google cache page of an AIX manpage. I don't blame you for
> not reading the pathetic Linux (GNU) manpage.
>
> Blocksize only matters for "special files": rawish I/O devices. Most
> other I/O goes through the buffer cache and thus essentially
> eliminates any blocksize effect other than performance.
>
> Performance: the larger the block size, the fewer system calls that
> are made. bs=1 means there will be a couple of system calls for each
> byte. bs=1024 will cut that down by a factor of 1024. But you can
> take that too far, tying up too much RAM in the dd process.
>
> Disks these days have a raw blocksize of 512 bytes (if I remember
> correctly). Linux filesystems often impose a larger blocksizes in some
> sense (1k or 4k are typical). Possible senses: allocation units,
> transfer units, "extents".
>
> In really raw devices, blocksize matters. In UNIX, there were /dev
> entries for raw disk drives (they were "character" devices) but Linux
> doesn't do that. I think all disk accesses go through the buffer
> cache.
>
> Blocksize matters in some kinds of tape drives. Hardly anyone uses them
> anymore.
>
> Overlap is tricky. But most people never overlap copies. Why would
> you? I'm assuming I understand what is meant by overlap:
> dd if=/dev/sda1 of=/dev/sda1 skip=1
> or
> dd if=/dev/sda1 of=/dev/sda1 seek=1
> This doesn't seem very useful.
> Accidental case:
> dd if=/dev/sda of=/dev/sda1
> Again, not useful.
>
> In most cases, bs=10k or bs=100k ought to be harmless and might improve
> performance. I have not tested if this results in observable improvements
> on current hardware. An exercise for the reader.
I tend to use 128k since that happens to be the maximum transfer size of
most IDE/SATA drives I have seen.
--
Len Sorensen
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list