我怎么知道硬盘上坏扇区的数量?

我知道如何检查/修复我的硬盘驱动器,但我不知道如何查看硬盘上坏扇区的数量。

PS看起来我的硬盘很快就会死:-(

有两种方法可以检测Linux中的坏扇区:您可以使用磁盘实用程序(gui),也可以使用badblocks命令检查硬盘是否存在坏扇区:

sudo badblocks -v /dev/{device} 

这应该回答这个问题,但对于其他任何对如何标记它们感兴趣的人来说,可以用2个简单的命令来完成…

您将坏块添加到文件中…

 sudo badblocks /dev/sdb > {/dir/to/filename} 

然后告诉fsck将这些标记为无法使用…

 sudo fsck -l {/dir/to/filename} /dev/{device} 

例如,使用fsck.ext3(e2fsck)并使用-cc选项

 -c This option causes e2fsck to use badblocks(8) program to do a read-only scan 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 is specified twice, then the bad block scan will be done using a non-destructive read-write test.` 

fsck -cc / dev / sda1