Making a clone of your Linux system is a great way to make a complete backup. This type of backup would preserve all your system and personal files, as well as any customizations and settings that you have applied to your operating system over time (assuming everything is on one hard drive). Cloning and restoring a Linux system is relatively easy, since Linux will not encounter errors if you clone it onto different hardware – at worst, you may have a few hiccups, such as the need to uninstall and install necessary drivers.
You can even make a clone of your Linux system as its running. 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 running 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 Linux system with
- How to clone a Linux system with Partimage
- How to clone a Linux system 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 Linux system step by step instructions
If you do not wish to install extra software, and can clone your Linux system directly to 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 Linux System With dd
dd can be used to clone your entire hard drive that contains your Linux operating system installation. Everything will be copied, including partitioning information and all data present on the hard disk 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 Linux system onto the backup disk:
$ sudo dd if=/dev/sda 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/sda is the disk that contains our Linux system (the disk 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 will load into the Linux system just as you would on the original disk.
Clone Linux System With Partimage
Keep in mind that Partimage can only clone unmounted partitions, so your root partition cannot be currently in use if you hope to clone it.
- 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 Linux System 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 Linux system 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 an entire Linux system. This included a whole disk, individual partition, and even a currently running operating system. 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 installation is ideal for a backup solution and to load your same configuration onto a whole array of computers.