A co-worker accidentally deleted a .java file containing several hours worth of work. The file resided in his home directory, which conveniently had it's own dedicated partition. We managed to recover the file using the following (hackish) technique.
1) Take the machine to single user mode.
telinit 1
2) Unmount the partition containing the data.
umount /dev/sda2
3) Identify a semi-unique pattern located in the file.
His code contained a string that matched "Dictionary()".
4) Determine how much context around the string you need.
We chose 250 lines before and after the match.
5) Run grep on the partition.
grep --binary-files=text -250 "Dictionary()" < /dev/sda2 > /tmp/dump.bin
If you're lucky, the data will be somewhere in the file. We extracted the Java code using Vim, wrote a new file to /root, and went back to runlevel 2. One warning, remember not to write the recovered file to /tmp as it's often cleared when changing runlevels and rebooting.
Showing posts with label ext3. Show all posts
Showing posts with label ext3. Show all posts
Thursday, August 14, 2008
Subscribe to:
Posts (Atom)