sudo badblocks -v /dev/{device}
这应该回答了问题,但对于其他对如何标记它们感兴趣的人来说,可以使用两个简单的命令来完成...
您将坏块添加到一个文件中...
sudo badblocks /dev/sdb > {/dir/to/filename}
然后告诉fsck将这些标记为不可用的...
sudo fsck -l {/dir/to/filename} /dev/{device}
-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
e2fsck有一个-c选项,它会自动调用badblocks并处理块大小。如果按照你的方式操作,必须非常小心确保它们匹配。 - Martin Uedingbadblocks+fsck来标记坏块可能是危险的。根据badblocks手册中的说明:"重要提示:如果badblocks的输出将被传递给e2fsck或mke2fs程序,请务必正确指定块大小,因为生成的块编号非常依赖于文件系统所使用的块大小。因此,强烈建议用户不直接运行badblocks,而是使用e2fsck和mke2fs程序的-c选项。"请参考@john-mehorter的回答。 - sierrasdetandil