How to Clone Your Linux Hard Drive: 4 Methods
Whatsapp Pinterest
Advertisement

Just because you’re running a Linux operating system doesn’t mean that you won’t run into problems from time to time. It’s always good to have a backup plan, just in case a problem strikes. Perhaps a rare Linux virus will attack; perhaps you’ll be targeted by ransomware scammers. Maybe the hard disk drive (HDD) will fail.

Unlock the "Essential Linux Commands" cheat sheet now!

This will sign you up to our newsletter

Enter your Email

By cloning your Linux hard disk drive, you create a disk image that can be restored later. But how do you clone your Linux hard drive?

Linux Disk Cloning Tools

Your Linux installation might develop a bug; you could be upgrading your hard disk drive to a larger volume. Whatever the problem, if you have a backup of your disk, getting things back up and running again will be relatively simple.

Linux has four disk cloning solutions you should consider:

  1. dd
  2. Partimage
  3. Partclone
  4. Clonezilla

Whether you use functions that are built into your Linux operating system, or you install a third-party tool, it shouldn’t be long before you’re able to get your system back up and running.

Let’s look at each the four main options for cloning a drive in Linux.

1. dd: The Native Linux Disk Cloning Tool

Perhaps the most powerful Linux tool of them all, dd (sometimes referred to as “disk destroyer”) can clone an entire HDD or disk partition to another. But if misused, it can delete the contents of your disk.

As such, you should use with extreme care. You’ll find dd built into most Linux operating systems. If not, install it from the package manager. To clone your computer’s hard disk, use the command:

dd if=/dev/sdX of=/dev/sdY bs=64K conv=noerror,sync

Here, sdX is the source disk, while sdY is the destination. The numerical value 64K, corresponds to the block size command, bs. The default value is 512 bytes, which is very small, so it’s best to include 64K or the larger 128K as a condition. However: while a larger block size makes transfer quicker, a smaller block size makes the transfer more reliable.

If you only want to clone a partition of your drive, use

dd if=/dev/sda1 of=/dev/sdb1 bs=64K conv=noerror,sync

As you can see, the partition sda1 (that is, partition 1 on device sda) will be cloned to sdb1 (a newly created partition 1 on device sdb), for instance a secondary, or external, HDD attached to your computer.

Tap Enter to run the command. How long it takes will depend on the size of the disk or partition. Just make sure that destination volume is large enough to store it!

2. Linux Partition Cloning Tool, Partimage

Clone your Linux partitions

If you have run into problems trying to get your head around the instructions with dd, or would prefer to avoid accidentally deleting your HDD with typo, partimage is also available for most distros, and doesn’t carry any “disk destroyer” risks!

However, partimage does not support the ext4 filesystem, so avoid using it for cloning disks or partitions of that type. However, if necessary, it can be used to clone Windows disk formats (FAT32 or NTFS, although this is experimental) as well as the more widely used Linux filesystem ext3, and other, older alternatives.

Before starting, ensure that the partition you wish to clone is unmounted (with the umount command). Otherwise you’ll need to exit partimage to do so before continuing with the process. You can exit at any time with the F6 key.

For Ubuntu, install with:

sudo apt install partimage

Launch from the command line with:

sudo partimage

This is a mouse-driven application, which requires you to first select the partition to be cloned.

Select a partition to be cloned

Tap right on the arrow keys to move to the next section, then Image file to create/use and give it a name (or enter the filename of the image to be restored).

Select the correct Action to be done (ensure the chosen option has an asterisk) and press F5 to proceed. In the following screen, select the Compression Level, and your preferred Options. You also have the choice of setting an image split mode and setting an instruction for what should happen after the backup is made.

Choose an appropriate compression level

Tap F5 to continue, confirm the details, then tap OK to begin the process. The speed of this will depend on the power of your computer.

Clone your Linux partition

If you’re looking for a quick and dirty—but safe—disk cloning solution for Linux, use partimage.

3. Partclone: Software for Partition Imaging and Cloning

For a more mature alternative to dd that supports backups of the ext4 filesystem, partclone is simple to use, but again requires text commands rather than a keyboard or mouse driven interface. Install with:

sudo apt install partclone

And launch with:

partclone.[fstype]

…where [fstype] is the filesystem type of the partition you wish to clone.

The following command will create a disk image of hda1 (hard disk drive 1, partition 1) called hda1.img:

partclone.ext3 -c -d -s /dev/hda1 -o hda1.img

You might want to restore that image, so use

partclone.extfs -r -d -s hda1.img -o /dev/hda1

Further details on usage can be found on the partclone website.

4. Clone Your Linux Drive With Clonezilla

For a more flexible solution, why not try Clonezilla? This popular disaster recovery solution is based on Partclone and designed for a range of disk cloning tasks. All the expected filesystems are supported, across Linux, Windows, and macOS (and beyond).

Unlike dd and Partclone, Clonezilla is available as a bootable ISO. You can write this to DVD or USB stick to fully clone your Linux HDD. Clonezilla is straightforward to use, with keyboard-driven menus rather than obscure commands, so anyone can get to grips with it.

While Clonezilla can be setup as a standalone utility, you might prefer to use it as part of Hiren’s Boot CD recovery tool.

You can also use Clonezilla in a professional capacity, to image multiple similar PC setups with the same operating system.

Download: Clonezilla

Cloning Your Linux Hard Drive Is Easy

If you’ve never cloned a hard disk drive before, you may be feeling a little reluctant to get started. It can be intimidating, especially if you’re in dire straits with a damaged HDD that desperately needs cloning before failure.

While you might prefer to simply sync your vital data to the cloud, it is always a good idea to have a full disk backup that you can quickly restore in the event of system errors. Remember to use these tools with care, however, as they can easily cause you to accidentally lose your data.

Backing up your data is vital! Learn how to optimize your backups on Linux 6 Apps and Tricks to Optimize Your Linux System Backups 6 Apps and Tricks to Optimize Your Linux System Backups Concerned about backing up data in Linux? Worried about using dd, or just want to make things as simple as possible? These tips will help you make straightforward backups that don't eat up storage. Read More .

Explore more about: Clone Hard Drive, Data Backup, Linux Tips, System Restore.

Enjoyed this article? Stay informed by joining our newsletter!

Enter your Email

Leave a Reply

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

  1. Eddie OConnor
    May 16, 2019 at 8:05 am

    I don't bother with cloning, I have two (2) 4TB external HDD's for the computers and laptops I have, I just copy the /etc...and the /home folders (along with the hidden files for Mozilla and Thunderbird) and that's all I need, all other config files? I don't worry about. Sometimes simpler is better. I don't use a program to copy those files and folders, I just attach the external USB, and right-click and copy the files where I need them to be. I always select the "Overwrite destination files" option so that I always get the latest version of emails, and browser settings etc. I can't be bothered with risking losing my data due to a mis-typed command, or selecting an option I don't have much knowledge about. But I guess for those that need these kinds of tools...its good that they exist.

  2. D.C.
    May 9, 2019 at 9:34 pm

    I use MX Snapshot, a feature of the MX Linux distribution. This tool allows the user to easily back up their installed system to an *.iso, then run it as a live session from DVD or a USB drive, with the option to install/reinstall to a hard drive.

  3. sadhu
    August 10, 2018 at 5:36 pm

    My linux partition is a mere 20 gb, of which about 9 is used. All my data is located in another partition. I have many symbolic links from .confg, /etc, and other directories to a /shared_config directory in the data partition.

    I simply issue the command
    "sudo rsync -av --delete --exclude=".Trash*" /ddr/ /media/sadhu/wddr
    where /ddr is the data partition (220GB) on the hard disk, and wddr is a similar partition on an external hdd.

    sometimes I just back up the partition instead of mirroring it, so I omit the --delete argument.

    I run this every night before I hit the sack.

    --Sadhu

  4. laurel
    August 7, 2018 at 11:39 am

    utter newbie, i need to copy a disk thats got bad sectors to an external drive,
    my only spare normal,large drive has some partitions on it already;-( and doesnt fit the computer i need to save
    so i will then have to repeat the process to a new minidrive in the laptop
    so if i make 250gig in one partition..can i then copy THREE partitions off the dud drive over?
    or do i have to split the one i am moving it to into 3 also?

  5. Michael Fraley
    May 22, 2018 at 5:24 pm

    Hello,

    I use rsync and have it run every time I boot. It copies my linux partition to an external hard drive (USB mount). File and directory ownership and permissions are preserved. I have used it to restore a failed drive.

  6. S. S. Framson
    April 29, 2017 at 12:03 am

    Clonezilla has never been able to clone an entire stand alone system disk of Ubuntu 16.04 due to the reason that it always shows the destination disk as being smaller than the source disk. Clonezilla does this even when the physical size of the destination disk is twice that of the source disk. It must be noted that the source disk on which the existing Ubuntu OS is installed is a Samsung ssd of 240 GB and the destination disk is Samsung ssd of 520 GB. DO NOT PUT TOO MUCH FAITH IN CLONEZILLA'S CAPABILITY. Till April of 2017 there is no software tool that can copy and clone an entire Ubuntu OS from a ssd to another ssd. THANKS

  7. Hank Castello
    April 12, 2017 at 1:19 pm

    I've been using Clonezilla for years. Some of those other methods aren't safe to use before your morning coffee!

  8. apple
    January 9, 2017 at 11:53 pm

    The Linux HD is making squeaky noise so a clone is needed.

    When only the OS HD is present, using "fdisk -l", it shows sda with sda1 and sda2. However when placing a new HD (to be cloned to), it it listed sda and sdb. sdb1 and sdb2 have similar size of above. Clearly it seems the HD wit bootable OS becomes sdb and the empty new HD is assigned as sda.

    How can I be sure that the OS boot HD is indeed sdb and the empty HD to be cloned to is sda?

    I really don't want to erase the HD because it's so important.

    Thanks!

  9. germeten
    July 5, 2016 at 9:40 pm

    OK the first problem I run into running mount in terminal is I get: /dev/sdb1 on /type ext4
    According to your instructions, my HD should be sda but it's not. My CD drive may in fact have master status. Question is how do I identify my current HD to the new one I wish to clone. Don't want to make any fatal errors!

  10. johnC
    April 14, 2016 at 12:48 am

    Justin,, I ran into a file lock issue with using dd but it was good enough to get the
    job done with copying my hard drive to a USB stick.

    I deleted the file lock but got the error again and after digging thru it , I seen a issue
    with a symbolic link of a file into a file that was in /tmp. It was plexing me and I
    am trying to understand it. Any ideas??

    Otherwise, like your 'dd' tips and thank you. JohnC.

  11. Timal
    January 23, 2016 at 7:38 pm

    You and the commenters obviously know nothing about dd and cloning a hard drive.

    • Justin Pot
      January 24, 2016 at 4:11 pm

      I know enough to get the job done, and to try to teach other people, but I could always learn more. Got any tips?

    • Concerned Comment Viewer
      October 5, 2016 at 2:23 am

      And you have no idea to be useful or helpful in any of this... so please keep your comments to yourself so others may actually learn something that you pretend to know, but do not share.

      • Timal
        October 5, 2016 at 3:39 am

        Thanks for caring. What exactly are you here to "learn" about? How NOT to clone a hard drive? Be my guest. And yes, I will keep my comments to myself just like you are keeping yours to yourself. Have a nice day!

        • John Galt
          November 13, 2016 at 11:02 pm

          Timal's comments are the reason so many give up on Linux.
          They forget that they too were once a newbie and didn't know how to do things.

  12. Anders
    July 22, 2011 at 12:55 am

    This is ok method, as long as you don't use it to install on new/other computers.  Then there are much better methods.  Like FAI or other automatic installation softwares.

  13. Babr
    July 21, 2011 at 7:13 am

    You can also compress dd on the fly like this;
    dd if=/dev/sda1 |gzip > /backup-path/somename.img.gz
    reverse looks like this;
    gzip -dc /backup-path/somename.img.gz | dd of=/dev/sda1
     If you backup your root partition always do it with a live-cd, as said by jahid65.
    It is not smart to include a running /tmpfs that contains the thread of your dd command!

  14. jahid65
    July 20, 2011 at 6:31 pm

    I prefer fsarchiver, though it's not a partition cloning tool. It makes a compressed archive of a partition/file-system. you can put more than one partition in one archive. you can split that archive also. One of the advantage is that the file-system can be restored on a partition which has a different size and it can  be restored  on a different file-system. But you have to restore archive using live cd's (only applicable for root partition) or other linux distro installed in your HDD which has fsarchiver insalled. just make sure while you backup/restore archive the particular partition should be unmounted. well you can backup mounted partition(in case of root partion), but it is not preferable.