Why would you ever need to run this command?
In case the lost+found
directory doesn't exist. Since it's just an ordinary directory, the root
user can remove it using rm -r
. Some versions of fsck
, when they need to make use of a lost+found
directory, will create it if it doesn't exist, and some versions won't. If there's no lost+found
directory, fsck
can't recover orphaned files, that is, files that do not have any directory entries that refer to them.
The Linux version of mklost+found
has the following feature (from the mklost+found man page):
mklost+found
pre-allocates disk blocks to the lost+found directory so that when e2fsck(8) is being run to recover a filesystem, it does not need to allocate blocks in the filesystem to store a large number of unlinked files. This ensures that e2fsck will not have to allocate data blocks in the filesystem during recovery.
This means that, if you have to recover files from a damaged filesystem using fsck
, fewer files will be lost as part of the recovery process because fsck
won't need to allocate blocks from the filesystem; such blocks which may contain valid file data.
What would happen if you have multiple lost and found directories?
For a given filesystem, fsck
will only use one lost+found
directory: the one that is at the filesystem's root directory. Any other lost+found
directory will not be treated specially.
rm -rf /lost+found
. Oops... – cjm Apr 21 '14 at 16:51