1821244 Members
2731 Online
109632 Solutions
New Discussion юеВ

DD Command

 
P Arumugavel
Respected Contributor

DD Command

Hi Experts,

# dd if=/dev/rdsk/c0t1d0 of=/dev/null bs=1024k count=64 &

What is happening behind the above command?

Output1:
64+0 records in
64+0 records out

What info the above/below output give?

Output2:
dd read error: I/O error
0+0 records in 0+0 records out

Thanks in advance...
10 REPLIES 10
Hakki Aydin Ucar
Honored Contributor

Re: DD Command

dd is a common Unix program whose primary purpose is the low-level copying and conversion of raw data. dd is an abbreviation for "dataset definition" in IBM JCL, and the command's syntax is meant to be reminiscent of this.[1] dd is used to copy a specified number of bytes or blocks, performing on-the-fly byte order conversions, as well as more esoteric EBCDIC to ASCII conversions.[2] dd can also be used to copy regions of raw device files, e.g. backing up the boot sector of a hard disk, or to read fixed amounts of data from special files like /dev/zero or /dev/random.[3]

Some Useful Examples ;

dd read test :
dd if=/dev/dsk/cxtydz of=/dev/null bs=256k

convert a text file to UPPERCASE:
# dd if=/aydin/jokes.txt of=x conv=ucase
0+1 records in
0+1 records out

Divide a file to reduce size to edit by copying 10 blocks only:
# dd if=input_file of=/tmp/output_file.1 count=10

Divide a file to reduce size to edit by skipping first 10 block and copying 10 blocks only:
# dd if=input_file of=/tmp/output_file.1 iseek=10 count=10
SoorajCleris
Honored Contributor

Re: DD Command

Hi,

Output1:
64+0 records in
64+0 records out

==> This says, at the end of the command, this was the result ( even if you interrupt , it gives) this many records were read from the input file to output file.

What info the above/below output give?

Output2:
dd read error: I/O error
0+0 records in
0+0 records out

There was an I/O error and it could int read from the source. If your input file was a disk , the error may come because of disk read error.
We use this command to check the integrity of disk. Remember this command may hang if there is serious problems with the disk.

Regards,
Sooraj
"UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity" - Dennis Ritchie
P Arumugavel
Respected Contributor

Re: DD Command

# dd if=/dev/null of=/dev/rdsk/c0t1d0 bs=1024k count=64 &

What could be output of above command.
Will this command check the I/O func of /dev/rdsk/c0t1d0 ?
Torsten.
Acclaimed Contributor

Re: DD Command

As you say, the output could be

Output1:
64+0 records in
64+0 records out

64 records are successfully read and written;

Output2:
dd read error: I/O error
0+0 records in 0+0 records out

there was an I/O error when reading the disk.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Hein van den Heuvel
Honored Contributor

Re: DD Command



> What could be output of above command.

The main output is discarded, send to the big bit bucket in the sky (null device)

A detailed success or error message will go to stderr, as you have shown

>> Will this command check the I/O func of /dev/rdsk/c0t1d0 ?

Yes, partially.

It will test that the first 64 MB of the selected raw device can be read.
That tests 99% of the circuitry ( driver, hba, controller, cabling, drive electronics.)
It tests wll less than 1% of the total data and only tests reads, no writes.

cheers,
Hein
Patrick Wallek
Honored Contributor

Re: DD Command

>># dd if=/dev/null of=/dev/rdsk/c0t1d0 bs=1024k count=64 &

>>What could be output of above command.

>>>The main output is discarded, send to the big bit bucket in the sky (null device)

Look at his command closer! He is taking /dev/null as the INPUT as using /dev/rdsk/c0t1d0 as the OUTPUT device.

What this will do is OVERWRITE the first 64 MB (1024k x 64 times) of the disk with NULLs. If this disk is not in use, then maybe this is OK. If this disk is in use, you just killed it as you overwrote all of the VG configuration.
Torsten.
Acclaimed Contributor

Re: DD Command

Good catch Patrick.

In the first post it is

# dd if=/dev/rdsk/c0t1d0 of=/dev/null bs=1024k count=64 &

but in the second

# dd if=/dev/null of=/dev/rdsk/c0t1d0 bs=1024k count=64 &

(this will write to the disk and destroy data!)



This could be related to this thread
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1453526


;-)

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Hein van den Heuvel
Honored Contributor

Re: DD Command

Patrick, Thanks for the correction.
Our anonyous friend change the rule on me!
Now I understand the question better... I thought it was a repeat/rephrase.
But apparently he/she moved to the next questions in the homework assignment.

But while were are correcting....

Patrick>># dd if=/dev/null of=/dev/rdsk/c0t1d0 bs=1024k count=64 &
Patrick>> What this will do is OVERWRITE the first 64 MB (1024k x 64 times) of the disk with NULLs.

I beg to differ with the follow up comments.
The command will read EOF right away and copy 0 records.
The next question is likely about "if=/dev/zero". That woes provide an infinite suppy of zeroes as you refer to, but "null" does not.

So I think nothing will happen to the output, as the input fails, but I am in no rush to try verify this on anything but a play system :-)

Hein
Patrick Wallek
Honored Contributor

Re: DD Command

Hi Hein,

I believe you may be correct. I just did the following:

$ dd if=/dev/null of=test bs=1024k count=64
0+0 records in
0+0 records out

So, yes when 'dd' receives the first 'null' it exits, though it did create the 'test' output file with a size of 0.

How would this affect an actual disk device though.... Good question. It very well may not do anything to harm the disk. But like you I do not want to try it.

If the command were to use /dev/random or /dev/zero, then you would overwrite data on the disk.

bullz
Super Advisor

Re: DD Command

U can find more information in the below link.


http://www.brandonhutchinson.com/Mirroring_disks_with_DiskSuite.html