fsck 针对坏块重新建立索引

fsck 针对坏块重新建立索引

我有一个外部驱动器,它肯定会出故障(4 年以上)。我在读取/写入时不断收到 I/O 错误,但在更换它之前,我确实想尝试延长它的使用寿命。

我知道我可以用它fsck -c /dev/sdX标记坏块,但这是否也会重新索引这些块周围的文件系统?我搜索了很久,还没有找到确切的答案。

当我在未安装的驱动器上尝试 fsck -c 时,我收到一个错误的超级块消息,因此我考虑重新格式化,但就 I/O 错误而言,这在过去也没有帮助,我之前已经做过几次了。

编辑:澄清一下,这是一个旧的 Verbatim 外置硬盘,SATA 硬盘,装在一个外壳中,外壳上有一个 SATA-to-USB 和一个电源适配器。目前,它只是一个玩具硬盘(我已将其他所有内容备份到 NAS 上),连接到 Raspberry Pi 上供摆弄。

就问题而言,我主要想的是:如果我有一个损坏的块,导致读取和写入数据失败(根据 dmesg 和 badblocks,是否可以将该块标记为“死”并使用下一个好块进行读取/写入?

答案1

尝试执行磁盘写入时(仅限)会重新映射坏块。重新映射坏块时,该块中的数据将放入另一个备用好块中。根据坏块的数量,仍可能会发生文件损坏。

对磁盘进行坏块修复的正确方法是:

注意:不要中止坏块扫描!

注意:不要对 SSD 造成坏块

注意:请先备份您的重要文件!

注意:这将花费很多小时

注意:您可能面临硬盘故障

在“尝试 Ubuntu”模式下启动 Ubuntu Live DVD/USB。

terminal...

sudo fdisk -l# 识别所有“Linux 文件系统”分区

sudo e2fsck -fcky /dev/sdXX# 只读测试

或者

sudo e2fsck -fccky /dev/sdXX# 非破坏性读写测试(受到推崇的)

-k 很重要,因为它会保存之前的坏块表,并将任何新的坏块添加到该表中。如果没有 -k,您将丢失所有之前的坏块信息。

-fccky 参数...

   -f    Force checking even if the file system seems clean.

   -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 direc‐
         tory.  If this option is specified twice, then the bad block scan
         will be done using a non-destructive read-write test.

   -k    When combined with the -c option, any existing bad blocks in the
         bad blocks list are preserved, and any new bad blocks found by
         running badblocks(8) will be added to the existing bad blocks
         list.

   -y    Assume an answer of `yes' to all questions; allows e2fsck to be
         used non-interactively. This option may not be specified at the
         same time as the -n or -p options.

相关内容