LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Make me understand on dd (https://www.linuxquestions.org/questions/linux-newbie-8/make-me-understand-on-dd-881712/)

fjkum 05-19-2011 09:40 PM

Make me understand on dd
 
Hi,

Can anyone explains to me in laymen term how to deduce the following command:

dd if=/dev/zero of=/swap bs=1M count=1000

Thanks in advance!

corp769 05-19-2011 09:54 PM

Hello,

Are you talking about explaining it? First and foremost, here is the man page: http://linux.die.net/man/1/dd
That will help a lot......

But besides that, by looking at the command, it is saying to take the input from /dev/zero, which pretty much means that the input bits/bytes will be all zeros. The output file /swap is your swap; So from here on out, nothing but zeros are going to your swap space. "bs" stands for blocksize; the blocksize is one megabyte. "count" is how many times recursively it will repeat, so therefore, 1,000 megabytes of "0's" will be written to swap.

Cheers,

Josh

Telengard 05-19-2011 10:10 PM

I don't want to hijack the thread, but this has me a little curious.

Quote:

Originally Posted by corp769 (Post 4361450)
the blocksize is one megabyte

The dd manpage on my system says M 1024*1024. According to Wikipedia the term megabyte can have multiple meanings depending on context. How should one infer the meaning from the context of dd?

Quote:

so therefore, 1,000 megabytes of "0's" will be written to swap
What might be the result of this operation?

John VV 05-19-2011 10:58 PM

my understanding is that a power of 2 is needed
not the advertising company short cut 1024=1000
but
Quote:

1,000 megabytes of "0's" will be written to swap.
is NOT that it is just a number .The repeat could be any real number.

there is a term " read the code"
--- dd if=/dev/zero of=/swap bs=1M count=1000 ---
corp769 has a very good answer

and to shorten it " zero out the SWAP "

Telengard 05-19-2011 11:20 PM

Quote:

Originally Posted by John VV (Post 4361478)
there is a term " read the code"
--- dd if=/dev/zero of=/swap bs=1M count=1000 ---

One thousand blocks of size 1M. The manpage defines 1M, so that's fine. Nowadays I just get a little confused when I see the word megabyte because its meaning is context dependent.

Quote:

corp769 has a very good answer
I won't dispute that.

Quote:

and to shorten it " zero out the SWAP "
Great. Whatever that means :-/

teckk 05-20-2011 01:43 PM

http://www.linuxquestions.org/questi...ommand-362506/

markush 05-20-2011 02:57 PM

Hello,

I found this page very useful: http://www.softpanorama.org/Tools/dd.shtml

Markus

fjkum 05-22-2011 08:54 PM

How do I issue the command to increase the swap size by another 200MB?

John VV 05-22-2011 09:10 PM

Quote:

How do I issue the command to increase the swap size by another 200MB?
that depends if you are using a LVM or standard partition

200 meg will not do much

if you have 4+ gig of ram you might not ever need to use the swap space


without knowing what your system is
How it is set up
or even anything about it
there is NO WAY we can help

katto 05-22-2011 10:14 PM

Quote:

Originally Posted by Telengard (Post 4361491)
One thousand blocks of size 1M. The manpage defines 1M, so that's fine. Nowadays I just get a little confused when I see the word megabyte because its meaning is context dependent.



I won't dispute that.



Great. Whatever that means :-/

What it would do would depend on whether you are using the swap space at the time you issue the command. An empty swap getting filled with zeros will probably do nothing as it is meant to be overwriten when in use. The swap is supposed to be used for things that do not fit in ram for quick access. So, imagine what would happen if you filled your ram with zeros. The same thing would probably happen with the swap, although I think that the really important stuff do not usually get transferred to the swap space. In general, crashes and memory corruption but it would probably not cause any permanent damage. Don't take my word for that last bit however.


All times are GMT -5. The time now is 06:17 PM.