31

I have an empty seperate partition used for my vhd/virtualbox. mounted at /mount/win7.

I've deleted everything now and there's a lost+found folder left over. It takes up about 5gigs

Is it safe to remove a lost and found folder?

32

fsck will recreate the lost+found directory if it is missing.

On startup most distributions run fsck if the filesystem is detected as not being unmounted cleanly.

As fsck creates the lost+found directory if it is missing, it will create it then and place anything that it finds into that directory.

So you can remove it without any problem.

  • 1
    According to this answer in serverfault ( serverfault.com/a/9909/486260 ), it is not a good idea to delete it, since in the case of filesystem issues, when fsck recreates the directory during check it could potentially overwrite otherwise salvageable data as it would have no alternative to tie orphaned inodes to directory entries. The pre-created lost+found directory reserves directory entries for salvaged files during filesystem check – Marcelo Sep 5 '18 at 0:12
17

So far I was under the impression that deleting lost+found was perfectly safe, as it would be recreated by fsck whenever it is needed. But after the Ubuntu 12.10 upgrade I got this mail from cron:

/etc/cron.daily/standard:

Some local file systems lack a lost+found directory. This means if the
file system is damaged and needs to be repaired, fsck will not have
anywhere to put stray files for recovery. You should consider creating
a lost+found directory with mklost+found(8).

The following lost+found directories were not available:

/home/lost+found

The man-page of mklost+found says:

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.

I am not sure what exactly that means, but it seems to indicate that not having lost+found might cause trouble on recovery. Furthermore it indicates that lost+found different from a regular directory in that it has preallocated blocks associated with it.

  • I believe that the pre-allocation of disk blocks for lost+found directory is used to make sure that further allocations will not be needed to be done while the filesystem is in unstable state (during fsck). If the file system is already messed up, it might get worse if fsck tried to allocate directory entries while restoring lost files. At least ext2/ext3/ext4 family tries very hard to not make things worse during fsck even if the filesystem is totally broken. – Mikko Rantalainen Dec 23 '16 at 8:23
2

You don't want to delete the lost+found directory.
It is an important system folder and will be recreated on next boot anyway. There is some pretty good explanation of why it is there and what it does here

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.