0

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?

oshirowanen
  • 4,047

2 Answers2

1

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.

psusi
  • 38,031
1

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