linux – fsck:文件系统在每次检查后都用-c进行了修改,为什么?

我使用脚本以自动方式对CF卡(与USB卡写入器连接)进行分区和格式化.在主要过程之后,我再次使用fsck检查卡.为了检查坏块我也尝试了’-c’开关,但我总是得到一个返回值!= 0和消息“FILE SYSTEM WAS MODIFIED”(见下文).我几次检查同一个驱动器时得到的结果相同……

有谁知道为什么a)文件系统完全被修改和b)为什么每次我检查时都会发生这种情况,而不仅仅是在出现错误的情况下(如坏块)?

这是输出:

linux-box# fsck.ext3 -c /dev/sdx1
e2fsck 1.40.2 (12-Jul-2007)
Checking for bad blocks (read-only test): done
Pass 1: Checking inodes,blocks,and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

Volume (/dev/sdx1): ***** FILE SYSTEM WAS MODIFIED *****
Volume (/dev/sdx1): 5132/245760 files (1.2% non-contiguous),178910/1959896 blocks

解决方法

手册页:

-c
This option causes e2fsck to run the badblocks(8) program to find any blocks which are bad on the filesystem,and then marks them as bad by adding them to the bad block inode. If this option is specified twice,then the bad block scan will be done using a non-destructive read-write test.

因此-c选项写入文件系统,fsck将其解释为“纠正错误”,因此返回码为1(“文件系统错误已更正”)

…所以,你问,为什么当你指定-n时它会返回1,哪个应该以只读方式打开文件系统并且不做任何修改?
好了,进一步阅读该联机帮助页也显示了答案:

-n
Open the filesystem read-only,and assume an answer of `no’ to all questions. Allows e2fsck to be used non-interactively. (Note: if the -c,-l,or -L options are specified in addition to the -n option,then the filesystem will be opened read-write,to permit the bad-blocks list to be updated. However,no other changes will be made to the filesystem.)

(换句话说:-n是谎言!)

这个答案完全由the manpage for fsck.ext3带给你.

相关文章

/etc/sysctl.conf这个目录主要是配置一些系统信息,/etc/sys...
1.作用 useradd或adduser命令用来建立用户帐号和创建用户的起...
它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅...
不管是我们在安装软件还是监测软件的使用性能,我们都要随时...
装好Tomcat7后,发现除了本机能访问外界访问不了,岂有此理。...
修改防火墙配置需要修改 /etc/sysconfig/iptables 这个文件,...