我有一个连接到 Debian GNU/Linux 服务器的 USB 硬盘。我正在尝试使用以下命令对其进行格式化(NTFS):
# mkntfs -v /dev/sdd1
这需要几个小时,因为它也会检查磁盘。检查时,dmesg -T
显示以下内容:
[Wed Jan 12 15:22:53 2022] sd 9:0:0:0: [sdd] Attached SCSI disk
[Wed Jan 12 18:03:26 2022] usb 1-4: USB disconnect, device number 5
[Wed Jan 12 18:03:26 2022] blk_update_request: I/O error, dev sdd, sector 621745808 op 0x1:(WRITE) flags 0x104000 phys_seg 240 prio class 0
[Wed Jan 12 18:03:26 2022] Buffer I/O error on dev sdd1, logical block 621743760, lost async page write
[Wed Jan 12 18:03:26 2022] Buffer I/O error on dev sdd1, logical block 621743761, lost async page write
(...and so on for a few lines, then)
[Wed Jan 12 18:03:26 2022] blk_update_request: I/O error, dev sdd, sector 621746048 op 0x1:(WRITE) flags 0x104000 phys_seg 240 prio class 0
[Wed Jan 12 18:03:26 2022] blk_update_request: I/O error, dev sdd, sector 621746288 op 0x1:(WRITE) flags 0x100000 phys_seg 8 prio class 0
[Wed Jan 12 18:03:26 2022] blk_update_request: I/O error, dev sdd, sector 621746296 op 0x1:(WRITE) flags 0x800 phys_seg 16 prio class 0
(...and so on for a few lines, then)
[Wed Jan 12 18:03:31 2022] buffer_io_error: 9015384 callbacks suppressed
(...other errors...)
看着大量的错误消息,我会说 HDD 几乎死了,但将它附加到 Windows PC 似乎可以工作。此外usb 1-4: USB disconnect, device number 5
,dmesg
在其他错误之前出现的第一个错误( .
但是我在dmesg
输出方面不是很有经验,所以很可能我读错了。
编辑:根据 NiKiZe 的要求,这里是输出smartctl -a /dev/sdd
:
# smartctl -a /dev/sdd
smartctl 6.6 2017-11-05 r4594 [x86_64-linux-5.10.0-3-amd64] (local build)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Western Digital Blue Mobile
Device Model: WDC WD10SPCX-00KHST0
Serial Number: WD-WXF1A95F0J3X
LU WWN Device Id: 5 0014ee 65b7e0332
Firmware Version: 01.01A01
User Capacity: 1.000.204.886.016 bytes [1,00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: 5400 rpm
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-2 (minor revision not indicated)
SATA Version is: SATA 3.0, 6.0 Gb/s (current: 1.5 Gb/s)
Local Time is: Thu Jan 13 11:04:19 2022 CET
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART Status not supported: Incomplete response, ATA output registers missing
SMART overall-health self-assessment test result: PASSED
Warning: This result is based on an Attribute check.
General SMART Values:
Offline data collection status: (0x00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: (16080) 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: ( 184) minutes.
Conveyance self-test routine
recommended polling time: ( 5) minutes.
SCT capabilities: (0x7035) SCT Status 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 200 051 Pre-fail Always - 0
3 Spin_Up_Time 0x0027 190 184 021 Pre-fail Always - 1500
4 Start_Stop_Count 0x0032 081 081 000 Old_age Always - 19048
5 Reallocated_Sector_Ct 0x0033 200 200 140 Pre-fail Always - 0
7 Seek_Error_Rate 0x002e 200 200 000 Old_age Always - 0
9 Power_On_Hours 0x0032 073 073 000 Old_age Always - 20415
10 Spin_Retry_Count 0x0032 100 100 000 Old_age Always - 0
11 Calibration_Retry_Count 0x0032 100 100 000 Old_age Always - 0
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 188
192 Power-Off_Retract_Count 0x0032 200 200 000 Old_age Always - 43
193 Load_Cycle_Count 0x0032 187 187 000 Old_age Always - 41054
194 Temperature_Celsius 0x0022 119 095 000 Old_age Always - 28
196 Reallocated_Event_Count 0x0032 200 200 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 200 200 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 100 253 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 200 200 000 Old_age Always - 0
200 Multi_Zone_Error_Rate 0x0008 100 253 000 Old_age Offline - 0
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]
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.
假设这个 HDD 确实出现故障,并且其中的错误消息dmesg
是针对真正的坏扇区,为什么会在坏扇区消息之前而不是之后dmesg
显示断开连接?
断开连接首先发生,然后您会得到由断开连接引起的混合错误,其中生成磁盘写入的各个层会注意到有问题。
大多数 I/O 以具有磁盘支持的“脏”内存页面的形式发生,内核最终会在写入被应用程序确认很久之后刷新到磁盘,并且唯一的驱动程序层是仍然对请求感兴趣的是内存子系统(想知道是否可以释放页面)和文件系统(需要在写入数据后生成更多写入以更新元数据)——上面的任何内容都已拆除已经。
一些请求不通过内存子系统(例如 SMART 状态查询),一些请求(如读取)可能只附加到内存子系统,因为文件系统已经查找了块映射并且不再需要涉及。
因此,由于断开连接而收到的错误消息没有特定的顺序——它们发生在由于设备离线而生成、提交和拒绝请求时。如果某些请求之间存在因果关系(例如在中止数据传输后反映新状态的日志条目——毕竟,日志可能在不同的设备上),那么这就定义了一些顺序。
我可能会尝试在适当的 SATA 端口上使用磁盘,并通过良好的电源供电——USB 到 SATA 机箱中的电压转换器通常有点狡猾。
请考虑驱动器死机。
通常格式化驱动器不需要那么长时间。然而,坏块的重试和重置确实需要时间。
当然,这可能是由于电源不良或其他原因。
并非所有 USB 设备都支持智能直通,但请尝试:
smartctl -a /dev/sdd
特别寻找Reallocated_Sector_Ct
,Reallocated_Event_Count
,Current_Pending_Sector
,Offline_Uncorrectable
如果其中任何一个具有RAW_VALUE
除 之外的其他设备0
,我会尽量避免将磁盘用于非重要数据以外的任何内容。如果磁盘上没有数据,您可以随时尝试擦除它,使用类似(此处小心!!!)之类的方法
dd if=/dev/zero of=/dev/sdd bs=4M status=progress
。之后您将需要重新创建分区表。