My mother has placed some important files on her /tmp per accident. Now, of course, they are gone.
This happened yesterday (2 boots of the machine since)
I want to try to undelete the files. They were on /tmp, which was on the same partition as the rest of / , so I need a tool that runs on a mounted system (or maybe I could use a livecd ...)
Right now, I am trying testdisk on a systemrescuecd that I just downloaded. I can get some files from /tmp, but not all. (is it the right tool ? What exactly are those "red" files ? are only some of them recoverable ?)
You can also use
extundelete
First unmount (
umount
) the file system where the files have been deleted.Then read the chapter What to do if you've deleted a file.
You can install
extundelete
from classic Ubuntu repository:Or better, you can download the latest version and compile it:
Example of usage: restore all deleted files from directory
Images
into new created directoryrestore
Bad news if you see your file
XXXX
within the following format:See all restored files (look for your file):
Backup your file(s) and remove this temporary directory
restore
Data recovery, especially on EXT file systems, should be attempted from a live CD or other system that isn't depending on the partition you're undeleting from. Getting the disk unmounted or re-mounted as read only helps a great deal in the recovery effort.
Most of the time I try to create an image of the partition or disk using
dd
or a similar tool, so that I'm not working on the disk itself:Once you have your image, you can use a tool like
ext3grep
to try and find the files you're looking for. There are lots of different switches that you can try, but this might be a good start:The
ext3grep
utility also provides several different ways to search through the file system if you don't know the name of the file. Checkext3grep --help
for the various methods of searching.I prefered to use ext4magic as :
Note you have to resolv symlink by your own
References:
http://ext4magic.sourceforge.net/howto_en.html
http://sourceforge.net/projects/ext4magic/
http://rzr.online.fr/q/recover
AnalyzeEXT
Parse data blocks for EXT directory data.
Detailed documentation on EXT4 can be found here:
Download the perl script with
No guarantee but may be able to reconstruct deleted filesystems.
I could not recover my crontab file by using ext4magic or extundelete.
On Debian, the crontab for root is here:
But, by using the following command, I was able to at least manually recover my crontab from the logs.
It will output only the executed cron jobs (no timings), but at least this is a lot more than starting from scratch.
If you don't remember how often certain cron jobs run, take a full log e.g. syslog.1 and this will give you the count for runs trough the day: