One more thought. The files in your directory weren't gone; they were
just moved to the lost+found directory, and you just lost their
name->inode numbers mapping. This is recoverable, however, if you had
saved that information first.
If you must test on filesystems with precious data (as opposed to
using scratch disks or loopback mounts), something which is really
useful to do in advance is to run the command:
e2image -r /dev/hdXX /var/e2image/XXX.e2img
This will create a dump of all of the critical filesystem metadata,
including the directory blocks. I sometimes ask people to send me
compressed e2image dump files when I need to debug a filesystem, since
it allows me to see all of the metadata, which is what I care about,
without getting need to send all of the data in the filesystem, which
(a) might be a privacy problem, and (b) makes the image file
significantly bigger to send over the network.
It's also useful for recovery purposes. For example, you can run
debugfs on the e2image file, and use the ls command to see the
original directory, which would have allowed you to relatively easily
reconstruct the filenames of the files left in the lost+found
directory.
Actually, the easiest way to do it would be to write a quick perl or
python script to gether up all of the inode numbers of the files in
lost+found, and pass it to the debugfs's "ncheck" command, which will
map inode numbers to pathnames. You can specify all of the inodes
ncheck at once:
debugfs -R "ncheck ino1 ino2 ino3 ..." /var/e2image/XXX.e2img
Then just parse the output, and move the files from lost+found back to
their original location in your home directory.
In fact, what e2image can be so helpful that a wise distribution might
want to consider automatically running it at boot time, to save
critical filesystem metadata. This could be used to reconstruct
filesystems and recover critical data in the case of various sorts of
hardware failure and/or kernel bugs.
- Ted
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/