为什么 fsck 对我来说不起作用?

为什么 fsck 对我来说不起作用?

我的硬盘上有一些坏扇区,所以我按照网站

为了检测坏扇区,我执行了以下命令:

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

这很好,下一步是运行以下命令:

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

由于某种原因,这对我不起作用并给我以下消息:

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$ 

为什么这不起作用?

答案1

您不想使用badblocks。现代驱动器是智能的,能够报告错误并将任何坏扇区重新映射到备用池。但是,驱动器只能在您尝试写入扇区时重新映射扇区。如果磁盘实用程序报告驱动器有几个待处理的重新分配,那么您可以通过将零写入整个磁盘来强制它们发生:

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

此后,应该不再有待处理的扇区。如果扇区受到物理损坏,则重新分配的扇区数量将会增加。如果数据只是被打乱了,则向介质写入零即可纠正,而无需重新分配扇区。

如果最终仍有任何扇区处于待处理或脱机_无法纠正状态,或者有多个重新分配的扇区,则需要更换驱动器。

答案2

e2fsck(如果是 ext2/3/4 文件系统,则由 fsck 包装器调用的应用程序)的手册页说明如下

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.

因此只需使用

sudo e2fsck -c /dev/sda5

相关内容