Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Every certain amount of time, Ubuntu checks my filesystems and it creates several empty "lost+found" folders.

Can I disable this feature? Is there any way that Ubuntu deletes automatically these folders if they are empty?


Is there any manner to hide this folder on NFS?

share|improve this question

4 Answers 4

up vote 8 down vote accepted

Whenever fsck goes through the system and tries to recover damaged files, it will put them into the lost+found folder. I guess this is basically a problem with fsck creating that folder even if there's nothing to put in. As Ubuntu periodically runs those checks on your partitions, those folders will always be re-created, so deleting it won't work.

If you just want to hide the folder from Nautilus, you can create a '.hidden' file containing 'lost+found' and put it into the lost+found parent's folder.

Eg. for the lost+found folder in '/':

echo "lost+found" | sudo tee /.hidden

For the one in you home directory (if any):

echo "lost+found" > ~/.hidden


I guess alternatively you can remove them after every boot by adding the following to the file '/etc/rc.local':

if [ -d /lost+found ]; then
    rmdir /lost+found 2>/dev/null
fi

if [ -d /home/USER/lost+found ]; then
    rmdir /home/USER/lost+found 2>/dev/null
fi

This will run rmdir on the folders if they exist, which only removes them if they are empty (2>/dev/null will discard the "not empty" message from rmdir). There probably aren't lots of directories, so I kept it simple. Just make sure 'exit 0' stays on the bottom line.

Downside: this only keeps track of directories created by fsck during boot. If it's run at a later time, you'll again see that directory. You then could put above into a periodically executed cron job.

share|improve this answer
    
Thanks, I knew this but that solution only works for nautilus. –  Simón Nov 10 '10 at 13:11
    
And how can I hide this folder on NFS? –  Simón Nov 10 '10 at 13:35
    
See update. Sorry, I have no experience with NFS. –  htorque Nov 10 '10 at 13:43

[Having a] lost+found directory with a large enough size to contain a large number of unlinked files puts less of a burden on e2fsck to create the directory and grow it to the appropriate size.

[fsck will attempt to create lost+found if it doesn't exist], but in the face of a corrupt filesystem, it can be more risky.

Very old fsck's for other filesystems on other platforms were not able to create /lost+found, nor were they able to grow it. This is the history for the rationale of /lost+found...

It is needed much less often since ext3. With a journaling filesystem, files shouldn't get "lost" on a crash / power failure. You might argue it's only kept to avoid fatal surprises for old-timers (and weirdos who disable the journal). If you don't know what you're missing, maybe it's not a problem.

Still, removing it is like patching e2fsck. You "can" do it, but you shouldn't.

share|improve this answer
    
Thanks, but this doesn't answer my question. –  Simón Nov 10 '10 at 13:10

This article will give you a proper explanation about lost+found directory : http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/lostfound.html

share|improve this answer
    
Thanks, I knew this but this doesn't answer my question. –  Simón Nov 10 '10 at 13:11
    
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  Eliah Kagan Aug 15 '12 at 5:28

cd where the lost+found folder is located
sudo touch .hidden
sudo mcedit .hidden (Write lost+found and save with F2.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.