How to delete metadata left from LSI 3ware controller

We have many servers with hardware controllers like LSI 3Ware. From time to time disks degrade and we have to change it with another one. However we found a little problem when trying to use unwiped disk in LSI 3ware controller, which was previously used in another 3ware controller. The following error appears in the disk status – Unsupported_DCB.

LSI 3Ware stores the RAID information on the disks. The main advantage is that we can replace controller without having to reconfigure it. That information is stored on a section called Disk Control Block (DCB). There are two versions of DCB – on both of them the information is stored at the end of the disk. DCB appears to be 1024 LBAs long (1024 * 512 bytes per sector = 512KiB). Additionally in one of the versions there is a copy of the DCB as the first 1024 LBAs of the disk.

So we have to wipe that info before replacing disk from one controller to another. Here’s a simple script that do it for you:

#!/bin/bash
DISK=sdz
LBAS=$(cat /sys/block/$DISK/size)
dd if=/dev/zero of=/dev/$DISK bs=512 count=1024
dd if=/dev/zero of=/dev/$DISK bs=512 seek=$(($LBAS-1024)) count=1024

Very Important!!! Please replace sdz with the device name. I advice you to triple check the disk before executing the script. I am not responsible if you delete another disk by mistake.

rescue hdd with I/O errors

No matter how often I repeat people to keep important things in more than one place … I always hear “no problem”

While you do not squawk at 05:00 AM to recover data from a “burned disc” with status “URGENTLY”

The problem was that when you trying to access the disk at file level…you get a solid  flooding in screen and syslog with an I/O error:

end_request: I / O error, dev sda, sector 3500097

Isn’t that a wonderful thing or what?

It is time to discuss what are the differences and similarities tricks that can make using dd, dd_rescue, dd_rhelp

The main similarity is that all of this tools  examine the hard disk block level and not really interested in the file system, files and so on.

dd : will make a copy of a disk drive with errors, if you set “conv=noerror” so it will keep going after errors. The catch is that it just *removes* the erroneous sectors from its output,
as if they didn’t exist, which totally screws up the file system image. Fsck will tell you just how unhappy it is with such an image; it’s unrecoverable without massive manual work, shifting big blocks of data around.

dd_rhelp :  is a complex shell script that runs dd_rescue many times, trying to be strategic about copying the drive. It copies forward until it gets errors, then jumps forward by a big jump looking for either the end of the drive, or more easy-to-read stuff. Once it finds the end of the drive, then it starts working backward, trying to close up the “hole” that it hasn’t read yet. As it encounters errors, it skips around looking for more error-free parts of the drive. It only reads each sector once. It reads the logfile output of dd_rescue to see what happened and to figure out what to do next.

dd_rescue : It reads and copies bigger blocks until it sees an error, then slows down and goes back, and reads single sectors. After a while it speeds up again. It can also read backward, and can quit after it gets some specified number of errors.If it gets an error reading a sector, it doesn’t write to that sector of the output file, but it skips past it to write the next good one, so everything stays in sync. It seeks the input and output in parallel so it makes an exact copy of the parts that it can read.

so lets try with:

dd_rescue /dev/bad_hdd /dev/new_hdd

or if we want to use an image file

dd_rescue /dev/bad_hdd /mnt/new_hdd/image_of_bad_hdd.img

the process will take hours of reading/writing and rasping ….and if it done correctly try to check/fix your filesystem with fsck:

fsck -y /dev/new_hdd

or an image

fsck -y /mnt/new_hdd/image_of_bad_hdd.img

you will see long output in screen …all you can do is to watch and pray for it

Then reboot…then pray even harder 🙂

Read more at: http://ubuntu-rescue-remix.org/node/51