LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Please explain how dd works and what it does (https://www.linuxquestions.org/questions/linux-newbie-8/please-explain-how-dd-works-and-what-it-does-392225/)

ohovus 12-13-2005 02:04 AM

Please explain how dd works and what it does
 
Hello All,

dd if=/dev/zero of=/dev/hda bs=446 count=1;reboot
I know above command wipe out MBR, but how it works?
dd if=/dev/zero of=myfile bs=1M count=5
This creates 1mb file but then how it works please
explain, I am a newbie who want to learn.
Thanks,
Ohovus

[NL]_Target 12-13-2005 06:34 AM

dd if=/dev/zero of=/dev/hda bs=446 count=1

To my understanding (I'm not 100% sure) this writes out exactly as much data as the MBR is large, so effectively wiping it out. /dev/hda means the 'disc' A. This is different than for example /dev/hda1, which would be the partition. /dev/hda is the raw disk, and when you write this ammount of data to it it wipes out the MBR, cause these are the first couple of blocks on that file. /dev/zero is, as the name suggests, a file that contains only 0's :-).

I hope this helps you out, if anyone has a better explanation, I'd be very interested to learn about it.

Greets, Target

pixellany 12-13-2005 08:19 AM

Have you read the man page on dd? In particular, understand the count, seek and skip commands.
Does anyone know for a fact that /dev/zero makes all "0"s? I've never seen this before.

Generically, dd moves blocks of data from point a to point b without regard for filesystems and formatting. Powerful, but dangerous.

i will post an excellent tutorial if I can find it.

nx5000 12-13-2005 08:45 AM

Code:

dd if=/dev/zero of=/dev/hda bs=446 count=1;reboot
This is a dangerous command!!

Yes /dev/zero is outputing zeros. See
Code:

cat /dev/zero > u
Interrupt the command just after pressing enter, otherwise your disk can be full very quickly

And display the file in hex:
Code:

od -x u
There is a very good tutorial by a poster on linuxquestions, use the search.

pixellany 12-13-2005 08:48 AM

Quote:

Originally Posted by nx5000
There is a very good tutorial by a poster on linuxquestions, use the search.

I just posted a link to it


All times are GMT -5. The time now is 07:45 AM.