Cloning a Hard Drive Using dd

The other day I helped a friend with his daughter’s computer. The issue was that she had a machine with a 50GB hard drive, all one partition, and it was 99% full. It was a small form factor Dell with only 1 bay for a SATA drive, so simply adding another drive was out of the question. So, how do I get everything from the old hard drive to a new 500GB drive quickly and efficiently?

Easy: dd. What is dd you ask? Well, its a pretty awesome little utility in Linux distros that manipulates file systems at the low, block level. So, this means that you really need to be careful, because you can seriously destroy any hopes of recovering/copying data if you mess up the command.

For starters, you either need a bootable Linux disc, such as Knoppix, or you just need a machine with Linux already installed. For this, I used a netbook I have with Ubuntu 9.10 installed. You will also need at least one external drive enclosure. For my project, I needed two. One for the new drive and one for the old. If you are booting to a disc, pop the disc into the old computer with the drive that is going to be replaced and plug up the new drive via USB.

After you have booted into your Linux distro, you will need to determine which drive is which. This is a very important step. With Ubuntu, you can use the disk utility and easily determine which drive is which. You are looking for something that says “/dev/sda” or something similar (could be /dev/sdb, sdc, etc..). Once you have determined which drive is which, you can open a terminal and begin the process.

For the sake of examples, lets assume that the old drive is “/dev/sdo” and the new drive is “/dev/sdn” (O for old, N for new). The command would look something like this:

dd if=/dev/sdo of=/dev/sdn conv=noerror,sync

The if part of command is “input file” and of is “output file”, the “conv=noerror,sync” tells dd that if it can’t read a block for some reason, it should at least write something the same length/size.

This process takes quite some time. For the 50GB hard drive, it took about 10 hours to copy. After it is done, you can take out the old hard drive and put in the new one. Then turn on your machine and it will boot just like it used to. But, this is only part of the solution. The dd command also copied the partition table, which means that you still only have 50 GB.

Next we need to extend the partition. In Windows, a great tool to use is EASEUS. In Linux, you can use gparted. They both have a GUI and are pretty easy to figure out.

So there  you have it, and if you are uncomfortable or need help, just comment on this post and I will be glad to contact you and help you out.

Leave a Reply

Your email address will not be published. Required fields are marked *