Re: bs on dd

Bart Trojanowski <[email protected]>
Newsgroups gmane.user-groups.linux.ottawa.general
Message-ID <[email protected]>
On Wed, Jun 15, 2011 at 15:28, Jean-Francois Messier <[email protected]> wrote:

> If I use the dd command to create the image of, say, a USB disk, and use
> bs=2048, for example, can I use a different value when writing to
> another USB disk, or should I keep the same value for both reading and
> writing ?
>

You can set this value to whatever you wish.  It will only impact
performance, if it's too low.  The writes to disk may be done in smaller or
larger chunks at the whim of the block layer and the file system.

If you use oflag=direct, it will force writes out to disk in a synchronous
manner using the block size your have requested.  This usually hurts
performance of writes.

If you don't use oflag=direct, then you really don't have to play with block
size... let the file system decide what's best.

Also, the value I used above, 2048 is for blocks of 2K. Can I imprive
> the performance using, say, values that would be higher like 1048576 or
> 1M, or other ?
>

Larger blocks tend to improve performance, but there will be a point at
which that diminishes (probably around 4 megs).  The smallest block size you
should be using is 4k, since that's the size of a page in your system
(unless you're running Alpha or Sparc).

You can also say "bs=2k" instead of 2048, or something like

dd bs=$((0x1000))

if you prefer to specify it in hex, or

dd bs=$(( 4 * 1024 * 1024 ))

if you need to calculate something.  This is not dd related, but a shell
computation.

-Bart
-- 
OCLUG general discussion list
[email protected]
http://oclug.on.ca/mailman/listinfo/oclug
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.