Centos – Create a bootable clone in Linux

backupbootablecentosclonezillalinux

I have a working Linux system (Centos 6.7) which I would like to clone to a bootable hard disk. The hard disk is also internal.

The purpose of the clone is for disaster recover as well as to allow me to test changes safely.

On the Mac, for example, I can easily clone the main disk using Carbon Copy Cloner, or Super Duper, and easily boot from the cloned partition when needed.

I’m not necessarily looking for a new tool to do this, as I suspect that the tools are already available in my system. However, if they’re not, then I’m happy to get such a tool.

I have read much about Clonezilla, but, as far as I understand:

  • Clonezilla requires a larger destination drive — my backup drive is the same size (and, because of differences in hardware, may be a few bytes smaller).
    — It does not actually make the copy bootable
  • It runs from a Live CD which is OK, but not practical if I want to do this on a regular basis.

It is my intention to create the clone, and possibly use rsync to keep it up to date.

One other detail: I am running a Raid 1 array (but my clone should be a simple hard disk), and LVM.

Is there a simple tool or procedure to do the job? I don’t know whether the answer would be general or specific to the distribution.

To qualify the question, I guess that I don’t actually need to make a literal clone, but just a copy of everything.

Best Answer

As you are using LVM, you could utilize the volume shapshots: each time you would like to synchronize your cloned versions of volumes with the actual ones you create snapshots, then rsync the snapshot volumes to clones and then destroy snapshots again.

The initial creation of a cloned volumes could be also achieved with LVM's mirroring of a volume on another Physical Volume with the following breaking of a mirror volume. After the initial cloning don't forget to fsck -f the clones and change UUIDs (and volume labels if you use volume labels) of clones so they have unique UUIDs.

Also some care should be taken during later synchronisation in regard of 'cloned' version of /etc/fstab, /boot and grub configuration if you really like your clone to be bootable for disaster recovery.

So the whole creation and later synchronization could be done online with short interruption of services: you need to prevent any sensible data change at the time of snapshots creation or mirror break: e.g. if you are running a web service that updates some DB, then you should stop the DBMS, sync, then create snapshots (takes really short time) and then start DBMS again.

Related Question