If you are thinking "What's this?", see Whose Sounds in the Cellar.
If you are wondering "How did I get here?", use the back button of your browser.
If you are asking "What Sounds?", read on.

ReiserFS undelete/data recovery HOWTO

This isn't a proper HowTo or anything, but putting such a title ensures Google indexes this entry nicely in it's database - the database that we all turn to on the first signs of trouble. More on writing for Google.

So web searchers, you've come here because you've lost data on your ReiserFS partition or you accidentally deleted a file and came to know after googling that there's no undelete utility for ReiserFS. I once deleted my entire home directory using the 'rm -rf ./stuff/ *' trick. I managed to recover a lot, but it took time and some googling. The following few steps are to ensure you have better success at recovering lost data.

NOTE: These steps are only for really bad hard disk muck-ups and accidentally deleted files. For normal filesystem inconsistencies, don't use these steps!

  1. Once you realize that you've lost data, don't do anything else on that partition - you may cause that data to be overwritten by new data.
  2. Unmount that partition. e.g., umount /home
  3. Find out what actual device this partition refers to. You can usually get this information from the file /etc/fstab. We'll assume here that the device is /dev/hda3.
  4. Run the command: reiserfsck --rebuild-tree -S -l /root/recovery.log /dev/hda3

    You need to be root to do this. Read the reiserfsck man page for what these options do and for more options. Some interesting options are '--rebuild-sb, --check'

    After the command finishes, which might be a long time for a big partition, you can take a look at the logfile /root/recovery.log if you wish.

  5. Mount your partition: mount /home
  6. Look for the lost+found directory in the root of the partition. Here, that would be: /home/lost+found
  7. This directory contains all the files that could be recovered. Unfortunately, the filenames are not preserved for a lot of files. You'll find some sub-directories - filenames withing those are preserved!
  8. Look through the files and copy back what you need.

UPDATE (15 June, 2004): I just found this thread which warns of possible corruption of existing files on the partition. Essentially, the recovery process may take older (deleted) versions of a current file and try and merge it with the new file resulting in data corruption. As a safety measure, make a backup of important undamaged files on another partition before you carry out the above steps.

Here's a useful link for more advanced tricks.

Hope that helps! Please leave a comment here if you found this page useful and/or if there should be something more on this page that I missed.

PS: For normal filesystem inconsistencies, use the --fix-fixable option with reiserfsck. See the man page for more on that.

techtalk | 7 comments | permalink | 04.06.2004 11:49 MALST

Re: ReiserFS undelete/data recovery HOWTO
Ashwin wrote on Sat, 05 Jun 2004 10:02

u in NUS by any chance?


Reply to this comment
    Re: Re: ReiserFS undelete/data recovery HOWTO
    deepak wrote on Sat, 05 Jun 2004 10:35

    Yes, but not for long.

    I graduate in a month.

    Why? You there too?


    Reply to this comment
Re: ReiserFS undelete/data recovery HOWTO
shev wrote on Mon, 09 Aug 2004 23:15

indeed, this was by far the best help available and i used google

sadly it was about only the 20th entry or so, it took me some time, but as firefox tabbed browsing ruled, this was quite fast.

i accidentally... no... lets say... i with a slight mistake, killed about 100 binary files. was because of the rm *

that really sux, i think i must implement a script which ensures a talkback function if there are more than 200 files which would get deleted, so that it asks "you are about to delete FOO files in DIR. Continue? yes"...

anyway, right now i am running the test as described...

Skipping 8808 blocks (super block, journal, bitmaps) 19582440 blocks will be read 0%. left 18033511, 7984 /sec


Reply to this comment
    Re: Re: ReiserFS undelete/data recovery HOWTO
    wrote on Tue, 10 Aug 2004 00:23

    Some update, after about 15 minutes the output looked (btw it was a 80 GIG hard disc, a rather new thing):

    Skipping 8808 blocks (super block, journal, bitmaps) 19582440 blocks will be read 0%....20%....40% left 11026904, 8512 /sec

    then after this was finished, sth like...

    Objectids found 142363

    Flushing..finished Syncing..finished ########### reiserfsck finished at Mon Aug 9 15:54:16 2004 ###########

    my log was 11.3 MB in size

    and i found many entries with

    wrong block count in the StatData

    i mounted it, changed to lost+found dir

    there were incredibly many directories inside

    a bit despair came up here ;)

    i ran ls -c -l|gr 08-09 to find out which dirs i should have a look in... there i eventually found some of the files i deleted... so i copied some, then switched to the original dir where all the trouble has happened

    and lo and behold, there all the files i deleted were again!

    is a bit auto-magical to me but hey - the files are there , i have 2 harddiscs, now i use the other harddisc as well to back that data up :)


    Reply to this comment
      Re: Re: Re: ReiserFS undelete/data recovery HOWTO
      deepak wrote on Tue, 10 Aug 2004 03:29

      lucky you! getting all ur files back so easily. especially with those binary files...


      Reply to this comment
    Re: Re: ReiserFS undelete/data recovery HOWTO
    deepak wrote on Tue, 10 Aug 2004 03:23

    well, link to this page and bring it up in google's ranking :-D


    Reply to this comment
Re: ReiserFS undelete/data recovery HOWTO
§@nTē$ wrote on Sun, 10 Oct 2004 06:53

Hi all,

I just want to thank for the tips on recovering deleted files. I've just wrongly deleted some files and been able to recover them by following your steps / steps from pages mentioned herein. Instead of finding deleted files in lost+found directory, I've ended up finding them in the original directories (from where they were deleted). I've compiled the sequence of steps for my specific case (slight changes will suit particular issues regarding unwanted file deletion), which follows:

Recover deleted files (from /home = /dev/hda7) 0. Unmount partition from where to recover deleted files umount /home 1. Create partition copy dd if=/dev/hda7 conv=noerror > /hda7.img 2. Set up device containing copy of partition (created in 1.) losetup /dev/loop/0 /hda7.img 3. Rebuild FS tree, performing a thorough partition scan and logging to /recovery.log file reiserfsck --rebuild-tree -S -l /recovery.log /dev/loop/0 (4. Check written log file) (less /recovery.log) 5. Create directory for mounting recovered partition mkdir /recovery 6. Mount recovered partition in directory created in 5. mount /dev/loop/0 /recovery 7. Access recovered partition's lost+found directory and look for files cd /recovery/lost+found 8. If not there (7.), then look for in original directory cd /recovery/ 9. Remount /home partition mount /home 10. Copy recovered files from 7./8. to /home/ cp /recovery// /home// 11. Unmount recovered partition umount /recovery 12. Detach recovered partition device losetup -d /dev/loop/0

§@nTē$


Reply to this comment
 
Name:
URL/Email:
Title:
Comment:
Save my Name and URL/Email for next time