文件系统检查
一、为什么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