LWN: Comments on "The many faces of fsck" https://lwn.net/Articles/248180/ This is a special feed containing comments posted to the individual LWN article titled "The many faces of fsck". en-us Sat, 30 Aug 2025 14:17:25 +0000 Sat, 30 Aug 2025 14:17:25 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net The many faces of fsck https://lwn.net/Articles/342841/ https://lwn.net/Articles/342841/ rhkramer <div class="FormattedComment"> Echoing others, this is a great article--thanks! (I say that even though <br> I haven't read the entire article yet.)<br> <p> Nevertheless, I do want to make one comment (somebody can correct me if I <br> really am wrong):<br> <p> For a long time it's been my understanding that certain "fixes" by fsck <br> (and similar fixes in the Windows world, like in chkdsk or whatever "they" <br> call it) result in the deletion of data.<br> <p> I think that is alluded to in the somewhat cryptic statement: "Repair here <br> means, as it does in the rest of the article, returning the file system to <br> a usable consistent state, rather than to some platonic ideal of what the <br> file system would have been without the corruption."<br> <p> I personally feel that it would be much better to be less cryptic, even <br> for (and maybe especially so for) Linux newbies.<br> <p> (I do recognize that some of the events that prompt the use of fsck (like <br> an improper shutdown (possibly due to a power loss event), can cause data <br> loss regardless of what happens during a(n) fsck.)<br> <p> <p> </div> Wed, 22 Jul 2009 15:28:27 +0000 hard links to directories https://lwn.net/Articles/255283/ https://lwn.net/Articles/255283/ rbfair <pre class="FormattedComment"> Apparently Apple has implemented directory hard links in their hfs+ filesystem, and it is the underpinning for the new 'Time Machine' backup in Mac OS-X leopard, where each incremental backup of an unchanged subtree is a single directory hard link. Seems like a very reasonable usage - though Time Machine presumably will not work on NAS boxes lacking directory hard link support (like Linux file systems.) [Ref: <a rel="nofollow" href="http://www.appleinsider.com/articles/07/10/12/road_to_mac_os_x_leopard_time_machine.html&amp;page=3]">http://www.appleinsider.com/articles/07/10/12/road_to_mac...</a> </pre> Sun, 21 Oct 2007 17:52:41 +0000 hard links to directories https://lwn.net/Articles/249988/ https://lwn.net/Articles/249988/ sflintham For what it's worth, and assuming I haven't misunderstood, Acorn's RISC OS had/has the concept of thing-which-is-a-file-and-directory. There were programs that made things like zip files behave as if they were a directory, and IIRC when another program asked the OS 'is this a file or a directory', it returned a bitmap where (say) bit 1 signalled 'this is a file' and 2 'this is a directory', and both would be set. Naturally this slightly broke programs that were written before they added this feature which just checked for a 1 or 2 value, but I don't remember it causing too many problems.<br> <p> Not trying to argue a case for or against making the change in Linux here, just thought I'd drop this in...<br> Sat, 15 Sep 2007 14:59:11 +0000 hard links to directories https://lwn.net/Articles/249914/ https://lwn.net/Articles/249914/ nix . and .. appear as hard links to users of the VFS. That doesn't mean they <br> have any physical existence, especially not at filesystem roots.<br> <p> The VFS and layers below manage . and .. entirely on their own: users just <br> call mkdir(2), rmdir(2), or rename(2) on the directory and the kernel does <br> all the rest.<br> <p> <p> The file-as-directory idea, while beguiling (especially for structured <br> file formats) has *many* more problems, not least that whether specific <br> programs were willing to treat a file as a directory or vice versa, or <br> both, would depend on currently-irrelevant details of how they were coded. <br> It is currently safe for a program to stat() something and then switch on <br> its d_type; but what d_type does a file-and-directory return? If it's new, <br> nothing much will support it unless you hack the S_ISREG() and S_ISDIR() <br> macros to return true for the new type too (and that's an ABI change: new <br> glibc major version!): if it's nailed to S_IFREG, very little will treat <br> it as a directory, and vice versa if it's nailed to S_IFDIR.<br> <p> I wish it could be implemented, but unless we're willing to throw away our <br> existing software, I suspect we'll be stuck with kludges that expose both <br> as different faked-up-but-aliased inodes somehow, one a file, the other a <br> directory.<br> <p> Fri, 14 Sep 2007 19:34:45 +0000 hard links to directories https://lwn.net/Articles/249857/ https://lwn.net/Articles/249857/ Duncan Thanks. Useful information. I hadn't thought out the implications of .. <br> to multiple named hard-linked dirs myself, so I'm glad you pointed it out. <br> It also explains the notes on directory unlink that I'd read (the <br> root-only thing, and that the exception was directory specific) but never <br> really understood. I understood that the subject went deeper than I <br> understood; now I'm beginning to see just a few of the ways it does so.<br> <p> But just to be sure, now, . and .. are indeed hard links within a <br> filesystem, on at many (but not necessarily all) filesystem <br> implementations? You specified that the entries in filesystem roots are <br> faked (as I was beginning to realize), but left not quite as nailed down <br> as I'd like that they are indeed hard links within the filesystem, even if <br> they are exception links that require kernel calls to create/destroy.<br> <p> Anyway, the kernel calls thing explains somewhat why filesystems haven't <br> implemented this yet. That's an additional complication, and would <br> certainly be heavily scrutinized if anyone tried introducing a filesystem <br> of that nature into the kernel mainline... which pretty neatly ties into <br> exactly why reiser4 has had the problems it has had getting into mainline, <br> given the original file as directory idea and implementation thereof. Now <br> I understand the implications of /that/ debate a bit better too, and a bit <br> more about what the nature of the introduced races and the complaints <br> about them entailed.<br> <p> Duncan<br> Fri, 14 Sep 2007 11:07:38 +0000 hard links to directories https://lwn.net/Articles/249840/ https://lwn.net/Articles/249840/ nix The . and .. directory entries in the roots of filesystems don't actually <br> exist, but are faked by the VFS. (There's no reason why the filesystem <br> couldn't generate all . and .. entries that way, and IIRC some do.)<br> <p> Once upon a time . and .. really were real hardlinks, <br> and /usr/lib/{mk,rm}dir (IIRC) were setuid root programs that <br> created/removed the directory and manipulated these links. This turned out <br> to have unfixable races, so was replaced with an in-kernel call, but some <br> Unixes (notably Solaris) maintained the semantics that unlink() of a <br> directory as root was permitted (which caused some aggro on the git list <br> recently).<br> <p> Multiple hardlinks to a directory are theoretically implementable, and <br> under Linux the biggest problem (`where does .. take us?') is solvable <br> using the dcache; but allowing it will confuse users to some extent.<br> <p> (Linus said that he had no major objections to allowing directory <br> hardlinking --- the we don't corrupt filesystems kind --- about seven <br> years or so ago, but nothing happened after that that I know of.)<br> Fri, 14 Sep 2007 06:32:38 +0000 hard links to directories https://lwn.net/Articles/249823/ https://lwn.net/Articles/249823/ Duncan <font class="QuotedText">&gt; So if a directory has a link count &gt; 1, this must be an error.</font><br> <p> What are all the (normally hidden) . (me) and .. (my parent) links if not <br> hard links?<br> <p> Your assumption that additional links are not allowed doesn't necessarily <br> hold for all filesystem types, either. Looking it up, the GNU coreutils <br> info entry for ln has the following:<br> <p> <font class="QuotedText">&gt; On all existing implementations, you cannot</font><br> <font class="QuotedText">&gt; make a hard link to a directory, and hard links</font><br> <font class="QuotedText">&gt; cannot cross file system boundaries. (These</font><br> <font class="QuotedText">&gt; restrictions are not mandated by POSIX, however.)</font><br> <p> Thus multiple named directory links are apparently not only possible, but <br> not restricted by POSIX either, so an implementing filesystem could indeed <br> allow such things, it's simply that few (none known to the info entry <br> author quoted above at the time the statement was written) have done so.<br> <p> Hmm... That leads to two questions.<br> <p> 1) What does creating a subdir do if it doesn't create a hardlink entry in <br> the form of .. back to the parent? Does the above only refer to directly <br> created named (not . and ..) links?<br> <p> 2) The no crossing filesystem boundaries is interesting. The kernel must <br> fix that up by creating a logical .. link in the root dir of a mounted <br> filesystem, since it self-evidently couldn't be a hard-link, given that <br> the filesystem could be arbitrarily mounted anywhere. Likewise, the <br> kernel must remove the .. entries from chroots.<br> <p> So maybe those . and .. entries aren't hard links after all, which begs <br> the question (avoids the question, begs that it be asked and answered, <br> whatever [1], I'm a literal constructionist in this case) I asked at the <br> beginning, what /are/ they, then? However, that's out of my league. <br> Perhaps Val can trivially answer.<br> <p> [1] <a rel="nofollow" href="http://www.onelook.com/?w=beg+the+question">http://www.onelook.com/?w=beg+the+question</a> <br> <p> Duncan<br> Fri, 14 Sep 2007 03:13:52 +0000 hard links to directories https://lwn.net/Articles/249607/ https://lwn.net/Articles/249607/ gw666 <blockquote> UNIX file systems have the wonderful quality of allowing more than one hard link to an inode (which can be file or directory). </blockquote> You cannot hard link a directory: <p> <code> $ ln foo/ bar<br> ln: `foo/': hard link not allowed for directory </code> </p> So if a directory has a link count > 1, this must be an error. Thu, 13 Sep 2007 08:19:25 +0000 First availability of fsck https://lwn.net/Articles/249333/ https://lwn.net/Articles/249333/ addw <blockquote><i>the first fsck was designed for the Fast File System</i></blockquote><p> No, fsck was available long before then with the original Unix file system. For instance see: <em><a href="http://uglx.org/sys3">http://uglx.org/sys3</a></em> Wed, 12 Sep 2007 06:16:01 +0000 War story https://lwn.net/Articles/249134/ https://lwn.net/Articles/249134/ cstanhop I just want to say that this is a great article. I've enjoyed the others along this line, and I look forward to more articles like this one. <br> <p> My fsck war story is one where the fsck program was of absolutely no help, and I got to play human fsck for a day. <br> <p> This was back in '96 on a Caldera Linux distribution with ext2. I had just finished installing and configuring a linux box that acted as the file, email, web server, DNS, dial-up router, and proxy for the three person company I was part of. It was a big deal for us, and it had taken me a better part of a week to get everything running as I had planned. Everything was complete except (feel free to shudder knowingly) we hadn't received the tape drive system we intended to use as the backup for the system. However, I was primarily working as an EE at the time, and as a third of the work force, I needed to get back to my other work.<br> <p> The system was running fine for a couple of days, but then one morning I came in and my boss told me it refused to boot. My heart sank as I went to the terminal and saw some error about the file system not being recognized. A week's work gone! I had a suspicion somebody had neglected to shut it down properly because they had forgot the root password, but under my baleful gaze oaths were sworn that this was not the case. Anyway pointing fingers wasn't going to get the thing to boot, and I should have figured out a way to back it up even without the tape drive.<br> <p> So, I tried booting from a floppy and running fsck, but fsck wouldn't have anything to do with the drive. I briefly considered the possibility of rebuilding everything, but I was determined to not lose all that hard work. So, I read up all the information I could find about ext2, and I fired up ext2ed. Working with ext2ed, it appeared that a drive sector in the root inode had become corrupted. Reading that sector gave errors, but I could poke around in other sectors. So, based on what I had been reading about ext2 and knowing how I had laid out the drives, I had ext2ed rewrite the root inode. Once ext2ed wrote the root inode, the drive began to read the sector without errors. Yea me!<br> <p> So, now I ran fsck. Success again! Absolutely no errors! But we were still spooked, so my boss had run out and bought equivalent geometry drives from some other manufacturer. I "mirrored" the disks with dd, then I booted from the originals just to see if worked. It did, so we swapped in the new drive and tried it, and it worked too. As far as I could tell, nothing had been lost and it was only that sector in the root inode that caused problems. We continued running with the new drives and kept another new drive as a mirrored backup for a while until we could get the tape backup working.<br> <p> All I can say is "phew!" Luckily it only took me a better part of the day to recover from that potential data disaster. With a couple of earlier exception in the days of DOS, that's the closest I've had to get to my file system. I completely appreciate all the work people put into them so I can get on with the things I want to do. Even the slow fscks are appreciated (when they work). At least I learned the value of backups. Lots and lots of backups...<br> Tue, 11 Sep 2007 06:07:13 +0000 The Sound of fsck https://lwn.net/Articles/249131/ https://lwn.net/Articles/249131/ BrucePerens In the early 80's, Kirk McCusick pronounced it "fisk" while delivering his paper on the (then new) BSD FFS. I don't know how much closer to origin we can get.<p><i>Bruce</i> Tue, 11 Sep 2007 04:23:55 +0000 Always consistent https://lwn.net/Articles/248679/ https://lwn.net/Articles/248679/ vaurora Yeah, "wafl_check" indeed used to be "wack." I don't know the story behind the name change, but it seems likely that either the pronunciation was too confusing ("You want me to whack the file system? Are you crazy?"), or someone performed a humor-ectomy after NetApp got really successful.<br> Fri, 07 Sep 2007 00:48:32 +0000 Always consistent https://lwn.net/Articles/248652/ https://lwn.net/Articles/248652/ jwb NetApp's fsck is (or at least was, at one time) "wack" which is surely the easiest to pronounce.<br> Thu, 06 Sep 2007 20:34:47 +0000 Always consistent https://lwn.net/Articles/248648/ https://lwn.net/Articles/248648/ rfunk Yeah, the description of zdb reminded me of the early days of XFS on Irix, <br> when we were told that no fsck was necessary because it was always <br> consistent. Then later it was discovered that, yes, even journaling filesystems <br> can get corrupted, and xfs_check and xfs_repair were added. (Which I've <br> personally had to use on at least two separate occasions.)<br> <p> Also, I must dispute the author's characterization of "xfs_check" as more <br> pronouncable than "fsck". fsck lacks that nasty underscore, so it's much easier <br> to tell someone to run fsck than xfs_check. "fsck" is also easier to say (however <br> you say it) and type.<br> Thu, 06 Sep 2007 19:51:55 +0000 The "yes" command existed before "-y" https://lwn.net/Articles/248545/ https://lwn.net/Articles/248545/ hamjudo There was no need to wear out the enter key.<br> Before fsck had -y, you could have used<br> yes | fsck /dev/rd02a<br> <p> You should go back in time and tell the younger version of yourself that. It will save your fingers.<br> <p> If you used fsck before the yes(1) command, then suggest to yourself that you write a yes(1) command, it is only a few lines longer than /bin/true.<br> Thu, 06 Sep 2007 14:04:05 +0000 The many faces of fsck https://lwn.net/Articles/248444/ https://lwn.net/Articles/248444/ jwb This is a great article. I'm glad you mentioned the mysterious WAFL fsck program and ZFS. I think people should approach claims of "always consistent" with extreme skepticism. The existence of WAFL's fsck is little-known because NetApp salesmen swear that it does not exist. The file system is always consistent, therefore you can't possibly need a fsck. That is, until you come in one morning and your filers are fscking themselves, and you call support, and support tells you "oh, that's the fsck, didn't you know about it?"<br> <p> So when Sun claims that ZFS doesn't need a fsck, one tends toward disbelief. And given that they are 10 years behind NetApp in the file system design division, I bet they have less experience with all the weird modes of failure, too.<br> Thu, 06 Sep 2007 04:32:08 +0000