Re: Question about a ' dd ' command.
- From: elmo <elmo@xxxxxxxxx>
- Date: Fri, 07 Mar 2008 20:19:44 -0500
Peter Garrett wrote:
On Fri, 07 Mar 2008 17:20:03 -0500Thanks all.. I'm beginning to get the picture and feel more comfortable
elmo <elmo@xxxxxxxxx> wrote:
I read somewhere that these two commands are special application of the
basic 'dd' command that will copy and display the transfer action.
Yes - but these two lines are just an illustration that lasts slightly
more than a second, and does nothing harmful. It just sends a lot of zeros
to nowhere - /dev/null is a useful black hole ;-)
$ dd if=/dev/zero of=/dev/null& pid=$!
$ kill -USR1 $pid; sleep 1; kill $pid
I don't understand the null& and pid=$! in the first line
Attempted explanation follows... The lines you quote are just intended as
an example, as you will see.
$ dd if=/dev/zero of=/dev/null
"Send zeros to the bit bucket" ( that is, to nowhere, if you prefer)
& : Put the previous command in the background.
pid=$! : Store the process number identifying the "dd" process in a
variable named "pid" so we can use it later to send signals to the process.
In this case, the signal " kill -USR1 $pid" tells "dd" to output some
information about what it is doing. See "man signal" ( "kill" doesn't
always mean destruction, in Bash !)
; semicolon divides one command from the next on the command line.
sleep 1 ; Do nothing for one second
kill $pid : Kill the actual process.
Output here looks like this:
$ dd if=/dev/zero of=/dev/null& pid=$!
[1] 16690
$ kill -USR1 $pid ; sleep 1 ; kill $pid
42209510+0 records in
42209510+0 records out
21611269120 bytes (22 GB) copied, 56.7523 seconds, 381 MB/s
As you see, I let it run for nearly a minute.
The alarming-looking 22 GB actually went nowhere, as explained above.
and I don't
understand any of the second line. There doesn't seem to be any
explanation of these anywhere. It appears to me that the writer used
some notations that can be confusing to other guys like me,
Yes, true that it is confusing if you don't already know.
Have a look for example at
http://tldp.org/LDP/abs/html/
For more information.
Is there a more complete discussion of these commands somewhere?
Could someone please show me what the commands
would look like if the simple basic version of ' dd 'is:
dd if =/dev/sda2 of=/dev/sdc3 bs=4096
If you wanted to see periodic information during the process, you could
append "&" without the quotes, to that line, as in the example, and assign
the pid with pid=$!
dd if =/dev/sda2 of=/dev/sdc3 bs=4096 & pid=$!
Then every now and then run
kill -USR1 $pid
The final "kill" after the "sleep" would not be good move, unless you
wanted to stop the dd process, which you probably don't want to do. You
could also stop the "kill -USR $pid" command for example with ctrl+c - the
dd command is by then already in the background ( & ) , so it continues to
completion unless specifically killed with " kill $pid"
dd is powerful and low level, so experiment at your own risk! That's why
the commands used /dev/zero as input and sent them to /dev/null - that's
harmless. If you make a slight error using dd, though, disastrous things
can happen silently ( say, overwriting your whole partition with zeros
unintentionally, and so on. )
Peter
about digging into the references you
mentioned. Now why couldn't the author have taken a few seconds to
supply just a little more clarification?
elmo
--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
- References:
- Question about a ' dd ' command.
- From: elmo
- Re: Question about a ' dd ' command.
- From: Peter Garrett
- Question about a ' dd ' command.
- Prev by Date: OT: Ubuntu on Lenovo G400
- Next by Date: cdrom/dvd drive & hdparm
- Previous by thread: Re: Question about a ' dd ' command.
- Next by thread: need help with ossec
- Index(es):
Relevant Pages
|