LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   What exactly does dd do? (https://www.linuxquestions.org/questions/linux-general-1/what-exactly-does-dd-do-830976/)

Daravon 09-08-2010 08:02 AM

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.

CincinnatiKid 09-08-2010 08:39 AM

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.

Daravon 09-08-2010 09:00 AM

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?

sem007 09-08-2010 09:23 AM

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/

CincinnatiKid 09-08-2010 09:45 AM

Quote:

Originally Posted by Daravon (Post 4091436)
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.

Daravon 09-08-2010 12:09 PM

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.

H_TeXMeX_H 09-08-2010 01:39 PM

Quote:

Originally Posted by Daravon (Post 4091611)
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.


All times are GMT -5. The time now is 09:04 PM.