6

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?

5
  • 4
    fsck will try valiantly to not lose data, but it cannot perform miracles. It's reasonably safe...if your damage is reasonably ordinary.
    – user535733
    Nov 13, 2019 at 17:03
  • 3
    Do sudo fsck -N -y to run it without making any changes first, if you are concerned. manpages.ubuntu.com/manpages/bionic/man8/fsck.8.html is the general fsck man page; subordinate man pages exist for filesystem-specific checkers such as manpages.ubuntu.com/manpages/bionic/man8/fsck.ext3.8.html for ext2/3/4 filesystems.
    – K7AAY
    Nov 13, 2019 at 17:17
  • 2
    "How safe is running fsck -f -y?" Simple: we all make backups and know how to restore them so I say go for it. If it fails and ends badly you restore your backup.
    – Rinzwind
    Nov 13, 2019 at 18:46
  • 1
    What is this "safe" concept?
    – waltinator
    Nov 14, 2019 at 0:23
  • @waltinator: It means nothing will be corrupted as a result of running a procedure, or command, or software
    – BlueSkies
    Nov 14, 2019 at 12:28

1 Answer 1

3

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 the fsck(8) man page as follows (emphasis mine):

    For some filesystem-specific checkers, the -y option will cause the fs-specific fsck to always attempt to fix any detected filesystem corruption automatically. Sometimes an expert may be able to do better driving the fsck manually.

    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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .