How To Clone Hard Drives with DDRESCUE
Copied from here so I can find it easier.
Tips:
run fdisk -l to list all the hard drives in your system. This will show you proper path for the drive (sda, sdb, etc)to use in the ddrescue command.
If you are unsure which drive is source and which is destination, boot up with just one of the drives and note the serial number displayed by fdisk -l
Cloning Hard Drives with ddrescue
Before starting this process, you will need a copy of ddrescue (preferably on a CD or DVD), a fully functional hard drive, and the damaged drive. You can download the latest version of ddrescue here, or click here to download SystemRescueCD, a system rescue disk for Linux that can be used as a bootable USB stick or CD.
Of these options, we’d recommend using the SystemRescueCD, since it provides for a fairly simple hard disk cloning process with ddrescue.
To run ddrescue, use the following format for commands:
ddrescue [options] infile outfile [logfile]
With SystemRescueCD, you can see a list of devices by typing fdisk -1 at the root prompt. Run the utility with the following commands appended:
root# ddrescue -r3 -n /dev/[baddrive] /dev/[gooddrive] recovery.log
Here’s an explanation of each of these components:
-n
Short for’–no-scrape’. Prevents ddrescue from running through the scraping phase, essentially preventing the utility from spending too much time attempting to recreate heavily damaged areas of a file.-r3
Tells ddrescue to keep retrying damaged areas until 3 passes have been completed. If you set ‘r=-1’, the utility will make infinite attempts. However, this can be destructive, and ddrescue will rarely restore anything new after three complete passes./dev/[baddrive]
Identifies the drive that will be copied. Fill this in with the name of your bad drive./dev/[gooddrive]
Identifies the drive where the data will be cloned. Fill this in with the name of the good drive. You can also create an image file by replacing this with something like imagefile.img.recovery.log
This creates a logfile, which is essential if you’re performing multiple passes. You can name the logfile anything, but without a logfile, you can’t make additional passes on areas of your disk with bad sectors.
Some other useful command options for the process include:
-D
Short for ‘–synchronous’. This issues an fsync call after every write.-d
Short for ‘–delete-if-done’. Deletes the given logfile “if all the blocks in the rescue domain have been successfully recovered.”-e [+]n
Short for ‘–max-errors=[+]n’. This sets the maximum number of error areas allowed before ddrescue gives up, and it can be used to prevent the utility from running infinitely.-v
Short for ‘–verbose’. This sets “verbose” mode, providing additional details. Can be useful for diagnosing issues.-S
Short for ‘–sparse.’ This compels ddrescue to use sparse writes — blocks of zeroes aren’t allocated on the disk, which can save space. However, it can only be used for regular files, and it is not an available option on all operating systems.