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.
Block-level cloning
Using dd
See dd#Disk cloning and restore and Core utilities#dd alternatives.
Using ddrescue
If possible, data recovery from disks should be performed using their native interface: SATA or, for older drives, IDE. Results may vary while using USB adapters.
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 --force -n /dev/sdX /dev/sdY rescue.map
where X
is the partition letter of the source and Y
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 --force -d -r3 -n /dev/sdX /dev/sdY rescue.map
In some circumstances the disk controller or a USB adapter may lock, while attempting to read a particular sector. The option may be used to instruct ddrescue to start reading after that position.
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 , 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.
- System Tar & Restore — Backup and Restore your system using tar or Transfer it with rsync
- GUI and CLI interfaces
- Creates .tar.gz, .tar.bz2, .tar.xz or .tar archives
- Supports openssl / gpg encryption
- Uses rsync to transfer a running system
- Supports Grub2, Syslinux, EFISTUB/efibootmgr and Systemd/bootctl