Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 硬碟壞軌修復實戰:e2fsck 檢查、fdisk 重分區、mkfs.ext4 格式化、資料搶救流程

編輯:關於 Linux

硬碟出現 I/O 錯誤、EXT4-fs warning: mounting fs with errors 時,需依嚴重程度分級處理。本文提供從軟體壞軌修復到物理損壞更換的完整 SOP,含指令實例與資料保全優先原則。

硬碟錯誤日誌

故障徵兆 (dmesg / /var/log/messages)

Buffer I/O error on device sdl1, logical block 1415594116
sd 6:0:6:0: [sdl] Sense Key : Medium Error
Add. Sense: Unrecovered read error

分級處理流程

Level 1:檔案系統層面修復 (軟體壞軌/元資料不一致)

umount /hadoop/7
e2fsck -fy /dev/sdl1     # -f 強制檢查, -y 自動回答 yes
mount -L /Hadoop07 /hadoop/7 -t ext4 -o defaults,noatime,nodiratime,noauto

Level 2:重分區 + 重新格式化 (壞軌集中、修復失敗)

fdisk /dev/sdl
  d   # 刪除現有分區
  n   # 新建分區 (預設全磁碟)
  p   # 主分區
  1   # 分區號
  Enter  # 起始磁區預設
  Enter  # 結束磁區預設
  w   # 寫入分區表

mkfs.ext4 -L Hadoop07 /dev/sdl1
mount -L Hadoop07 /hadoop/7 -t ext4 -o defaults,noatime,nodiratime,noauto

Level 3:物理壞軌擴散 → 立即更換硬碟

# 1. 禁止寫入防止資料進一步損壞
chmod 0 /hadoop07

# 2. 搶救資料 (唯讀掛載或 ddrescue)
mount -o ro /dev/sdl1 /mnt/rescue
cp -a /mnt/rescue/* /backup/

# 3. 通知硬體廠商 RMA / 採購替換

關鍵原則

  • 資料優先:任何操作前先唯讀備份關鍵資料。
  • SMART 監控:smartctl -a /dev/sdl 追蹤 Reallocated_Sector_Ct、Current_Pending_Sector。
  • RAID 環境:單顆故障立即標記故障、熱備援重建,切勿在陣列降級時做高風險修復。

遵循分級流程可最大程度保全資料,並快速判斷是否需硬體更換。

Copyright © Windows教程網 All Rights Reserved