LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-08-2010, 08:02 AM   #1
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Rep: Reputation: 15
What exactly does dd do?


If you use dd to dump one hard drive to another, is the new hard drive a perfect clone of the old one? In what ways? What are the "gotchas" of cloning a hard drive with dd? Is a "dd-clone" truly a clone?

I have a Windows box that acts as a serial monitor/relay for some industrial equipment. The box was set up by an outside vendor and I don't have confidence in their ability to always be available for support. I was thinking it would be a good idea to clone the hard drive so that if anything happens I can always slap in the cloned hard drive and restore the box to a known working state. I was going to do this by using two SATA-USB adapters and my Linux laptop, and just dd the current 1TB drive to a new 1TB drive. If I do this, will Windows boot the clone drive? Will it even know anything happened? What if the new hard drive is a different model, or brand, or has a different amount of cache? I need to be confident the new hard drive will work, or there's no point to the exercise. I would like to actually clone the hard drive and then put the CLONED drive back in the computer when I'm done; then I know that the cloning is working as planned. But I don't want to mess anything up, and I know next to zero about Windows.
 
Old 09-08-2010, 08:39 AM   #2
CincinnatiKid
Member
 
Registered: Jul 2010
Posts: 454

Rep: Reputation: 47
dd is used to create an image of just about anything. It is commonly used to clone partitions. Note that as far as I know you can't clone a whole drive at a time, only partitions. So you can create identical partitions on the second hard drive, and then dd the partitions to the new hard drive. For instance:

Code:
dd if=/dev/sda2 of=/dev/sdb2
That would essentially copy the data on /dev/sda2 and place it on /dev/sdb2. If you did this:

Code:
dd if=/dev/sda of=/dev/sdb
if I am not mistaken, it would just copy the MBR over to the other drive.
 
0 members found this post helpful.
Old 09-08-2010, 09:00 AM   #3
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Original Poster
Rep: Reputation: 15
Oh. I thought if you did dd if=/dev/sda of=/dev/sdb, then it would make a bit-for-bit copy of the whole drive, including partitions, file system, MBR, everything.

If I had to prepare the destination drive by partitioning it, I'm not sure how to do that. I'm not sure how to make identical partitions on the destination drive, or what that even means...identical sizes? Identical starting points? Would they need a filesystem too? What about the disklabel?

Isn't there a way to just duplicate the hard drive, bit-for-bit?

Last edited by Daravon; 09-08-2010 at 09:01 AM.
 
Old 09-08-2010, 09:23 AM   #4
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
very good thread for dd command. You learn lot about dd command.

Quote:
This post contains comprehensive documentation with examples for one of the most useful Linux/UNIX/Windows commands: dd. Dd is a bit-stream duplicator. If you have questions, post them. The latest addition, How to rescue data from a CD or DVD, or flash drive or memory card was on 07-23-2010:
http://www.linuxquestions.org/questi...ommand-362506/
 
Old 09-08-2010, 09:45 AM   #5
CincinnatiKid
Member
 
Registered: Jul 2010
Posts: 454

Rep: Reputation: 47
Quote:
Originally Posted by Daravon View Post
Oh. I thought if you did dd if=/dev/sda of=/dev/sdb, then it would make a bit-for-bit copy of the whole drive, including partitions, file system, MBR, everything.

If I had to prepare the destination drive by partitioning it, I'm not sure how to do that. I'm not sure how to make identical partitions on the destination drive, or what that even means...identical sizes? Identical starting points? Would they need a filesystem too? What about the disklabel?

Isn't there a way to just duplicate the hard drive, bit-for-bit?
I think I am wrong after reading the info on the page that sem007 posted, but you may want to double check. If you were going to do it partition-by-partition, I believe the partition sizes would be the only thing that would need to be the same. The starting point would not matter, because you are simply cloning a partition, not a drive.
 
Old 09-08-2010, 12:09 PM   #6
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Original Poster
Rep: Reputation: 15
Now that I think about it, using USB-to-serial adapters, which are maybe 30MB/s, this is going to take 9.7 hours! That's longer than my working shift. I'd be better off using Sata, which at 3Gb/s, would be 45 min. Although I imagine the real speed will be much less than 3Gb/s which is the max drive speed.
 
Old 09-08-2010, 01:39 PM   #7
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
Quote:
Originally Posted by Daravon View Post
Now that I think about it, using USB-to-serial adapters, which are maybe 30MB/s, this is going to take 9.7 hours! That's longer than my working shift. I'd be better off using Sata, which at 3Gb/s, would be 45 min. Although I imagine the real speed will be much less than 3Gb/s which is the max drive speed.
If these are not SSDs then yes it will take a whole lot longer. A better estimate is either to run 'hdparm -t /dev/sda' or just watch the transfer rate using a monitoring program. For my HDD it is about 73.75 MB/sec, but in reality it usually gets maybe 50-60 MB/sec in bursts, and it averages to more like 40-50 MB/sec. dd will also post the average transfer rate, so you can try transferring some files.

Last edited by H_TeXMeX_H; 09-08-2010 at 01:41 PM.
 
  


Reply



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 On
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:18 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
Open Source Consulting | Domain Registration