Disk cloning

Disk cloning is the process of making an image of a partition or of an entire hard drive. This can be useful for copying the drive to other computers or for backup and recovery purposes.

Tip: Over time file systems get new features and the mkfs utilities change their defaults, but not all new features can be enabled without reformatting. So, when moving data to a new drive, instead of cloning the block devices or file systems, consider creating a new file system and only copy the files (and their attributes, ACLs, extended attributes, etc.) with e.g. rsync.

Block-level cloning

Using dd

See dd#Disk cloning and restore.

dd spin-offs

  • dcfldd enhanced version of dd for forensics and security, with on-the-fly hashing capability helping to ensure integrity, progress status output, flexible disk wipes, bit-for-bit match verification between input and target, output to multiple files or disks at the same time, split output and piped output and logs. The latest official version was released in 2006, but a semiofficial continuation has been releasing updates between 2019 and 2021.
http://dcfldd.sourceforge.net || dcflddAUR
  • dc3dd another patched version of GNU dd from the United States Department of Defense Cyber Crime Center (DC3), with very similar goals and features to dcfldd. The project aimed at tracking the GNU upstream updated, however its last release was in 2016.
https://sourceforge.net/projects/dc3dd/ || dc3ddAUR

Using ddrescue

GNU ddrescue is a data recovery tool capable of ignoring read errors. ddrescue is not related to dd in any way except that both can be used for copying data from one device to another. The key difference is that ddrescue uses a sophisticated algorithm to copy data from failing drives causing them as little additional damage as possible. See the ddrescue manual for details.

To clone a faulty or dying drive, run ddrescue twice. For the first round, copy every block without read error and map the errors to rescue.map.

# ddrescue -n /dev/sdX /dev/sdY rescue.map

where is the partition letter of the source and of the target block device.

For the second round, copy only the bad blocks and try 3 times to read from the source before giving up.

# ddrescue -d -r3 -n /dev/sdX /dev/sdY rescue.map

Now you can check the file system for corruption and mount the new drive.

# fsck -f /dev/sdY

File system cloning

Using e2image

e2image is a tool included in for debugging purposes. It can be used to copy ext2, ext3, and ext4 partitions efficiently by only copying the used blocks. Note that this only works for ext2, ext3, and ext4 filesystems, and the unused blocks are not copied so this may not be a useful tool if one is hoping to recover deleted files.

To clone a partition from physical disk , partition 1, to physical disk /dev/sdb, partition 1 with e2image, run

# e2image -ra -p /dev/sda1 /dev/sdb1

Versatile cloning solutions

These applications allow easy backup of entire filesystems and recovery in case of failure, usually in the form of a Live CD or USB drive. They contain complete system images from one or more specific points in time and are frequently used to record known good configurations. See Wikipedia:Comparison of disk cloning software for their comparison.

See also Synchronization and backup programs for other applications that can take full system snapshots, among other functionality.

        • Mondo Rescue A disaster recovery solution to create backup media that can be used to redeploy the damaged system.
          • Image-based backups, supporting Linux/Windows.
          • Compression rate is adjustable.
          • Can backup live systems (without having to halt it).
          • Can split image over many files.
          • Supports booting to a Live CD to perform a full restore.
          • Can backup/restore over NFS, from CDs, tape drives and other media.
          • Can verify backups.
        http://www.mondorescue.org/ || mondoAUR

                See also

                This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.