I want to check the consistency of a file system and fix the errors. What are the safety considerations in running fsck -f -y
on a file system?
I want to check the consistency of a file system and fix the errors. What are the safety considerations in running fsck -f -y
on a file system?
Neither flag is defined in the top-level
fsck
documentation, so the most general answer is that it depends on the filesystem-specific fsck command you are using.For many fs-specific commands, in particular
e2fsck
for ext2/ext3/ext4 file systems, the-f
option is used to "Force checking even if the file system seems clean." This can make the command slower but is not expected to cause any harmful side effects in itself.The
-y
flag is described in thefsck(8)
man page as follows (emphasis mine):This implies that there is some risk involved: in some cases, the command may perform actions that would not be advised by an expert administrator.
The
e2fsck
command has an alternative,-p
, which can be used to "automatically fix any filesystem problems that can be safely fixed without human intervention." The command will exit with an error if any issues are detected that require further intervention.