LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-26-2011, 02:32 PM   #1
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Rep: Reputation: Disabled
Cloning Hard Drives with "dd"


I'm new to Linux Questions and I have a question about cloning hard drives.

I've done some research and found that this command will clone /dev/sda to /dev/sdb:

sudo dd if=/dev/sda of=/dev/sdb

When I enter this command the terminal just kind of sits there. The cursor blinks but it shows no signs of progress and has taken a lot longer than I thought it should. I'm only cloning 40GB hard drives. I was wondering if this was normal. Is there any way to check it's progress? How long should it take for it to complete? If I let it sit for awhile will it complete?

Any help would be greatly appreciated. Thanks in advance.
 
Old 11-26-2011, 03:45 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,103

Rep: Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117Reputation: 4117
Possibly it's already finished, and the question is now moot.
Start up a new tab in your terminal session (or go to another vt) and "man dd". Near the end is a description of how to get stats out of it.

BTW I'd suggest you research some more - "dd" is an abysmal option for this (in most cases).
 
Old 11-26-2011, 03:48 PM   #3
jamesf
Member
 
Registered: Dec 2004
Location: USA
Distribution: Slackware 12, Slackware64 14.2
Posts: 236
Blog Entries: 1

Rep: Reputation: 57
From man dd:
Code:
       Sending a USR1 signal to a running `dd' process makes it print I/O sta-
       tistics to standard error and then resume copying.

              $ dd if=/dev/zero of=/dev/null& pid=$!
              $ kill -USR1 $pid; sleep 1; kill $pid

              18335302+0  records  in  18335302+0 records out 9387674624 bytes
              (9.4 GB) copied, 34.6279 seconds, 271 MB/s
Note that the man page is killing the copy after demoing the statistics. You just want to "kill -USR1 pidOfddProcess", either after backgrounding the dd with a trailing & or issuing the kill -USR1 from another terminal.

Last edited by jamesf; 11-26-2011 at 03:50 PM. Reason: further information
 
Old 11-26-2011, 03:52 PM   #4
brak44
Member
 
Registered: Aug 2010
Location: Brisbane Australia
Distribution: Centos, Fedora
Posts: 87

Rep: Reputation: 24
Check that you have discs recognised by the operating system by doing as su
fdisk -l
To clone 1 disk to another you should be running the operating system from a live cd to avoid a disaster where you may overwrite the wrong disk.
To monitor progress use dc3dd e.g.
dc3dd progress=on progresscount=1000 if=/dev/sda of=/dev/sdb
 
Old 11-26-2011, 04:56 PM   #5
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Original Poster
Rep: Reputation: Disabled
Thanks for the help.

This is what happens when I type the "dd" command:

root@ubuntu:/home/ubuntu# dd if=dev/sda of=dev/sdb
_

That underscore is what happens. I can't enter any commands and it just stays there blinking, so I can't enter any of the commands that you all have told me to do.

Thanks again.
 
Old 11-26-2011, 05:10 PM   #6
jamesf
Member
 
Registered: Dec 2004
Location: USA
Distribution: Slackware 12, Slackware64 14.2
Posts: 236
Blog Entries: 1

Rep: Reputation: 57
Switch to a different tty (Ctrl-Alt-F1 through F6), log in, do a "ps -ef | grep dd". Get the PID from the result, and then "kill -USR1 pidOfddProcess" to get the statistics.

Last edited by jamesf; 11-26-2011 at 05:10 PM. Reason: punctuation
 
Old 11-26-2011, 05:20 PM   #7
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Original Poster
Rep: Reputation: Disabled
I have a lot of questions.

What does "ps -ef | grep dd" mean?

What do you mean "get the PID from the result"?

From what I understand "kill -USR1 pidOfddProcess" kills the process and then gives me the statistics. If I'm correct, is there anyway to not kill the process?

Once again, Thanks a lot for your help.
 
Old 11-26-2011, 05:55 PM   #8
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: Slackware, Ubuntu, PCLinux,
Posts: 10,444

Rep: Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474
Quote:
What does "ps -ef | grep dd" mean?
It doesn't mean anything but gives output on the dd command.

Quote:
What do you mean "get the PID from the result"?
Gets the process running dd so that if you wish to stop that process, you kill it.

If you want to get info, I believe the last line in the post by brak44 gives you that.
Also, did you follow through on his suggestion to run fdisk to see if your second drive is recognized?
Are you running this from a Live CD as suggested?
Did you check the connections to the second hard drive?
 
Old 11-26-2011, 06:10 PM   #9
jthill
Member
 
Registered: Mar 2010
Distribution: Arch
Posts: 211

Rep: Reputation: 67
My SATA drives transfer at about 50MB/sec. That's twenty seconds per gb assuming the data path can handle 100MB/s aggregate, 40*20 is pushing fifteen minutes at that rate, but 40GB is _very_ small, which probably means old, which probably means slow. Half an hour or more wouldn't be very surprising.

Not every signal terminates a program. Only one (-KILL) is a forced kill (do not use this casually, ^C sends -QUIT), many have conventional meanings, but -USR1 and -USR2 are completely up to the receiving program.
 
Old 11-26-2011, 06:54 PM   #10
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Original Poster
Rep: Reputation: Disabled
Yes I know both drives are being recognized with the "lshw -c disk" command and I am running it from a Live CD (Ubuntu Rescue Me remix to be specific).

I used "ps -ef | grep dd" and got a table of info as a result, I do not know where to find the pid on this table of info though. What should it look like, or where can I find it on the table so I can use the "kill -USR1 pidOfddProcess" to get the statistics?
 
Old 11-26-2011, 07:22 PM   #11
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by Clarence-Adams View Post
Thanks for the help.

This is what happens when I type the "dd" command:

root@ubuntu:/home/ubuntu# dd if=dev/sda of=dev/sdb
_
Unless this is an error in transcription, you probably want
Code:
dd if=/dev/sda of=/dev/sdb
# Note leading slashes on device-file names
--- rod.
 
Old 11-26-2011, 08:29 PM   #12
jamesf
Member
 
Registered: Dec 2004
Location: USA
Distribution: Slackware 12, Slackware64 14.2
Posts: 236
Blog Entries: 1

Rep: Reputation: 57
Here I'm doing it all from one terminal, just so you can follow what is going on. Note that when I background dd with & it tells me the new pid. Then, the grep dd gives the pid in the second column, parent pid in the third (I don't need it for this). Then, I use kill.
Code:
james@gaz:~$ dd if=/dev/urandom of=/dev/null &
[1] 2120
james@gaz:~$ ps -ef | grep dd
root         2     0  0 20:23 ?        00:00:00 [kthreadd]
root      1793  1764  0 20:24 ?        00:00:00 hald-addon-input: Listening on /dev/input/event0 /dev/input/event1 /dev/input/event2
root      1815  1764  0 20:24 ?        00:00:00 hald-addon-storage: polling /dev/sdb (every 2 sec)
root      1816  1764  0 20:24 ?        00:00:00 hald-addon-storage: no polling on /dev/fd0 because it is explicitly disabled
82        1818  1764  0 20:24 ?        00:00:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
root      1822  1764  0 20:24 ?        00:00:00 hald-addon-storage: polling /dev/sr0 (every 2 sec)
root      1925  1764  0 20:24 ?        00:00:00 hald-addon-storage: polling /dev/sdc (every 2 sec)
root      1938  1764  0 20:24 ?        00:00:00 hald-addon-storage: polling /dev/sdd (every 2 sec)
root      1939  1764  0 20:24 ?        00:00:00 hald-addon-storage: polling /dev/sde (every 2 sec)
root      1946  1764  0 20:24 ?        00:00:00 hald-addon-storage: polling /dev/sdf (every 2 sec)
james     1998     1  0 20:24 ?        00:00:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
james     2029     1  0 20:24 ?        00:00:00 xfce4-power-manager --restart --sm-client-id 2992dd5db-0f1c-4ada-a49a-ee408aaeb063
james     2120  2096 94 20:34 pts/0    00:00:06 dd if=/dev/urandom of=/dev/null
james     2122  2096  0 20:35 pts/0    00:00:00 grep dd
james@gaz:~$ kill -USR1 2120
james@gaz:~$ 309724+0 records in
309723+0 records out
158578176 bytes (159 MB) copied, 40.8541 s, 3.9 MB/s
a few seconds later, I did the kill again. Notice the numbers went up as dd is still copying in the background.
Code:
james@gaz:~$ kill -USR1 2120
1063221+0 records in
1063220+0 records out
james@gaz:~$ 544368640 bytes (544 MB) copied, 143.678 s, 3.8 MB/s
BTW, I tried something similar to what you're doing once. It takes a _long_ time on modern drives. They're larger than when dd was written. ;v)

Last edited by jamesf; 11-26-2011 at 08:40 PM. Reason: removed typo and fixed the whole thing.
 
Old 11-26-2011, 08:39 PM   #13
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
I just tried that trick sending a signal to dd while writing an image file to a SD flash card. It reported much higher progress than it should have, then stopped reporting progress way before it was done. I mention this because if you use this method to test 'done-ness', you may end up doing something to the target drive before the write is really done.
--- rod.
 
Old 11-26-2011, 08:46 PM   #14
jamesf
Member
 
Registered: Dec 2004
Location: USA
Distribution: Slackware 12, Slackware64 14.2
Posts: 236
Blog Entries: 1

Rep: Reputation: 57
Replying to theNbomr: Could it have been the write cache that was messing you up? The command will finish before the final flush actually takes place.

I ask because I've never had the statistics query mess me up.

Also, if these are new 4K disks then the default bs and obs of 512 won't be doing the duplication much good...
 
Old 11-27-2011, 10:30 AM   #15
Clarence-Adams
Member
 
Registered: Nov 2011
Distribution: Archlinux
Posts: 31

Original Poster
Rep: Reputation: Disabled
I used "ps -ef | grep dd" to get the PID of "dd if=/dev/sda of=/dev/sdb". The PID is 2412 in my case. So I used "kill -USR1 2412" to get the statistics, but instead I just got a blank line. What do you think is wrong?
 
  


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
Advice on Western Digital "Advanced Format" hard drives under linux telemeister Linux - Hardware 5 03-02-2010 12:18 AM
hard drives come up "no partition table" and "in use by another program" marti972 Linux - Newbie 3 03-16-2009 11:44 PM
Mounting Hard Drives To Act Like "Host Drive" Noxious020189 Linux - Hardware 3 11-30-2008 04:46 PM
"No Hard Disk Drives detected" error when installing Woody as guest OS in VMware Thomas Anderson Debian 1 01-25-2004 04:41 AM
Mandrake 9.0 & 9.1 "detecting hard drives" installation hang Dr Tom Danger Mandriva 3 11-07-2003 03:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:38 AM.

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
Open Source Consulting | Domain Registration