Jump to content

question about dd


saturnian

Recommended Posts

Guest LilBambi

dd (Unix) - Wikipedia:

 

A block is a unit measuring the number of bytes that are read, written, or converted at one time. Command line options can specify a different block size for input/reading (ibs) compared to output/writing (obs), though the block size (bs) option will override both ibs and obs. The default value for both input and output block sizes is 512 bytes (the traditional block size of disks, and POSIX-mandated size of "a block"). The count option for copying is measured in blocks, as are both the skip count for reading and seek count for writing. Conversion operations are also affected by the "conversion block size" (cbs).

 

For some uses of the dd command, block size may have an effect on performance. For example, when recovering data from a hard disk, a small block size will generally cause the most bytes to be recovered. Issuing many small reads is an overhead and may be non-beneficial to execution performance. For greater speed during copy operations, a larger block size may be used. However, because the amount of bytes to copy is given by bs×count, it is impossible to copy a prime number of bytes in a single dd command without making one of two bad choices, bs=N count=1(memory use) or bs=1 count=N (read request overhead). Alternative programs (see below) permit specifying bytes rather than blocks. When dd is used for network transfers, the block size may have also an impact on packet size, depending on the network protocol used.

 

The value provided for block size options is interpreted as a decimal (base 10) integer and can also include suffixes to indicate multiplication. The suffix w means multiplication by 2, b means 512, k means 1024, M means 1024 × 1024, G means 1024 × 1024 × 1024, and so on. Additionally, some implementations understand the x character as a multiplication operator for both block size and count parameters.

 

For example, a block size such as bs=2x80x18b is interpreted as 2 × 80 × 18 × 512 = 1474560 bytes, the exact size of a 1440 KiB floppy disk.

 

BOLD emphasis mine.

Link to comment
Share on other sites

USB keys are generally more efficient for larger block sizes and run near their rated speed only when writing large blocks of data. Even a high speed USB3 drive is very slow when writing many small files.

 

if you use dd often, you should look at the options for updating the progress while copying.

 

dcfldd is a drop-in replacement for dd that updates the number of records while copying:

 

#dcfldd bs=4M if=file.iso of=/dev/null
3840 blocks (120Mb) written.
4051+1 records in
4051+1 records out

 

Or you can use pipe viewer with dd to get a nice progress bar

 

# pv file.iso | dd bs=4M of=/dev/null
127MB 0:00:00 [2.83GB/s] [==============================================================================>] 100%
0+1013 records in
0+1013 records out
132775430 bytes (133 MB) copied, 0.0438432 s, 3.0 GB/s

# pv file.iso | dd of=/dev/null
127MB 0:00:00 [ 564MB/s] [==============================================================================>] 100%
259327+1 records in
259327+1 records out
132775430 bytes (133 MB) copied, 0.224751 s, 591 MB/s

 

The original method - open another console and type

pkill -USR1 -n -x dd

This gives a single update. You can use watch to get an update every couple of seconds.

 

Jim

Edited by jimg
  • Like 2
Link to comment
Share on other sites

The Gnu Coreutils page says

 

‘bs=bytes’ <a name="index-block-size-1009">Set both input and output block sizes to bytes. This makes dd read and write bytes per block, overriding any ‘ibs’ and ‘obs’ settings. In addition, if no data-transforming conv option is specified, input is copied to the output as soon as it's read, even if it is smaller than the block size.

Bold added by me.

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...