Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

On my server I have a 4 disk RAID-5 configuration. One of the drives fails the S.M.A.R.T. test. The array has not yet been declared as degraded but the disk shows up as needing replacement.

I don't want to spent money on a new drive just because it has a couple of bad blocks.

So, I've been thinking, if I remove the drive from the array, reformat it and then re-insert it again. Will I be able to re-initialise it and will the bad sectors get mapped out automagically?

Or do I need to do something extra?

(Please note: I'm using a headless, X-less server. So, only CLI available.)

Also, due to input from others, I already pulled the drive and replaced it by the spare. The array is repairing.

So, the disk is sitting on the shelf now with me wondering: If I put it back later, will the bad blocks be mapped out?

share|improve this question
    
You will need to be more specific. Edit your question to include the full smart information from smartctl -a. –  psusi Feb 23 at 15:23
    
The problem has become somewhat more academic :-D I've updated the question. –  Mausy5043 Feb 23 at 16:17

1 Answer 1

up vote 1 down vote accepted

See if these are what you're looking for:

sudo e2fsck -c /dev/sdXY

(replace sdXY with that of the target device)

The -c option causes e2fsck to use badblocks program to do a read-only scan (eqvt. to using badblocks with the -n switch) of the device in order to find any bad blocks. If any bad blocks are found, they are added to the bad block inode to prevent them from being allocated to a file or directory. If this option -c is specified twice (be forewarned that this option erases data), like in:

sudo e2fsck -cc /dev/sdXY

then the bad block scan will be done using a non-destructive read-write (eqvt. to using badblocks with the -w switch) test. If you want to do write-mode testing on an existing file system, use the -n option instead. It is slower, but it will preserve your data.

To print the blocks which are reserved as bad in the filesystem, you can use:

sudo dumpe2fs -b /dev/sdaX

(for the complete disk)

sudo dumpe2fs -b /dev/sdaXY

(for a particular partition of the disk)

share|improve this answer
    
Sorry I can't upvote your answer, because I don't have enough reps... Anyway, thanks for the answer. I didn't know about the dumpe2fs command. I can put the disk in another computer later this week and see if I can get some more info out of it. But the question remains, if I re-partition/format the drive will the bad blocks remain mapped out when it is re-assimilated into the hive^H^H^H^H array? –  Mausy5043 Feb 23 at 17:09
    
@Mausy5043 the bad block inode information like any inode number information should be written in the specific storage disk partition.. so I reckon the information will be portable, and care would be taken by the system so that such inodes are not allocated for use.. –  precise Feb 23 at 17:52
    
Thank you very much. –  Mausy5043 Feb 23 at 18:00
3  
There are a few problems with this answer: 1) you don't want to do this these days since the drive internally will remap bad sectors ( when you write to them ) if they really are bad so you don't want the filesystem marking them bad and not using them, and 2) This question is about a raid array, so you certainly don't want to run e2fsck on individual drives. At best you want to run badblocks -n for a non destructive read/write test. This will rewrite every block on the disk, forcing the drive to remap any bad blocks. You want to do this on an individual drive after stopping the raid. –  psusi Feb 23 at 22:57
1  
OP already has the concerned disk pulled out of the array.. so I would assume that he should be able to get the bad blocks remapped and plug it back into the array.. and as OP is okay with the idea of reformatting the disk too, e2fsck -cc ... would also an option for him.. good points though @psusi, thanks.. –  precise Feb 24 at 4:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.