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.

I have some bad sectors on my hard drive, so I followed the guide from this website

To detect the bad sectors, I did the following command:

sudo badblocks /dev/sda5 > /media/3865-6163/sda5

That worked fine, the next step is to run the following command:

sudo fsck -l /media/3865-6163/sda5 /dev/sda5

For some reason, this does not work for me and gives me the following message:

ubuntu@ubuntu:/media/3865-6163$ sudo fsck -l /media/3865-6163/sda5 /dev/sda5
fsck from util-linux 2.20.1
Usage: fsck.ext4 [-panyrcdfvtDFV] [-b superblock] [-B blocksize]
        [-I inode_buffer_blocks] [-P process_inode_size]
        [-l|-L bad_blocks_file] [-C fd] [-j external_journal]
        [-E extended-options] device

Emergency help:
 -p                   Automatic repair (no questions)
 -n                   Make no changes to the filesystem
 -y                   Assume "yes" to all questions
 -c                   Check for bad blocks and add them to the badblock list
 -f                   Force checking even if filesystem is marked clean
 -v                   Be verbose
 -b superblock        Use alternative superblock
 -B blocksize         Force blocksize when looking for superblock
 -j external_journal  Set location of the external journal
 -l bad_blocks_file   Add to badblocks list
 -L bad_blocks_file   Set badblocks list
ubuntu@ubuntu:/media/3865-6163$ 

Why is this not working?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You don't want to use badblocks. Modern drives are SMART and are capable of reporting errors and remapping any sectors that are bad to a spare pool. The drive can only remap sectors when you try to write to them though. If the disk utility reports that the drive has a few pending reallocations, then you can force them to happen by writing zeros to the whole disk:

sudo dd if=/dev/zero of=/dev/sda

After that, there should be no more pending sectors. If the sectors were physically damaged, the count of reallocated sectors will go up. If the data had simply been scrambled, writing zeros to the media corrected it without the need to reallocate the sector.

If you end up with any sectors that are still pending or offline_uncorrectable, or more than a few reallocated sectors, you need to replace the drive.

share|improve this answer
    
Note: for reasons I give here, it's not a good idea to continue to use a drive that has bad sectors for any longer than necessary. To me, that means any reallocated sectors - even one or two may be a sign of things to come. –  neon_overload Jul 31 '13 at 2:13
    
@neon_overload, sometimes there isn't anything physically wrong with the disk and you will end up with zero pending, uncorrectable, or reallocated, in which case the drive is perfectly fine to keep using. If some are reallocated then you certainly need to keep an eye on it; doing regular long SMART tests. Sometimes the damage spreads, and sometimes it doesn't. You have to make your own risk tolerance assessment. –  psusi Aug 2 '13 at 23:25

Well the manpage for e2fsck (the application getting called by the fsck wrapper if its an ext2/3/4 filesystem) states the following

Note that the block numbers are based on  the  blocksize  of  the  filesystem.
Hence,  badblocks(8) must be given the blocksize of the filesys‐
tem in order to obtain correct results.  As a result, it is much
simpler  and safer to use the -c option to e2fsck, since it will
assure that the correct parameters are passed to  the  badblocks
program.

So just use

sudo e2fsck -c /dev/sda5
share|improve this answer

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.