Hacker News — AI on Front Page · · 9 min read

What is the purpose of the lost+found folder in Linux and Unix? (2014)

Mirrored from Hacker News — AI on Front Page for archival readability. Support the source by reading on the original site.

210 pts · 73 comments on Hacker News

Stack Internal

Knowledge at work

Bring the best of human thought and AI automation together at your work.

Explore Stack Internal
Asked 14 years, 10 months ago
Viewed 519k times
835

There is a folder at the root of Linux and Unix operating systems called /lost+found/

What is it for? Under what circumstances would I interact with it? How would I interact with it?

Gilles 'SO- stop being evil''s user avatar
Gilles 'SO- stop being evil'
870k207207 gold badges1.8k1.8k silver badges2.3k2.3k bronze badges
asked Aug 5, 2011 at 20:49
Wesley's user avatar
Wesley
15.1k1212 gold badges3939 silver badges4949 bronze badges
5
  • 3
    Note that only ext2 (and ext3 and ext4) use lost+found. If you want to hide it, either use a different filesystem or mount it elsewhere, keep everything in a subdirectory, and symlink the subdirectory to the "real" place you use the data from.
    Adam Katz
    –  Adam Katz
    2015-02-26 19:17:24 +00:00
    Commented Feb 26, 2015 at 19:17
  • 4
    @Gilles someone was kind enough to add it: en.wikipedia.org/wiki/Fsck#Use
    Big McLargeHuge
    –  Big McLargeHuge
    2016-02-12 18:17:15 +00:00
    Commented Feb 12, 2016 at 18:17
  • 1
    Note that lost+found is specific to the Linux extended file system (ext2–4). Unices, e.g. FreeBSD typically don't have this directory on their file systems (UFS, ZFS).
    FUZxxl
    –  FUZxxl
    2017-01-20 12:01:51 +00:00
    Commented Jan 20, 2017 at 12:01
  • 12
    Sorry, but lost+found has been around practically forever on BSD systems. In fact, I just checked and it was definitely there on 4.3BSD, and I seem to recall it a lot earlier. And it is certainly on FreeBSD today.
    Bob Eager
    –  Bob Eager
    2017-07-11 23:34:30 +00:00
    Commented Jul 11, 2017 at 23:34
  • "Note that only ext2 (and ext3 and ext4) use lost+found" -- why would anyone say this (in fact two people, with 4 upvotes) when it is so blatantly false? lost+found was in Version 7 UNIX.
    Jim Balter
    –  Jim Balter
    2026-06-08 02:12:56 +00:00
    Commented 10 hours ago

3 Answers 3

Highest score (default) Date modified (newest first) Date created (oldest first)
725

If you run fsck, the filesystem check and repair command, it might find data fragments that are not referenced anywhere in the filesystem. In particular, fsck might find data that looks like a complete file but doesn't have a name on the system — an inode with no corresponding file name. This data is still using up space, but it isn't accessible by any normal means.

If you tell fsck to repair the filesystem, it will turn these almost-deleted files back into files. The thing is, the file had a name and location once, but that information is no longer available. So fsck deposits the file in a specific directory, called lost+found (after lost and found property).

Files that appear in lost+found are typically files that were already unlinked (i.e. their name had been erased) but still opened by some process (so the data wasn't erased yet) when the system halted suddenly (kernel panic or power failure). If that's all that happened, these files were slated for deletion anyway, you don't need to care about them.

Files can also appear in lost+found because the filesystem was in an inconsistent state due to a software or hardware bug. If that's the case, it's a way for you to find files that were lost but that the system repair managed to salvage. The files may or may not contain useful data, and even if they do they may be incomplete or out of date; it all depends how bad the filesystem damage was.

On many filesystems, the lost+found directory is a bit special because it preallocates a bit of space for fsck to deposit files there. (The space isn't for the file data, which fsck leaves in place; it's for the directory entries which fsck has to make up.) If you accidentally delete lost+found, don't re-create it with mkdir, use mklost+found if available.

Cristian Ciupitu's user avatar
Cristian Ciupitu
2,56011 gold badge2323 silver badges3131 bronze badges
answered Aug 5, 2011 at 21:23
Gilles 'SO- stop being evil''s user avatar
Gilles 'SO- stop being evil'
870k207207 gold badges1.8k1.8k silver badges2.3k2.3k bronze badges
15
  • 22
    Also, if accidentally deleted fsck may re-create it the next time it finds the filesystem clean (which will probably be the next boot).
    derobert
    –  derobert
    2011-08-06 05:05:30 +00:00
    Commented Aug 6, 2011 at 5:05
  • 44
    Is this folder something that should be checked and cleaned from time to time?
    TheLQ
    –  TheLQ
    2011-08-07 08:24:31 +00:00
    Commented Aug 7, 2011 at 8:24
  • 14
    @TheLQ Only if your filesystem has suffered extensive corruption, fsck was required, and it mentioned finding files and linking them in lost+found. In 20 years with various filesystems, I've only seen this once. And that was before journalling was the norm.
    Alexios
    –  Alexios
    2012-01-12 08:06:09 +00:00
    Commented Jan 12, 2012 at 8:06
  • 7
    I think it also appears if you format your HDD (I switched from NTFS to ext4 and it appeared)
    puk
    –  puk
    2013-11-20 08:43:38 +00:00
    Commented Nov 20, 2013 at 8:43
  • 10
    @puk The lost+found directory is created whenever you create an ext4 filesystem (as with many other filesystems), whether it's done as part of the system installation or not. “Format your HDD” is just one case of that. What fsck does is to possibly add files there.
    Gilles 'SO- stop being evil'
    –  Gilles 'SO- stop being evil'
    2013-11-20 10:17:51 +00:00
    Commented Nov 20, 2013 at 10:17
78

The lost+found directory (not Lost+Found) is a construct used by fsck when there is damage to the filesystem (not to the hardware device, but to the fs). Files that would normally be lost because of directory corruption would be linked in that filesystem's lost+found directory by inode number. Some of these might be lost directories or lost files or even lost devices. Each filesystem should have its own lost+found directory, but you might be looking at a system with only one filesystem. In general, you should hope that the directory is empty; but if there is corruption, be thankful that in many conditions files can be recovered after fsck places them here.

erch's user avatar
erch
5,2601717 gold badges5454 silver badges8686 bronze badges
answered Aug 5, 2011 at 21:21
Arcege's user avatar
Arcege
23k55 gold badges5959 silver badges6666 bronze badges
5
  • 7
    Valid point, however: these CAN become quite a nuisance anyway. For example, when trying to to a find operation on one or many ext[2|3|4] partition(s) from a non-admin user's account, you will always get these entirely unnecessary "permission denied" errors. Certainly, there are ways to circumvent those kinds of errors - but it's a bit awkward because the standard find . -name '*whatever*' won't do the trick.
    syntaxerror
    –  syntaxerror
    2012-09-29 19:54:42 +00:00
    Commented Sep 29, 2012 at 19:54
  • 3
    @syntaxerror: Good to hear you say that about the annoyances of find: `./lost+found': Permission denied. It bugs me from time to time too...
    Johan E
    –  Johan E
    2014-06-22 00:24:33 +00:00
    Commented Jun 22, 2014 at 0:24
  • 2
    @syntaxerror the reason I arrived at this question was precisely because I was doing a find operation and find kept generating a Permission denied warning. Given this question's answer, I know that lost+found is part of the filesystem and so I can safely ignore the generated warning (but I do wish it didn't produce the warning).
    Trevor Boyd Smith
    –  Trevor Boyd Smith
    2015-12-16 18:58:43 +00:00
    Commented Dec 16, 2015 at 18:58
  • 2
    @JohanE You're telling me. However, the actual reason why I posted my comment was because this answer was trying to suggest us to "be thankful" for lost+found. This felt way too hilarious to be true (I sat here with a broad grin), for the ridiculously few times when we're thankful for it can't compete with those when we'd rather be able to cast a "Begone!" spell to this nuisant lo+fo thing.
    syntaxerror
    –  syntaxerror
    2015-12-16 19:49:35 +00:00
    Commented Dec 16, 2015 at 19:49
  • 1
    To those complaining of permission denied errors due to lost+found: I have a few external disks where I removed lost+found using sudo and then recreated it with $ mklost+found (without sudo). The permissions are now of my user and I get no permission denied errors using find.
    Daniel
    –  Daniel
    2024-12-22 19:08:59 +00:00
    Commented Dec 22, 2024 at 19:08
45

From "Linux Filesystem Hierarchy", section /lost+found":

As was explained earlier during the overview of the FSSTND, Linux should always go through a proper shutdown. Sometimes your system might crash or a power failure might take the machine down. Either way, at the next boot, a lengthy filesystem check using fsck will be done. Fsck will go through the system and try to recover any corrupt files that it finds. The result of this recovery operation will be placed in this directory. The files recovered are not likely to be complete or make much sense but there always is a chance that something worthwhile is recovered. Each partition has its own lost+found directory. If you find files in there, try to move them back to their original location. If you find something like a broken symbolic link to 'file', you have to reinstall the file/s from the corresponding RPM, since your file system got damaged so badly that the files were mutilated beyond recognition. Below is an example of a /lost+found directory. As you can see, the vast majority of files contained here are in actual fact sockets. As for the rest of the other files they were found to be damaged system files and personal files. These files were not able to be recovered.

Cristian Ciupitu's user avatar
Cristian Ciupitu
2,56011 gold badge2323 silver badges3131 bronze badges
answered Aug 23, 2012 at 8:19
bhupal's user avatar
bhupal
45144 silver badges22 bronze badges

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Discussion (0)

Sign in to join the discussion. Free account, 30 seconds — email code or GitHub.

Sign in →

No comments yet. Sign in and be the first to say something.

More from Hacker News — AI on Front Page