27

What is the difference between the linux disk error-checking tools fsck and e2fsck?

27

fsck is just the original name. When they came out with new file systems they would need a specific tool for each one, efsck for ext, e2fsck for ext2, dosfsck, fsckvfat. So they made fsck the front end that just calls whichever is the appropriate tool.

  • Hmm, so apparently you can use the fsck "front-end" for some common tasks, but not for everything? For example the -c option (superuser.com/questions/20010/…) is mentioned in e2fsck man page but in that of fsck. – Jonik Aug 13 '09 at 7:45
  • Is there a GPT fsck? – Jonathan May 26 '18 at 17:18
  • @Jonathan fsck checks filesystems, while GPT is the partition table itself. There's probably a tool that can check those, but I can't think of one off the top of my head other than the Mac's Disk Utility (or the command line diskutil). The gpt command does have a "recover from backup table" option, at least on Mac. – SilverWolf Dec 12 '18 at 14:59
15

fsck is a wrapper for the filesystem-specific fsck.* family of tools. They can be used interchangeably with one caveat (from the fsck manpage):

Options which are not understood by fsck are passed to the filesystem-specific checker. These arguments must not take arguments, as there is no way for fsck to be able to properly guess which arguments take options and which don’t.

Options and arguments which follow the -- are treated as file system-specific options to be passed to the file system-specific checker.

Please note that fsck is not designed to pass arbitrarily complicated options to filesystem-specific checkers. If you’re doing something complicated, please just execute the filesystem-specific checker directly. If you pass fsck some horribly complicated option and arguments, and it doesn’t do what you expect, don’t bother reporting it as a bug. You’re almost certainly doing something that you shouldn’t be doing with fsck.

However, fsck will handle most of the normal operations on a file system.

4

On my system I have:

  • fsck
  • fsck.ext2
  • fsck.ext3
  • fsck.ext4
  • e2fsck
  • ... (more fsck.* tools for other, non-ext filesystems)

Now none of these are symbolic links but e2fsck and the fsck.ext2/3/4 tools all share the same inode so are actually the same file. (It is possible that this binary will interrogate its own name when it is run and behave differently for the name it is invoked with, but I doubt this is the case.)

So we're now down to just two tools:

  • fsck
  • e2fsck

And, as others have said, fsck is simply a front end that calls the appropriate tool for the filesystem in question, which in this case is e2fsck for an ext family filesystem.

I presume the reason for having the various fsck.ext2/3/4 files is so that 1. it's easy to write scripts that can handle all filesystem types generically (they can deduced the fsck tool name trivially from the filesystem type) and 2. for flexibility, so that it's trivial to split the e2fsck into two or more independent tools if necessary in the future.

  • Thank you for the longer explanation, because after reading @hyperslug answer I was already sensing heart attack :-) I have ext3 filesystem and I ran e2fsck. – greenoldman Oct 1 '16 at 20:42
  • Now none of these are symbolic links but e2fsck and the fsck.ext2/3/4 tools all share the same inode so are actually the same file. (It is possible that this binary will interrogate its own name when it is run and behave differently for the name it is invoked with, but I doubt this is the case.) - Why not - this is a particularly *nix-ish way of doing things and could actually be the case! – SlySven Mar 6 at 14:14
  • Those alternate names are actually examples of the lesser-spotted hard link (most people are familiar with symbolic links but their harder brother also has it uses though they are confined to the same device.) – SlySven Mar 6 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.