Recently I had a little issue with my laptop’s filesystem. I’m running Fedora 14 with ext4 partitions and had to run fsck to clear it up. Or at least, I had to run some mutation of fsck. The plethora of options that were available to me made my head spin. Let’s take a look at the typical options that are available to someone running a Red Hat implementation of Linux that uses an ext file system:
I know that I have a ext4 filesystem, so I probably want to stay far away from the other fscks, right? Let’s find out.
Before I go any further, let me disclaim my findings, assumptions and conclusions by saying that as of the writing of this post I am new to the Linux operating system. I have only been running it as my main OS for about six months with sparing exposure to it for just a few years prior to that. While I’ve had some great teachers and resources to draw on, I’m still a Linux nublet and what I am about to say may or may not be entirely accurate. I’ve done the best research that I can do at this point in my career, but if anyone has better insight into the topic please straighten me out in the comments below, an email or a blog post.
Furthermore, my findings are those of someone running a Red Hat / RPM based OS. Red Hat seems to do their own thing sometimes (great, I’ve switched from a Microsoft OS to the Linux version of a Microsoft OS!) and that can cause some huge YMMV moments.
If you tie your system into a knot as a result of anything I’ve said in this post, I’m truly sorry about that, but you have been warned. Your mileage may vary, read the fine manual and the picture on the box is enlarged to show texture.
You are in a Maze of Twisty little Passages, All Alike
Or at least, that’s what it felt like as I tried to unravel this mystery. Let’s take a look at some of the evidences that I discovered in my search to find out the difference between the various fsck commands.
Hammering out Hardlinks
The first thing to do is find which programs are identical. There’s no point in doing any other comparisons on programs that are duplicates. e2fsck, fsck.ext2, fsck.ext3 and fsck.ext4 are all hardlinks to the same inode. They are the same file. However, fsck is a different file with no hardlinks. It’s its own command that can be found nowhere else.
When referring to the family of hardlinked fscks, I’ll simply refer to e2fsck alone since that seems to be the more common command that can be found on all Linux distributions. fsck.ext[2-4] seem to be Red Hat permutations that are included for policy reasons. Something about incompatible binaries.
Sifting through Symlinks
None of the fsck commands listed above are symbolic links, however I found two commands in the extended fsck family that are. I’ll include them here for thoroughness. fsck.msdos and fsck.vfat are both symbolic links to dosfsck. Fortunately for me, I’m not going to be bothering with those mutations of the fsck gene pool.
Hunting Down Help
In spite of some clarity being added to the sitution by the above link sleuthing, some confusion is injected when looking at fsck’s command help:
[Me@MyPC ~]$ fsck help fsck from util-linux-ng 2.18 Usage: fsck.ext4 [-panyrcdfvtDFV] [-b superblock] [-B blocksize] [-I inode_buffer_blocks] [-P process_inode_size] [-l|-L bad_blocks_file] [-C fd] [-j external_journal] [-E extended-options] device
Wait, did you see what I saw? “Usage: fsck.ext4” – okay, so why is fsck apparently fsck.ext4 in disguise? Why, if fsck isn’t hardlinked to anything, does it seem to think it’s fsck.ext4? As of this post, I don’t have an answer to those questions. My only clue is from the answer to a question I asked over at unix.stackexchange.com.
Apparently Red Hat based distributions are a bit unique as a result of RH’s insistence on consistency and compatibility. (Or as I seem to recall a Slackware fan saying once: “If you learn Red Hat you know Red Hat. If you learn Slackware you know Linux.”) Nothing in that Stack Exchange post said anything about fsck being replaced by Red Hat’s preferred binary, but the situation leads me to believe that Red Hat may have replaced the fsck command with their own preferred version. Perhaps. This is all very foggy to me and I’m still seeking answers.
e2fsck’s help simply states that is is… well… e2fsck. At least that’s not an additional quandary to have to figure out.
Measuring Man Pages
In essence we only have two fscks to deal with: fsck itself and e2fsck. (I’ll ignore the strange “fsck thinks it’s fsck.ext4” drama for now) diff’ing the two man pages comes up with some interesting information. Here are some points that I came away with from the comparison:
- e2fsck is part of the e2fsprogs package and fsck is part of the util-linux-ng package.
- e2fsprogs is maintained by Theodore Tso and in spite of the name it works on ext2, 3 and 4.
- fsck is also apparently authored by Theodore!
- The util-linux-ng tools can be found at kernel.org.
- Both projects are apparently kept up to date and maintained, both having been updated in late 2010 as of the writing of this blog post.
- According to the man pages, fsck does not appear to be able to perform any actions on superblocks where e2fsck can. However, on my Fedora system fsck’s ‘help’ command makes mention of superblock parameters. Then again, it also says the it’s fsck.ext4 which is really e2fsck.
- fsck appears to be able to pass filesystem specific checkers some data. e2fsck does not seem to have that ability.
- fsck and e2fsck are similar but different in their options. Be careful if you frequently interact with both.
I also noted that the fsck binary is considerably smaller (30K) than the e2fsck binary (190K).
So What do I Use on my Filesystem?!
Let’s get one thing straight: fsck and e2fsck (and thereby any fsck.ext* permutation) can handle ext2, 3 and 4. So I feel confident in saying that you’re safe using either command on any ext-based filesystem. If you need to muck about with superblocks, e2fsck seems to be the tool for you. In fact if you need any of the other features that e2fsck uses, then you know what to use. Which features are those? You’ll have to research those differences on your own.
Personally, I now use e2fsck for everything ext related. It seems to be the best tool with the most options that is linked to by most other ext based filesystem commands.
What’s the deal between all the different hard links and the help of fsck showing that it thinks it’s fsck.ext4 (which is really e2fsck)? I have no idea. If you have better insight into the situation, I’d be very grateful for any kind of clue thrown my way. If you’d like to, you can head on over to the unix.stackexchange.com question that I asked and possibly garner some points for an additional answer. Or you could ask your own question and then answer it (since this article goes in a different direction than that specific question). Of course guest posts on my blog are welcomed or links to your own blog post on the topic are available.
Oh, and I’m rather proud that I made a whole post about fsck and didn’t once make a tawdry joke implying it’s visually similar cousin. =)