0

During boot time I found that my hard disk had logical errors in different sectors. I did my research and ran this command:

sudo badblocks -sv /dev/sda1 > bad-blocks-result

This command created a file in my home directory called 'bad-blocks-result' which contains a series of numbers, which I guess are bad sectors.

What procedure should I follow next to correct my hard disk?

1 Answer 1

2

For each bad block number, first use dd to verify that it is bad ( and you didn't make some mistake somewhere ):

sudo dd if=/dev/sda1 skip=##### count=1 of=/dev/null iflag=direct bs=1024

If that comes back with an error, then you are looking in the right spot.. now it's time to correct it:

sudo dd if=/dev/zero of=/dev/sda1 seek=###### count=1 oflag=direct bs=1024

If the second comes back without an error, you should be able to retry the first command and it should also now not error. Repeat for each bad block number listed in the file.

Make sure to type the commands exactly as shown ( substituting the block number for the #### ) or you can destroy your data

You also might want to run sudo smartctl -a /dev/sda to read the SMART status of the drive. Of note are the raw values for the reallocated count and pending. If you fixed all of the bad sectors, the pending count will have returned to zero. If they were remapped, the reallocated count will have gone up. If this is more than a handful you probably want to replace the drive as it is likely to get worse. If the reallocated count didn't go up, then there is nothing physically wrong with the drive.

At this point you also should boot into rescue mode and run a full fsck on the volume to make sure that checks out.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .