Data recovery from a failing hard disk can be a daunting task, but with the right tools, it becomes manageable. One such powerful tool in Linux is ddrescue, which is a data recovery tool created to copy data from one file or block device (like a hard disk) to another.

It efficiently handles read errors and tries to recover as much data as possible, making it ideal for failing hard disks.

In this article, I’ll guide you through the process of using ddrescue to recover data from a failing hard disk in simple, easy-to-follow steps.

Installing ddrescue in Linux

Before using ddrescue, you need to install it on your Linux system, the command is usually available in the default repositories of most Linux distributions and can be installed using the package manager of your distribution as shown.

sudo apt install gddrescue         [On Debian, Ubuntu and Mint]
sudo yum install ddrescue         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/ddrescue  [On Gentoo Linux]
sudo apk add ddrescue             [On Alpine Linux]
sudo pacman -S ddrescue           [On Arch Linux]
sudo zypper install ddrescue      [On OpenSUSE]    
sudo pkg install ddrescue         [On FreeBSD]

The ddrescue command is used to copy data from one location to another. It is designed to handle disks that are failing or have already failed.

The basic syntax of the command is as follows:

ddrescue [options] input_file output_file

Using ddrescue to Recover Data in Linux

First, identify the device names for both the failing disk and the destination disk by using the following lsblk command, which will list all block devices.


Look for the device names (e.g., /dev/sda, /dev/sdb). Let’s assume /dev/sda is the failing disk and /dev/sdb is the destination disk.

Next, create a backup of the failing disk to a separate disk or storage device, which will ensure that you have a copy of the data before attempting to recover it.

sudo ddrescue -n -v -b 4096 /dev/sda /media/backup/sda_backup mapfile

Here is the breakdown of the command:

  • -n tells ddrescue to run in non-interactive mode.
  • -v increases the verbosity of the output.
  • -b 4096 sets the block size to 4096 bytes.
  • /dev/sda is the device to be backed up.
  • /media/backup/sda_backup is the location where you want to store the backup.
  • mapfile is the log file that keeps track of the progress and any errors encountered during the backup process.

Finally, run the ddrescue command to start the recovery process, and monitor the log file to keep track of which parts of the disk have been successfully copied.

sudo ddrescue -f -n /dev/sda /dev/sdb /path/to/logfile.log

Here, the -f forces the overwriting of the output file and -n instructs ddrescue to skip the scraping phase (useful for the initial pass).

After the initial pass, you can perform additional passes to try to recover more data from the bad sectors.

sudo ddrescue -d -r3 /dev/sda /dev/sdb /path/to/logfile.log

Here, the -d enables direct disc access, which can be faster and -r3 retries reading bad sectors three more times.

Verify Recovered Data in Linux

Once ddrescue completes, you should verify the recovered data on the destination disk by mounting it and checking the files.

sudo mount /dev/sdb /mnt
ls /mnt

After verifying the data, unmount the disks safely.

sudo umount /dev/sda
sudo umount /dev/sdb

Using ddrescue to recover data from a failing hard disk in Linux is a powerful and efficient method. By following these steps, you can maximize the chances of recovering your valuable data.

Remember to always handle failing disks with care and consider creating regular backups to prevent data loss in the future.

Similar Posts