Divider Connect on Facebook Connect on Instagram Connect on Twitter YouTube email Email RSS Icon >

RAID

Recover Data From Corrupt Drives

April 9, 2014 at 9:10am

Recover from a bad superblock

First copy the data from the corrupt drive to the new drive. The logfile will record any errors. Copy sdb to sdc:

ddrescue -r3 /dev/sdb /dev/sdc logfile sudo ddrescue -v --no-split /dev/sdc /dev/sdb logfile -f

Note: Your new drive should be equal to or greater than the size of the corrupt RAID array.

e2fsck -v -f /dev/sdc mount -t ext2 -o ro /dev/sdc /mnt

If you know where an alternative superblock is (use dumpe2fs /dev/sdc | grep -i superblock to get alternative superblocks) then you can try mounting the rescued image using that block (sb):

mount sb=12345 /dev/sdc /mnt

The following command will scan the harddrive for superblocks. It might take upto 48 hours:

e2fsck -cc /dev/md127

Either the superblock or the partition table is likely to be corrupt! Abort < y > ?
Answer n

# resize2fs /dev/md127 # fsck -f /dev/md127

To repair the filesystem using alternate superblock, run:/

fsck.ext4 -p -b superblock -B blocksize /dev/sdc

Another Strategy

If the above does not work then, see if you can find an alternative superblock:

dumpe2fs /dev/sdc | grep -i superblock

This will output something like this:
------------------------------------------------------------------
Primary superblock at 0, Group descriptors at 1-6
Backup superblock at 123456, Group descriptors at 12345-6789

To repair the filesystem using alternate superblock, run

fsck -b 12345 /dev/sdb2

Free blocks count wrong for group #999 (55555, counted=99999).
Fix? yes
Free blocks count wrong for group #1200 (66666, counted=3337).
Fix? yes

Keep saying yes till all are fixed.
Now use the backup superblock stored at 123456 to mount the partition,

mount sb=123456 /dev/sdb2 /mnt

or

fsck.ext4 -p -b superblock -B blocksize device

As an aside, you can find badblocks, but it will take 5 to 6 hours at least:

badblocks /dev/sda

Testing a Hard Drive

Install Smartmontools

sudo apt-get install smartmontools

Make sure SMART is enable on drive /dev/sda:

sudo smartctl -s on /dev/sda

Initiate test:

sudo smartctl -t long /dev/sda

View Results

sudo smartctl -l selftest /dev/sda

For IDE drives:

sudo smartctl -a /dev/sda

For SATA drives

sudo smartctl -a -d ata /dev/sda

APPENDIX

Reference Section