Clone partition on Linux

Making a clone of a disk partition is a great way to make a complete backup. This type of backup would preserve all your system and personal files on that particular partition. Cloning and restoring a disk partition is relatively easy, even if you are cloning the partition on to a completely different storage device.

There are a few applications built especially for this type of function, like Partimage and Clonezilla, but we can also use a simple, default command line tool such as dd. In this tutorial, we will take you through the step by step instructions to make a clone of a partition on a Linux system. You will learn three different methods below and can choose the one that you think fits your situation best.

In this tutorial you will learn:

  • How to clone a disk partition with dd command
  • How to clone a disk partition with Partimage
  • How to clone a disk partition with Clonezilla
Clone partition on Linux
Clone partition on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software dd, Partimage, Clonezilla
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to clone a disk partition on Linux step by step instructions



Twitter icon Follow LinuxConfig.org on Twitter for the latest tips and tricks about Linux!


If you do not wish to install extra software, and can clone your partition directly to the same device or another hard drive or solid state drive, the dd command is the recommended method for you to follow below. If you prefer to make a clone file of your installation, then the Partimage or Clonezilla options would be your best route.

Clone Partition With dd

dd can be used to clone your entire partition to another partition or disk. Everything will be copied, including partitioning information and all data present on the partition at the time of cloning.

The easiest way to use this tool is to insert your backup hard drive into your computer. You do not need to partition or format the backup disk in any way, as dd will write to it as a block device.

Once the hard disk has been inserted, execute the following command to clone your partition onto the backup disk:

$ sudo dd if=/dev/sdb1 of=/dev/sdX bs=64K conv=noerror,sync
  • if (input file) is block device /dev/sdb1
  • of (output file) is block device /dev/sdX
  • bs (bit size) is 64K, as small chunks are less likely to encounter errors
  • conv settings are noerror, and sync which will try again on error and synchronize input and output

In this example, /dev/sdb1 is the disk that contains our partition that is being cloned. /dev/sdX is the backup disk which we are cloning to. You can use fdisk -l to obtain the device paths to your own hard drives, and then adapt the command above as needed.

After successfully running the command, you can pop your backup hard disk into any computer, and you can access the partition just as you would on the original disk.

Clone Partition With Partimage

Keep in mind that Partimage can only clone unmounted partitions. So the partition you wish to clone can’t be currently in use.

  1. The first step is to install Partimage:
    $ sudo apt install partimage
    
  2. Next, launch Partimage from command line:
    $ sudo partimage
    
  3. Use the arrow keys on your keyboard to select the partition that you want to clone. Once it is highlighted, press Tab to move onto the next field. Pick a name for your clone, and then press F5 to proceed to the next menu.



    Select partition to clone, and fill out the desired image name
    Select partition to clone, and fill out the desired image name

  4. Choose your desired compression settings, then hit F5 to continue.
    Choose compression settings for cloned image
    Choose compression settings for cloned image
  5. Partimage will then make a clone of your selected partition, and output it to the image file you specified.
    Partimage is done creating our clone of the partition
    Partimage is done creating our clone of the partition

Clone Partition With Clonezilla

  1. The first step is to install Clonezilla:
    $ sudo apt install clonezilla
    
  2. Next, launch Clonezilla from command line:
    $ sudo clonezilla
    
  3. Clonezilla will allow us to clone our disk’s partition to an image file, or directly to another hard disk. Choose whichever one you desire, but we will go with image file in this example.

    Choose whether to clone to image file, hard disk, or something else
    Choose whether to clone to image file, hard disk, or something else



  4. Next, choose to clone your local hard drive, unless you have some situation where you need to clone the disk from a different computer via the network.
    Select to clone the local disk
    Select to clone the local disk
  5. Next, choose which mode you would like to use. Stick with beginner unless you have some specific settings you need to apply to your cloned image.
    Choosing beginner mode
    Choosing beginner mode
  6. Choose whether you want to save the entire disk image, or just that of a partition.
    Save disk or partition image
    Save disk or partition image
  7. Lastly, choose a name for your cloned image.
    Choose name
    Choose name
  8. Clonezilla will then make a copy to your specified image. All done.

Closing Thoughts



Twitter icon Follow LinuxConfig.org on Twitter for the latest tips and tricks about Linux!


In this tutorial, we saw how to clone a disk’s partition on Linux. The stock dd tool suffices for the job, but extra applications are also available like Partimage, Clonezilla, and a slew of others that we did not cover here. Cloning your Linux partition is ideal for a backup solution and to load your same configuration onto a whole array of computers.



Comments and Discussions
Linux Forum