LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-19-2011, 09:40 PM   #1
fjkum
Member
 
Registered: Feb 2006
Posts: 38

Rep: Reputation: 15
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!
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-19-2011, 09:54 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
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
 
2 members found this post helpful.
Old 05-19-2011, 10:10 PM   #3
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

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

Quote:
Originally Posted by corp769 View Post
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?
 
Old 05-19-2011, 10:58 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,015

Rep: Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454
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 "
 
1 members found this post helpful.
Old 05-19-2011, 11:20 PM   #5
Telengard
Member
 
Registered: Apr 2007
Location: USA
Distribution: Kubuntu 8.04
Posts: 579
Blog Entries: 8

Rep: Reputation: 147Reputation: 147
Quote:
Originally Posted by John VV View Post
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 :-/
 
Old 05-20-2011, 01:43 PM   #6
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 1,850

Rep: Reputation: 234Reputation: 234Reputation: 234
http://www.linuxquestions.org/questi...ommand-362506/
 
1 members found this post helpful.
Old 05-20-2011, 02:57 PM   #7
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Hello,

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

Markus
 
Old 05-22-2011, 08:54 PM   #8
fjkum
Member
 
Registered: Feb 2006
Posts: 38

Original Poster
Rep: Reputation: 15
How do I issue the command to increase the swap size by another 200MB?
 
Old 05-22-2011, 09:10 PM   #9
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,015

Rep: Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454Reputation: 2454
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
 
Old 05-22-2011, 10:14 PM   #10
katto
Member
 
Registered: Nov 2010
Distribution: Kubuntu 10.4
Posts: 46

Rep: Reputation: 16
Quote:
Originally Posted by Telengard View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to make sure I understand cvsup and stuff Geocritter *BSD 2 02-03-2006 07:53 AM
How to make and understand RPMs wjleon Linux - Newbie 2 04-19-2005 08:46 PM
How to make rule for make install and make uninstall melinda_sayang Programming 1 06-14-2004 05:58 AM
How do I make my shared loader (ld-linux.so.1/ld.so) understand LD_PRELOAD? ic3 Slackware 1 11-02-2003 06:57 AM
make dep,make clean,make bzImage problem Babba Linux - Newbie 2 01-08-2003 03:49 AM


All times are GMT -5. The time now is 10:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration