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 mount 報錯 "Structure needs cleaning" ?xfs_repair 修復全流程

編輯:關於 Linux

XFS 檔案系統在高負載 IO 測試 (如 fio) 後出現 mount: Structure needs cleaning,表示檔案系統中繼資料不一致。本文說明使用 xfs_repair 修復流程,並強調 修復會導致該分區所有檔案遺失,務必先備份可救資料。

錯誤情境

  • 檔案系統:XFS (掛載於 /home)
  • 觸發操作:fio 多進程壓測
  • 現象:du -hs /home/* 部分檔案報 mount: Structure needs cleaning

修復步驟

  1. 卸載檔案系統 (必須卸載才能修復)
    
    umount /home
    # 若忙碌無法卸載
    fuser -km /home
    umount /home
    
  2. 執行 xfs_repair
    
    xfs_repair /dev/mapper/vg-home   # 或實際裝置路徑 /dev/sda3
    # 過程會輸出 Phase 1~7 掃描修復訊息
    

    ⚠ 警告:xfs_repair 會重建中繼資料,**分區內所有檔案將遺失**,即使 du 仍可見的檔案也不例外。

  3. 重新掛載驗證
    
    mount /home
    ls -la /home
    # 應為空目錄 (lost+found 可能存在)
    

關鍵提醒

  • 修復前務必嘗試備份:若檔案系統仍可部分讀取,優先 cp -a /home /backup/home 或 tar 打包重要資料。
  • xfs_repair -n (乾跑模式) 僅檢查不修改,可先評估損壞程度。
  • 生產環境建議啟用 XFS logbsize、lazycount 等掛載選項降低中繼資料爭用。
  • 定期快照 (LVM/VMware/ZFS) 是防資料遺失的根本對策。

延伸:其他檔案系統修復指令

檔案系統修復指令備註
ext4fsck.ext4 -y /dev/sdX需卸載或唯讀掛載
XFSxfs_repair /dev/sdX**必須卸載**,會清空資料
Btrfsbtrfs check --repair /dev/sdX謹慎使用,可能加劇損壞

xfs_repair 修復流程圖

Copyright © Windows教程網 All Rights Reserved