關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • 檢查及修復檔案系統指令 — e2fsck

    Posted on June 17th, 2006 Sam Tang No comments

    在 Linux 裡面有一個 e2fsck 的指令,可以檢查及修復檔案系統。它的參數包括有:

    -a: 檢查 partition,如發現問題會自動修復。
    -b: 設定 superblock 位置。
    -B size: 指定 size 作為區塊大小。
    -c: 檢查 partition 是否有壞軌。
    -C file: 將檢查結果儲存到 file。
    -d: 輸出 e2fsck debug 結果。
    -f: e2fsck 預設只會對錯誤的檔案系統檢查,加上 -f 是強制檢查。
    -F: 在檢查前將硬碟的 buffer cache 清空,避免發生錯誤。
    -l list: 記錄了壞軌區塊加入 list 中。
    -d : 列印 e2fsck 的 debug 结果。
    -f : 强制检查。
    -n: 以 (read-only) 開啟檔案系統
    -p: 關閉互動模式,如有問題自動修復,等同 -a。
    -v: 顯示詳細報告。
    -y: 啟用使用者互動模式。

    使用例子
    檢查 /dev/sda1 是否有問題,如發現問題便自動修復:

    e2fsck -a -y /dev/sda1

    執行 e2fsck 或 fsck 前請先 umount partition,否則有機會令檔案系統毀損。如果需要對根目錄 (/) 進行檢查及修復,便需要進入 singal user mode 執行。


    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word