1754964 Members
2993 Online
108828 Solutions
New Discussion юеВ

command dd

 
Feljav
Frequent Advisor

command dd

What is the meaning of these commands:
dd if=/dev/rdsk/c0t1d0 of=/dev/null bs=8192
and
dd if=/dev/zero of=/dev/rdsk/c0t1d0 bs=1024 count=1000?
4 REPLIES 4
Jeff_Traigle
Honored Contributor

Re: command dd

First one reads 8kB blocks from /dev/rdsk/c0t1d0 and writes them to /dev/null (i.e. writes them nowhere). Typically used to validate there are no bad blocks on the disk.

Second one writes 1000 1kB blocks of zeros to device /dec/rdsk/c0t1d0.
--
Jeff Traigle
James R. Ferguson
Acclaimed Contributor

Re: command dd

Hi:

> dd if=/dev/rdsk/c0t1d0 of=/dev/null bs=8192

...reads the raw disk device in blocked reads of 8192 characters and writes what is read to the "bit-bucket". This is a common way to test a disk device to see if it can be read and/or can be read without errors.

> dd if=/dev/zero of=/dev/rdsk/c0t1d0 bs=1024 count=1000

...reads an infinite stream of zeros, writting them in blocks of 1,024 to the disk device shown. After 1,000 writes, the command quits. This is a common way to erase (some) disk information.

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: command dd

Note that the man page for dd will be of some help here.

if=INPUT_FILE
of=OUTPUT_FILE
bs=BLOCKSIZE

However, the bs= values are extremely small and except as a small test, should not be used. The bs= value can have a suffix k in order to represent much larger values. The following will read all the tracks on a given disk at full speed:

dd if=/dev/rdsk/c0t1d0 of=/dev/null bs=512k

However, the second command should be considered very dangerous. As mentioned it writes zeros on the disk. What this really means is that it destroys all the files and directories on that specific disk with no possible way to fix the destruction.


Bill Hassell, sysadmin
tkc
Esteemed Contributor

Re: command dd

This is a good command to run a read-only test on the physical hard disk. If there is a bad block on the disk, the output will not complete and will give 'I/O error'. If you put a 'time' command before the dd, you can also test the I/O performance of that device with the different specified block sizes. A calculation of how many I/O or MB over the time it took to complete the command will give you the I/O performance of the disk in IO/sec or MB/sec.