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
- How to clone a disk partition with Partimage
- How to clone a disk partition with Clonezilla
|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
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – 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
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
ddcommand 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
of(output file) is block device
bs(bit size) is 64K, as small chunks are less likely to encounter errors
convsettings 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.
- The first step is to install Partimage:
$ sudo apt install partimage
- Next, launch Partimage from command line:
$ sudo partimage
- Use the arrow keys on your keyboard to select the partition that you want to clone. Once it is highlighted, press
Tabto move onto the next field. Pick a name for your clone, and then press
F5to proceed to the next menu.
- Choose your desired compression settings, then hit
- Partimage will then make a clone of your selected partition, and output it to the image file you specified.
Clone Partition With Clonezilla
- The first step is to install Clonezilla:
$ sudo apt install clonezilla
- Next, launch Clonezilla from command line:
$ sudo clonezilla
- 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.
- 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.
- 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.
- Choose whether you want to save the entire disk image, or just that of a partition.
- Lastly, choose a name for your cloned image.
Clonezilla will then make a copy to your specified image. All done.
In this tutorial, we saw how to clone a disk’s partition on Linux. The stock
ddtool 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.