Friday, February 20, 2009

Undelete any open files in Unix/Linux

Here's a great post by Chris Dew about how to undelete any file that is still open.

There are some unmentioned prerequisites, like a "modern" kernel, but otherwise this should work.

As Chris explains, the underlying magic is because when programs hold a file open and that file gets deleted, the data doesn't get deleted. Read the post for the details. Really interesting stuff!

Incidentally, this is the same reason that 'du' and 'df' disagree sometimes. Giant log files which get deleted but don't clear up disk space, for instance. That's because whatever process wrote them still has the file open. This can be really confusing sometimes!