2

For files that fsck places in lost+found directory, under what circumstances does fsck consider a file to be lost, I have the following in my mind:

For regular files:

1) If the inode links count is 0. As described in this answer: "an inode with no corresponding file name."

2) When a file has no entry in any directory even if the inode link count isn't zero possibly to improper shutdown.

This also raises the question about lost directories. What can qualify a directory as being lost so that fsck places it in lost+found directory. Perhaps the directory's inode links count? Or when the directory doesn't have an entry in any other directory?

2

I expect that it is just #2 (a file has no entry in any directory).  If a file is pointed to by one or more directory entries, fsck should just set the link count to equal the number of directory entries.  If a file is pointed to by one or more directory entries, there's no reason for fsck to create a new directory entry in the lost+found directory.

  • A directory cannot possibly be lost? This is because it has at least two entries referring to it .. and . – direprobs Aug 17 '17 at 9:10

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.