2009年11月30日 星期一

Linux Command - e2fsck

Refer from http://fanqiang.chinaunix.net/a1/b1/20010430/144406_b.html

指令:e2fsck

使用權限 : 超級使用者

使用方式 : e2fsck [-pacnydfvFV] [-b superblock] [-B blocksize] [-l|-L bad_blocks_file] [-C fd] device

說明 : 檢查使用 Linux ext2 檔案系統的 partition 是否正常工作


參數 :

device : 預備檢查的硬盤 partition,例如:/dev/sda1
-a : 對 partition 做檢查,若有問題便自動修復,等同 -p 的功能
-b : 設定存放 superblock 的位置
-B : 設定單位 block 的大小
-c : 檢查該partition 是否有壞軌
-C file : 將檢查的結果存到 file 中以便查看
-d : 列印 e2fsck 的 debug 結果
-f : 強制檢查
-F : 在開始檢查前,將device 的 buffer cache 清空,避免有錯誤發生
-l bad_blocks_file : 將有壞軌的block資料加到 bad_blocks_file 裡面
-L bad_blocks_file : 設定壞軌的block資料存到 bad_blocks_file 裡面,若無該檔則自動產生
-n : 將檔案系統以[唯讀]方式開啟
-p : 對 partition 做檢查,若有問題便自動修復
-v : 詳細顯示模式
-V : 顯示出目前 e2fsck 的版本
-y : 預先設定所有檢查時的問題均回答[是]

例子 :
檢查 /dev/hda5 是否正常,如果有異常便自動修復,並且設定若有問答,均回答[是] :
# e2fsck -a -y /dev/hda5
# e2fsck -c -y /dev/sda1

Notice: here the device name must have the full string, not only /dev/sda (this type of string will result fail)


注意 :

大部份使用 e2fsck 來檢查硬盤 partition 的情況時,通常都是情形特殊,因此最好先將該 partition umount,然再執行 e2fsck 來做檢查,若是要非要檢查 / 時,則請進入 single user mode 再執行。

沒有留言: