Creating backup disk image of RAID 1 array (MDADM)

We have some servers that run in very harsh environments (research vessel) that need to have high-availability.

We have software RAID 1 for some measure of resiliency, along with proper data backups (tapes etc), however we would like to be able to break out a new server and re-image it (including RAID setup) from a known good copy if the hardware completely fails on the production box. Simplicity of the process is a big plus.

I am interested in any advice on the best way to approach this. My current approach (relatively new to Linux administration, totally new to MDADM) is to use DD to take a complete gzipped copy of one of the RAID'ed devices (from a live CD): dd if=/dev/sda bs=4096 | gzip -c > /mnt/external/image/test.img then reverse the process on the new PC, finally using mdadm --assemble to re-create and re-build the array.

I'm not sure that this is the best approach, or if it will even work. Any advice would be great.


Your dd-based (block level) copy will include all the free space on the disk, won't take advantage of larger disks down the road, and won't fit onto smaller disks (in a pinch).

Rather than doing the cloning at the block level I'd do it at the filesystem level.

I'd boot the new server from the live CD, partition the disks, create the new MD array(s), format the arrays, run mkswap on any swap volumes, then untar (or un-cpio, if you prefer) file-level copies of each of the source server's volumes into each of the new arrays. Finally I'd install the boot-loader. Then you're golden.

All of that could be scripted and rolled onto a live CD/DVD image along with the filesystem archive(s) to untar.


Traditionally, dump and restore are programs that intimately know the filesystem structure and can efficiently write out and load the minimal needed to save and restore the filesystem.

On Linux, the commands dump and restore (sometimes named e2dump and e2restore) work for ext2/3/4. xfsdump and xfsrestore are the analogues for XFS.

Of course, you can use filesystem-independent tools such as tar or cpio or rsync. Your dd method wins on simplicity of use, since you don't have to set up the partitions or filesystems or bootloader at all, but may cause problems if your disks are not all identical.