檔案系統檢查
一、為什麼RHEL開機會花會很長時間?
為加快調用檔案的效率,開機時RHEL将資料存放在buffer/cache中,每次開機時RHEL也會檢查檔案系統的完整性.
二、檔案系統的狀态
為減少檢查檔案系統完整性所花的時間, RHEL會根據檔案系統狀态是否為dirty決定是否深入檢查每個檔案的完整性,如果是dirty則會花很長時間去檢查每個檔案的完整性.
RW: dirty
RO: clean
三、Fsck手動檢查檔案系統的完整性
文法: fsck [-A] [-a] [-y] [-f] [DEVICE]
-A Walk through the /etc/fstab file and try to check all file systems in one run.
-a Automatically repair the file system without any questions (use this option with caution).
-y For some filesystem-specific checkers, the -y option will cause the fs-specific fsck to always attempt to fix any detected filesystem corruption automatically.
-f 即使FS是幹淨的也要強制檢查
【note】 不要對已經挂載的檔案系統執行fsck,否則會破壞FS結構,模拟如下:
[[email protected] ~]# mount | grep '/dev/sda4'
/dev/sda4 on /newdisk type ext3 (rw)
[[email protected] ~]# fsck /dev/sda4
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
/dev/sda4 is mounted.
WARNING!!! Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
Do you really want to continue (y/n)? no
check aborted.
[[email protected] ~]# umount /dev/sda4
[[email protected] ~]# fsck /dev/sda4
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
/dev/sda4: clean, 11/26208 files, 8979/104420 blocks