驱动器的最后一个块成为坏扇区的可能性有多大?

驱动器的最后一个块成为坏扇区的可能性有多大?

这是这个,将磁盘归零dd会导致驱动器末端出现错误。

然后我开始尝试确定这是否是一个坏扇区(正如所建议的那样),而不是硬盘或我所运行的环境的某种问题。

跑步:

badblocks -o ~/.badblocks_in_X_full -vws /dev/sda 976762584 950000000

...给出输出:

Checking for bad blocks in read-write mode
From block 950000000 to 976762584
Testing with pattern 0xaa: Weird value (4294967295) in do_writerrors)
done
Reading and comparing: done
Testing with pattern 0x55: Weird value (4294967295) in do_writeerrors)
done
Reading and comparing: done
Testing with pattern 0xff: Weird value (4294967295) in do_writeerrors)
done
Reading and comparing: done
Testing with pattern 0x00: Weird value (4294967295) in do_writeerrors)
done
Reading and comparing: done
Pass completed, 1 bad blocks found. (1/0/0 errors)

生成的输出文件将坏块列为块 976762584。

正在cat /proc/partitions显示dev/sda有 976762584 个区块。

换句话说,badblocks就是报告驱动器的最后一个块是坏的。

我知道这是可能的驱动器的最后一个块/扇区可能是驱动器上唯一的坏扇区,但在我看来,这种情况发生的可能性很小,更有可能是其他原因造成的。

所报告的这个坏扇区是badblocks真实的吗,或者更可能只是硬件或环境问题的征兆?

答案1

虽然这不是对你的问题的直接回答,但它可能会给你一些启发。

首先,由于某种原因,badblocks似乎无论如何都会报告“最后一个块 + 1”的坏块(而对于“最后一个块 + 2”或更高,它正确地返回寻道错误):

[tom@alarm ~]$ sudo badblocks /dev/mmcblk0 -b 512 -v 31116287 31116287
Checking blocks 31116287 to 31116287
Checking for bad blocks (read-only test): done                                   

Pass completed, 0 bad blocks found. (0/0/0 errors)
[tom@alarm ~]$ sudo badblocks /dev/mmcblk0 -b 512 -v 31116288 31116288
Checking blocks 31116288 to 31116288
Checking for bad blocks (read-only test): 31116288
done
Pass completed, 1 bad blocks found. (1/0/0 errors)
[tom@alarm ~]$ sudo badblocks /dev/mmcblk0 -b 512 -v 31116289 31116289
Checking blocks 31116289 to 31116289
Checking for bad blocks (read-only test): badblocks: Invalid argument during seek
done
Pass completed, 0 bad blocks found. (0/0/0 errors)
[tom@alarm ~]$ sudo badblocks /dev/mmcblk0 -b 512 -v 31116290 31116290
Checking blocks 31116290 to 31116290
Checking for bad blocks (read-only test): badblocks: Invalid argument during seek
done
Pass completed, 0 bad blocks found. (0/0/0 errors)
[tom@alarm ~]$

dd没有这样的问题:

[tom@alarm ~]$ sudo dd if=/dev/mmcblk0 of=/dev/null skip=31116287
1+0 records in
1+0 records out                                                                  
512 bytes copied, 0.0254859 s, 20.1 kB/s
[tom@alarm ~]$ sudo dd if=/dev/mmcblk0 of=/dev/null skip=31116288
0+0 records in
0+0 records out
0 bytes copied, 0.000534631 s, 0.0 kB/s
[tom@alarm ~]$ sudo dd if=/dev/mmcblk0 of=/dev/null skip=31116289
dd: /dev/mmcblk0: cannot skip: Invalid argument
0+0 records in
0+0 records out
0 bytes copied, 0.000737962 s, 0.0 kB/s
[tom@alarm ~]$ sudo dd if=/dev/mmcblk0 of=/dev/null skip=31116290
dd: /dev/mmcblk0: cannot skip: Invalid argument
0+0 records in
0+0 records out
0 bytes copied, 0.000694995 s, 0.0 kB/s
[tom@alarm ~]$ sudo dd if=/dev/mmcblk0 of=/dev/null iflag=count_bytes,skip_bytes 
count=1M skip=15192M
2048+0 records in
2048+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.0612828 s, 17.1 MB/s
[tom@alarm ~]$ sudo dd if=/dev/mmcblk0 of=/dev/null iflag=count_bytes,skip_bytes 
count=1M skip=15193M
1024+0 records in
1024+0 records out
524288 bytes (524 kB, 512 KiB) copied, 0.029878 s, 17.5 MB/s
[tom@alarm ~]$ sudo dd if=/dev/mmcblk0 of=/dev/null iflag=count_bytes,skip_bytes 
count=1M skip=15194M
dd: /dev/mmcblk0: cannot skip: Invalid argument
0+0 records in
0+0 records out
0 bytes copied, 0.000814785 s, 0.0 kB/s
[tom@alarm ~]$ sudo dd if=/dev/mmcblk0 of=/dev/null iflag=count_bytes,skip_bytes 
count=1M skip=15195M
dd: /dev/mmcblk0: cannot skip: Invalid argument
0+0 records in
0+0 records out
0 bytes copied, 0.000700151 s, 0.0 kB/s
[tom@alarm ~]$

无论如何,如果您想检查某个特定块是否坏了和/或比较和的结果badblocksdd最好使用逻辑块大小(通常为 512 字节)进行测试,并且不要使用超过驱动器实际大小的值。这两条信息都可以通过以下方式获取fdisk -l

[tom@alarm ~]$ sudo fdisk -l /dev/mmcblk0
Disk /dev/mmcblk0: 14.86 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
[tom@alarm ~]$

另外,在指定特定块时,请确保从 0 开始计数,并且在指定块数时不要少算一个(例如 for count// in )skipseekdd

编辑:实际上,“最后一个块 + 1” 是一个特殊情况,这是很自然的,因为搜索整个驱动​​器(包括最后一个块)是有效的。只是没有更多空间可以读取/写入。但对于“最后一个块 + 2”或更高,即使搜索也会超出驱动器的末尾,因此会出现搜索错误。可能还值得注意的是,currentbadblocks并不确切检查写入错误是什么(而只是向其调用者返回写入长度为 0):https://github.com/tytso/e2fsprogs/blob/v1.45.4/misc/badblocks.c#L443

相关内容