How to Clone a Partition or Hard drive in Linux

There are many reasons why you may want to clone a Linux partition or even hard drive, most of which are related to creating backups of your data. There are multiple ways you can achieve this in Linux by using some external tools such as partimage or Clonezilla.

However in this tutorial we are going to review Linux disk cloning with tool called dd, which is most commonly used to convert or copy files and it comes pre-installed in most Linux distributions.

How to Clone Linux Partition

With dd command you can copy entire hard drive or just a Linux partition. Lets start with cloning one of our partitions. In my case I have the following drives: /dev/sdb, /dev/sdc.. I will clone /dev/sdb1/ to /dev/sdc1.

Read Also: How to Clone Linux Partitions Using ‘cat’ Command

First list the these partitions using the fdisk command as shown.

# fdisk -l /dev/sdb1/ /dev/sdc1
List Linux Partitions

List Linux Partitions

Now clone a partition /dev/sdb1/ to /dev/sdc1 using the following dd command.

# dd if=/dev/sdb1  of=/dev/sdc1 

The above command tells dd to use /dev/sdb1 as input file and write it to output file /dev/sdc1.

Clone Linux Partition with dd Command

Clone Linux Partition with dd Command

After cloning Linux partition, you can then check both partitions with:

# fdisk -l /dev/sdb1 /dev/sdc1
Verify Linux Partition Cloning

Verify Linux Partition Cloning

How to Clone Linux Hard Drive

Cloning a Linux hard drive is similar to cloning a partition. However, instead of specifying the partition, you just use the entire drive. Note that in this case it is recommended that the hard drive is same in size (or bigger) than the source drive.

# dd if=/dev/sdb of=/dev/sdc
Clone Hard Drive in Linux

Clone Hard Drive in Linux

This should have copied the drive /dev/sdb with its partitions on the target hard drive /dev/sdc. You can verify the changes by listing both drives with fdisk command.

# fdisk -l /dev/sdb /dev/sdc
Verify Linux Hard Drive Cloning

Verify Linux Hard Drive Cloning

How to Backup MBR in Linux

dd command can also be used to backup your MBR, which is located at the first sector of the device, before the first partition. So if you want to create backup of your MBR, simply run:

# dd if=/dev/sda of=/backup/mbr.img bs=512 count=1. 

The above command tells dd to copy /dev/sda to /backup/mbr.img with step of 512 bytes and the count option tells to copy only 1 block. In other words you tell dd to copy the first 512 bytes from /dev/sda to the file you have provided.

Backup MBR in Linux

Backup MBR in Linux

That’s all! dd command is a powerful Linux tool that should be used with caution when copying or cloning Linux partitions or drives.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Marin Todorov

I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

4 Responses

  1. Alexander von Essen says:

    Well, after working for an hour or so – without error message – it bricked my system completely. Also the so much favored “Boot Repair Disk” made the catastrophe even worse. The problem seems the discrepancy of the sector size in both partitions.

    Only my Windows System boots ok – but with mysterious error messages.

    So this is not the solution to my problem. I can start from scratch now and install a new system.

  2. RSYDW says:

    Are you referring dd related to OS disk ? dd is mostly used to copy data (disk dump) from one disk to another as cp is not copying entire data completely.

    In case of physical servers mostly H/W raids are configured as RAID 1 for OS. For data volumes if required you can create mirrored volume in LVM or if you are using Veritas you can create desired RAID.

    Rsync will be good option as it is also used as data replication across site as well as locally .


  3. Romualdo Soler González says:

    The big problem with dd is that if an error is found, when it is cloning, it stops. But this can be avoided adding: conv=sync,noerror

    • Ravi Saive says:


      Yes, I do agree with you, even i have faced many times with dd command. Thanks for sharing the tip, never heard about this options..

Leave a Reply to RSYDW Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.