我正在运行带有 Openmediavault 5 的 NAS,并且我以前曾使用 3 个 5TB WD Red 硬盘设置了 RAID5(使用 mdadm)(有关 mdadm 输出的详细信息,请参阅下文)。我将整个磁盘用作 RAID 的成员。如果我不得不再次这样做,我会在每个磁盘上创建一个分区,然后再将它们添加到 RAID,但这不是本讨论的内容。
不幸的是,我的一个硬盘(/dev/sdb)似乎开始出现故障,因为当前待处理部门和脱机_无法纠正SMART 值开始增加(见下面的 smartctl 输出)。此外,smartmontools 自检(短和长)由于读取错误而失败。我将尽快更换故障磁盘,但在更换之前,我想查看我的 RAID5 文件系统上是否有任何文件受到影响。
我使用 badblocks 命令查找无法成功读取的扇区。驱动器上发现无法读取的badblocks -b 4096 -o ~/sdb_badblocks.txt -sv /dev/sdb
扇区(使用 4096 字节块大小)是:/dev/sdb
984123818
984124149
984124809
984125140
984125470
984125801
我已使用dd
来确认这些扇区确实无法读取。为此,我使用了 ,dd if=/dev/sdb bs=4096 count=1 skip=984123818 | hexdump -C
这导致上述所有扇区的输出如下:
dd: error reading '/dev/sdb': Input/output error
0+0 records in
0+0 records out
0 bytes copied, 9,71509 s, 0,0 kB/s
我已经使用mdadm --examine-badblocks /dev/sdb
(针对阵列的所有三个成员:sda、sdb 和 sdd)来检查 mdadm 是否发现任何坏块,但所有三个 HDD 的输出都是相同的:
Bad-blocks list is empty in /dev/sdb
现在我想知道我的 RAID ext4 文件系统上的哪些文件受到这些坏块的影响。如果该磁盘有自己的文件系统,我就会知道如何使用tune2fs
和debugfs
查找 inode 和文件(来自https://www.smartmontools.org/wiki/BadBlockHowto)。
但是,如何在 RAID5 ext4 文件系统上找到与 RAID 成员上的坏块相关的文件(如果有的话)?如何将找到的扇区号转换/dev/sdb
为文件系统中的扇区号/dev/md127
?
预先感谢您的帮助!
以下是有关我的系统的一些重要输出和信息:
smartctl -ia /dev/sdb
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-5.10.0-0.bpo.12-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Western Digital Red
Device Model: WDC WD50EFRX-68L0BN1
Serial Number: WD-WX31D88FVFEK
LU WWN Device Id: 5 0014ee 2bb16b3fc
Firmware Version: 82.00A82
User Capacity: 5.000.981.078.016 bytes [5,00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5700 rpm
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-2, ACS-3 T13/2161-D revision 3b
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Wed Oct 12 20:22:11 2022 CEST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
General SMART Values:
Offline data collection status: (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 121) The previous self-test completed having
the read element of the test failed.
Total time to complete Offline
data collection: (52380) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 524) minutes.
Conveyance self-test routine
recommended polling time: ( 5) minutes.
SCT capabilities: (0x303d) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f 200 199 051 Pre-fail Always - 24
3 Spin_Up_Time 0x0027 200 196 021 Pre-fail Always - 8983
4 Start_Stop_Count 0x0032 100 100 000 Old_age Always - 32
5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0
7 Seek_Error_Rate 0x002e 100 253 000 Old_age Always - 0
9 Power_On_Hours 0x0032 057 057 000 Old_age Always - 31998
10 Spin_Retry_Count 0x0032 100 253 000 Old_age Always - 0
11 Calibration_Retry_Count 0x0032 100 253 000 Old_age Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 32
192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 14
193 Load_Cycle_Count 0x0032 199 199 000 Old_age Always - 5704
194 Temperature_Celsius 0x0022 120 108 000 Old_age Always - 32
196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 8
198 Offline_Uncorrectable 0x0030 200 200 000 Old_age Offline - 8
199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0008 200 200 000 Old_age Offline - 9
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Short offline Completed: read failure 90% 31990 3542399240
# 2 Short offline Completed: read failure 90% 31966 3481656353
# 3 Extended offline Completed: read failure 90% 31962 3481656358
# 4 Short offline Completed without error 00% 31950 -
# 5 Extended offline Completed: read failure 90% 31937 3481656358
# 6 Extended offline Completed: read failure 20% 31928 3578023248
# 7 Extended offline Completed: read failure 90% 31920 3542399240
# 8 Extended offline Completed: read failure 90% 31920 3481656353
# 9 Short offline Completed: read failure 90% 31918 3481656358
#10 Short offline Completed: read failure 90% 31894 3481656354
#11 Short offline Completed without error 00% 31870 -
#12 Short offline Completed without error 00% 31846 -
#13 Short offline Completed without error 00% 31822 -
#14 Short offline Completed without error 00% 31798 -
#15 Short offline Completed without error 00% 31774 -
#16 Short offline Completed without error 00% 31750 -
#17 Short offline Completed without error 00% 31726 -
#18 Short offline Completed without error 00% 31702 -
#19 Short offline Completed without error 00% 31678 -
#20 Short offline Completed without error 00% 31654 -
#21 Short offline Completed without error 00% 31630 -
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
uname -a
Linux HomeNAS 5.10.0-0.bpo.12-amd64 #1 SMP Debian 5.10.103-1~bpo10+1 (2022-03-08) x86_64 GNU/Linux
cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid1] [raid10]
md127 : active raid5 sdd[5] sda[3] sdb[4]
9767278592 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
unused devices: <none>
blkid
/dev/nvme0n1p1: UUID="649e3fe2-c351-4bd6-9e2f-38243f3f22d4" TYPE="ext4" PARTUUID="48c5342c-01"
/dev/nvme0n1p5: UUID="42901d13-899e-48dd-a53b-fe708a8017dd" TYPE="swap" PARTUUID="48c5342c-05"
/dev/sdd: UUID="bb8b3798-d160-71b4-cc60-bc8fdc8e0761" UUID_SUB="b2fa27d2-2d4d-cf14-cd80-cf18e5b0fcab" LABEL="HomeNAS:NAS" TYPE="linux_raid_member"
/dev/sdb: UUID="bb8b3798-d160-71b4-cc60-bc8fdc8e0761" UUID_SUB="bbc4815f-51af-de9f-2ced-e882c84fc3da" LABEL="HomeNAS:NAS" TYPE="linux_raid_member"
/dev/sdc1: UUID="8bb12818-d02e-40fe-b92e-f20f81377ae1" TYPE="ext4" PARTUUID="4e335cee-ed5e-4c04-8a57-d2b271481310"
/dev/md127: UUID="bd5ef96f-5587-4211-95c0-10219985ff6d" TYPE="ext4"
/dev/sda: UUID="bb8b3798-d160-71b4-cc60-bc8fdc8e0761" UUID_SUB="4624daa6-aa5d-b450-a4fe-3dd5f4e64e52" LABEL="HomeNAS:NAS" TYPE="linux_raid_member"
/dev/nvme0n1: PTUUID="48c5342c" PTTYPE="dos"
fdisk -l
Disk /dev/nvme0n1: 119,2 GiB, 128035676160 bytes, 250069680 sectors
Disk model: WDC PC SN520 SDAPMUW-128G
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x48c5342c
Device Boot Start End Sectors Size Id Type
/dev/nvme0n1p1 2048 216754175 216752128 103,4G 83 Linux
/dev/nvme0n1p2 216756222 250068991 33312770 15,9G 5 Extended
/dev/nvme0n1p5 216756224 250068991 33312768 15,9G 82 Linux swap / Solaris
Disk /dev/sdd: 4,6 TiB, 5000981078016 bytes, 9767541168 sectors
Disk model: WDC WD50EFRX-68L
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/sdb: 4,6 TiB, 5000981078016 bytes, 9767541168 sectors
Disk model: WDC WD50EFRX-68L
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/sdc: 7,3 TiB, 8001563222016 bytes, 15628053168 sectors
Disk model: WDC WD80EFAX-68K
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 21E78FD8-C64D-4B35-B0DE-81AB66227A51
Device Start End Sectors Size Type
/dev/sdc1 2048 15628053134 15628051087 7,3T Linux filesystem
Disk /dev/sda: 4,6 TiB, 5000981078016 bytes, 9767541168 sectors
Disk model: WDC WD50EFRX-68L
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/md127: 9,1 TiB, 10001693278208 bytes, 19534557184 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 524288 bytes / 1048576 bytes
mdadm --detail --scan --verbose
ARRAY /dev/md/NAS level=raid5 num-devices=3 metadata=1.2 name=HomeNAS:NAS UUID=bb8b3798:d16071b4:cc60bc8f:dc8e0761
devices=/dev/sda,/dev/sdb,/dev/sdd
mdadm --detail /dev/md127
/dev/md127:
Version : 1.2
Creation Time : Sat Mar 12 17:22:49 2016
Raid Level : raid5
Array Size : 9767278592 (9314.80 GiB 10001.69 GB)
Used Dev Size : 4883639296 (4657.40 GiB 5000.85 GB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Wed Oct 12 01:02:18 2022
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 512K
Consistency Policy : resync
Name : HomeNAS:NAS (local to host HomeNAS)
UUID : bb8b3798:d16071b4:cc60bc8f:dc8e0761
Events : 997
Number Major Minor RaidDevice State
4 8 16 0 active sync /dev/sdb
5 8 48 1 active sync /dev/sdd
3 8 0 2 active sync /dev/sda
答案1
在 RAID 设备和单个驱动器之间转换块号取决于所使用的 RAID 5 布局。MDADM RAID 5 可以使用几种不同的布局,但幸运的是,它们都定义得很好,易于理解。在您的例子中,阵列显示它使用左对称布局。您可以在互联网上找到 RAID 扇区计算器(例如https://www.runtime.org/raid-calculator.htm) 将根据 RAID 级别 (5)、块大小、布局和驱动器数量等信息为您计算结果。
但是您还需要每个物理磁盘上数据区域的起始块号。这取决于阵列使用的标头/超级块/元数据版本。您的阵列表示它使用的是 1.2 版,这意味着可以在每个磁盘的起始位置 4k 处找到其超级块。您需要查看此超级块并使用在那里找到的信息来计算数据在驱动器上的实际起始位置(请参阅https://raid.wiki.kernel.org/index.php/RAID_superblock_formats)。
现在到了我主动给你建议的部分!(我相信你在问这个问题的时候就知道了。)正如你已经提到的,如果你能重来一次,你现在会以不同的方式创建数组。你真的应该如果你真的关心这些数据,那就再做一遍,听起来你确实关心。不仅使用驱动器上的分区会更好,而且它是一个非常非常在廉价的 5 TB 机械硬盘上使用 RAID 5 是个坏主意。原因有据可查,通过搜索很容易找到,所以我就不在这里重复了。我很惊讶你的阵列能持续这么久。咬紧牙关,建立一个新阵列。如果你建立一个 SSD 阵列,那么 RAID 5 就没问题了,但如果你使用机械驱动器,你真的想使用 RAID 1、RAID 10 或 RAID 6。(就我个人而言,我甚至不会在今天的大型廉价机械驱动器上使用 RAID 6。我对这些驱动器的建议是 RAID 10。无论如何都不要使用 SMR 驱动器。)