How to clone a drive from the Linux command line

Jack Wallen shows you how easy it is to clone a drive in Linux.

I'll walk through the process of cloning a drive in Linux. This process actually isn't too terribly difficult--especially if you're comfortable with the Linux command line interface. But how do you do it? 

First you'll need a bootable ISO image, of just about any Linux distribution, on a flash drive. You'll also need a new drive to clone to. That target drive must be as big or bjgger than the drive you're cloning. I prefer to go with bigger, just to be safe.

Once you have all of that ready, boot the machine with the source drive, using the bootable Linux distribution. Once you've logged in, make sure to attach the target drive to the system and find out where the target drive is located with the command:

 cat /proc/partitions

You should see a listing of all available drives, but they shouldn't be mounted. You'll need the name of the source and target drives. 

So let's say the source drive is sda and the target drive is sdd. It is crucial that you get those names right, otherwise you could trash all of the data on your source drive and wind up with a non-bootable, not cloned target. 

With that information at hand, you can then clone the drive with the command:

 sudo dd bs=4M conv=sync,noerror status=progress if=/dev/sda of=/dev/sdd

Depending on the size of the drive and how much data is on the drive, this command can take some time to complete. When it does complete, you should be able to boot from the target drive as though it were the original. 

And that's how easy it is to clone a drive from the Linux command line. 

Also see

linuxhero.jpg

Image: Jack Wallen