阅读量:427
Linuxfsck(英文全拼:filesystemcheck)命令用于检查与修复Linux文件系统,可以同时检查一个或多个Linux文件系统。如果系统掉电或磁盘发生问题,可利用fsck命令对文件系统进行检查。
语法格式:fsck[参数][文件系统]
常用参数:
- -a:自动修复文件系统,不询问任何问题
- -A:依照/etc/fstab配置文件的内容,检查文件内所列的全部文件系统
- -N:不执行指令,仅列出实际执行会进行的动作
- -P:当搭配”-A”参数使用时,则会同时检查所有的文件系统
- -r:采用互动模式,在执行修复时询问问题,让用户得以确认并决定处理方式
- -R:当搭配”-A”参数使用时,则会略过/目录的文件系统不予检查
- -t:指定要检查的文件系统类型
- -T:执行fsck指令时,不显示标题信息
- -V:显示指令执行过程
参考实例
修复坏的分区文件系统:
shell
[root@bunian~] fsck -t ext3 -r /usr/local
fsck from util-linux 2.32.1
e2fsck 1.45.6 (20-Mar-2020)
fsck.ext3: Is a directory while trying to open /usr/local
The superblock could not be read or does not describe a valid ext2/ext3/ext4 filesystem. If the device is valid and it really contains an ext2/ext3/ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 or e2fsck -b 32768 /usr/local: status 8, rss 2956, real 0.037328, user 0.001944, sys 0.000000
显示fsck系统安装的版本号:
shell
[root@bunian~]# fsck --version
fsck from util-linux 2.32.1
检查msdos文件系统的/dev/hdb是否正常,如果有异常便自动修复:
shell
[root@bunian~]# fsck -t msdos -a /dev/hdb