Recover Data from Crashed Disks with ddrescue command: A Comprehensive Guide
Introduction
What is ddrescue and Why Use It?
Key Features of ddrescue:
Problem: "wrong fs type, bad option, bad superblock" Error
Understanding the Error
mount: wrong fs type, bad option, bad superblock on 192.168.1.155:/home/shared, missing codepage or helper program, or other error (for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program)
This error suggests that the filesystem on the disk may be corrupted or incompatible with the current mount options. It can also indicate that the system is missing necessary helper programs to mount certain types of filesystems.
Diagnosing the Issue
To diagnose the problem, start by checking the system logs for more detailed information:
dmesg | tail
This command will display the latest system messages, which can provide insights into why the mount operation failed.
Common Causes and Solutions
- Corrupted Filesystem: If the filesystem is damaged, you may need to run
fsck
(File System Consistency Check) to repair it. - Missing Helper Programs: For certain filesystems like NFS or CIFS, you might need to install additional packages or helpers.
- Incorrect Mount Options: Ensure that the mount options you're using are appropriate for the filesystem type.
Example Scenario: Recovering Data from a Crashed Disk
Server Configuration
Let's assume you have a CentOS 7 server with the following configuration:
- OS: CentOS 7
- HDD1:
/dev/sda1
- HDD2:
/dev/sdb1
(Mount point/mnt
) - HDD3:
/dev/sdc1
(Newly attached disk for recovery)
In this scenario, HDD2 (/dev/sdb1
) has crashed and is no longer mountable at /mnt
. We'll use ddrescue
to recover the data from /dev/sdb1
and copy it to a new disk, /dev/sdc1
.
Step 1: Install ddrescue on CentOS
Before you can use ddrescue
, it needs to be installed on your system. Run the following command to install ddrescue
:
sudo yum install ddrescue -y
Step 2: Using ddrescue to Recover Data
Once ddrescue
is installed, you can proceed with the data recovery process.
Command to Rescue Data
Use the following command to start the data recovery process:
sudo ddrescue -f -n /dev/sdb /dev/sdc logfile
Here’s what the command does:
-f
: Forcesddrescue
to overwrite the output file if it exists.-n
: Skips over bad sectors initially and tries to copy the good sectors first./dev/sdb
: The source disk (the crashed disk)./dev/sdc
: The destination disk (the new disk).logfile
: A file that logs the progress and errors during the recovery process.
Retry Bad Sectors
If there are additional read errors, you can retry the bad sectors with the following command:
sudo ddrescue -d -f -r3 /dev/sdb /dev/sdc logfile
-r3
: Retries bad sectors up to three times.-d
: Direct disc access, bypassing the kernel cache.
Step 3: Check the Recovered Disk
After the data recovery process is complete, it’s crucial to check the integrity of the recovered filesystem. Use the fsck
command to do this:
sudo fsck -v -f /dev/sdc1
This command will verify the filesystem on /dev/sdc1
and attempt to fix any errors it finds.
Step 4: Mount the Recovered Disk
Finally, mount the recovered disk to access the data:
sudo mount /dev/sdc1 /mnt
If everything has gone smoothly, you should now be able to access your data from the /mnt
directory.
Frequently Asked Questions (FAQs)
What is the purpose of the logfile
in ddrescue?
The logfile
records all the operations performed by ddrescue
, including the sectors that were successfully copied and those that encountered errors. This allows you to pause and resume the recovery process without losing progress and provides a detailed record of the recovery process.
How long does the ddrescue process take?
The duration of the ddrescue process depends on the size of the disk and the extent of the damage. For heavily damaged disks, the process may take several hours or even days, especially if you set a high number of retries for bad sectors.
Can ddrescue recover data from a completely dead hard drive?
No, ddrescue
cannot recover data from a drive that is completely dead or unresponsive. It is designed to recover data from drives that are partially damaged but still detectable by the system.
What should I do if fsck fails to repair the filesystem?
If fsck
fails to repair the filesystem, you might need to use more advanced recovery tools or consult a data recovery specialist. In some cases, the filesystem may be too corrupted to recover using standard tools.
Conclusion
Data recovery is a critical task that requires the right tools and techniques. The ddrescue
command is a powerful utility for rescuing data from crashed disks, especially when dealing with I/O errors or bad sectors. This guide has provided a comprehensive overview of how to use ddrescue
to recover data from a failed disk on a CentOS 7 server and how to address common filesystem errors like the "wrong fs type, bad option, bad superblock" error.
Remember, while ddrescue
is a valuable tool, it’s always best to have regular backups to minimize the risk of data loss. By following the steps outlined in this guide, you can recover your data and restore your system to normal operation.
Ensure you use the right mount options and keep your system updated with the necessary tools and programs to avoid similar issues in the future. Thank you for reading the huuphan.com page!
Comments
Post a Comment