Slashdot Mirror


Recovering Deleted Files on ReiserFS3?

DarkSarin asks: "I have a rather serious problem: I managed to accidentally delete some files (rather important ones at that!) while trying to back them up to cd (I was using a GUI burning software that will remain nameless for now). How do you recover accidentally deleted files in Reiserfs? This thread (started by me) indicates that you can't recover them. Note that I had found a way to rebuild the tree, but that didn't work. It seems odd to me that you wouldn't be able to recover accidental deletions, but that really does seem to be the case. Help? Please?"

29 of 126 comments (clear)

  1. Good luck... by SanityInAnarchy · · Score: 4, Interesting

    A filesystem has never (AFAIK) implemented a trash / recycle bin folder -- not on Windows or OS X, and not on any UNIX that I know of.

    The reason for this is that a recycle bin is to save you from accidental deletions. If you delete a file from the nice, big, friendly GUI, it usually asks you at least once whether you want to delete it, then instead moves it to the trash. When it's time to empty the trash, it asks you again to make sure you're not screwing yourself over.

    However, many programs create temporary files and then promptly delete them -- so many times that it would be ridiculously inefficient (both in space and fragmentation levels) to put them into the trash. Furthermore, can you imagine looking for your files in the middle of all sorts of files with names like 11025u012348512i51253.tmp?

    As someone said on the other forum, there's the hard way -- grep for it on the raw partition. This may not even work with ReiserFS, I'm not sure. The usual way to protect yourself from this is to back up in the first place (yeah, I know) and to only run programs you trust as a user that can delete files that you need.

    I would suggest that you try the grep method, and if that doesn't work, learn from it. The safest way to do this is (ironically) the command line. If you type "cp", you know for sure it will copy the file. If you type "mkisofs" or something similar, it is very unlikely that it will delete the files. And these tools (along with mv, which does delete the old copy after the new one is successful) have been around for so long and are so simple that the only way you could screw this up is through a very stupid mistake (like rm instead of cp) or using an experimental filesystem, which despite the opinion at Gentoo, ReiserFS is not.

    --
    Don't thank God, thank a doctor!
    1. Re:Good luck... by GigsVT · · Score: 4, Interesting

      On the other hand, an operating system is considered inefficient these days if it doesn't use 100% of the RAM for something or another.

      What use is "empty" disk space? The OS might as well use it for something, as long as it can ditch things that aren't important if there is a demand for space. As for your temp file issue, it's easy enough to just make /tmp and /var/tmp (and any others) a different file system that doesn't act this way.

      Modern file systems don't need to have a limited number of inodes. Even ext3 by default creates way too many inodes on large file systems, if you are going to be storing files of any significant size.*

      I think it's high time for filesystem reform, and it doesn't need anything revolutionary like databased buzzword filled paradigm shifting crap. It's just logical evolutionary improvements.

      *And it wastes 5% of the space by default! That's 100 GB on a 2TB fs completely wasted! Always use -m0 on storage fs's or -m1 on system fs with mke2fs. Use -T largefile4 to make one inode per 4MB, which is fine for storing "large" files. Otherwise the fs takes hours to create all those damn unnecessary inodes on a large fs.

      --
      I've had enough abrasive sigs. Kittens are cute and fuzzy.
    2. Re:Good luck... by Gilk180 · · Score: 2, Insightful

      The problems with this are in efficiency. Leaving the files in place would create fragmentation problems. Moving them to another part of the disk would result in a lot of unnecessary disk activity.

      Periodic backups are a much better answer.

      Schemes like this would also require the fs to delete old files when the space is needed, but this is what is done now. The data is still there until the space is used by something else (and even after that for all of you super security freaks). Given, the choice of what to delete could be made in a manner to use the least recently deleted space first, but this would again cause efficiency problems.

    3. Re:Good luck... by xenocide2 · · Score: 2, Informative

      Actually, rotational storage is very different from standard memory. Its considered inefficient not to use as much RAM as possible because using one page is as useful as the next. There's a uniform cost across all areas of RAM. In contrast, one prefers linear writes in a disk because it improves throughput. Each page on disk is not identical in usage cost. What we're paying here is the oppertunity cost if we use a specific page in disk.

      On the other hand, I agree that a marked for deletion queue makes a great use of "extra" disk space on a desktop system. But this use should not be forced on a filesystem that's used in a wide variety of different situations. Ideally, this idea can be done on top of the file system.

      --
      I Browse at +4 Flamebait

      Open Source Sysadmin

    4. Re:Good luck... by SteveOU · · Score: 4, Informative

      I will point out that the filesystems included in Novell's Netware product did include a deletion-recovery tool, accessible via the salvage command. My understanding was that Netware would not permantently delete a file until that disk space was needed for active data or until a timeout period expired.

      Damned handy tool, too. We had IBM's TSM for our major backup operations, but for those "oops" moments, salvage was sure handy. I hope that the new Novell might consider implementing those features on existing linux filesystems, or at least contribute native linux implemenations of their filesystems.

    5. Re:Good luck... by isj · · Score: 2, Informative
      A filesystem has never (AFAIK) implemented a trash / recycle bin folder -- not on Windows or OS X, and not on any UNIX that I know of.

      Actually, OS/2 implemented it. It could be enabled/disabled per drive, the size of the trashcan could be configured, and it worked even for temporary files made by programs. And yes, it was somewhat slow.

  2. Stop!!! by zulux · · Score: 5, Interesting

    Take the filesystem offline. NOW!

    Then use dd to copy the partition to another partion/disk. Then mess with the copy.

    A lot of silesystems do a good job at keeping files and their blocks in order. I've had luck with *BSD file-system by grepping for somthing at the begining of the file and grabbing a big chunk of data afterwords. This works great for MS Office Documents, JPEG or anthing that begins with a known preamble.

    This may not work for your filesystem.

    --

    Moneyed corporations, non-working 'poor' and criminal prisoners are turning productive citizens into tax-slaves.

  3. More questions... by ComputerSlicer23 · · Score: 2, Insightful

    First off, I have several questions. Do you have an original copy of the partition before you started running recovery tools (after you deleted the file, but before you created new ones)? If not, make an image immediately. You want the most original image you can find. Now, the second question, is how much data am I a looking for, and how large is the partition? (How large is the needle, and how large is the haystack?). What type of data am I looking for? Is it a word document? A text file? A gif? A jpg? Some html? A PDF? The smaller the file, the more likely that if it got overwritten, it all got overwritten. However, the more likely you are to recover all of it. If it was a very large file, it's possible that you can recover pieces and parts, but not all of it. Now, it's my understanding that you can recover anything written to a harddrive, even if you have overwritten it several times. However, it's very, very expensive to do so. So now the question is how much money is it worth to you? The guys as ReiserFS probably have the best shot at helping you. They probably don't want to however. The more you know about the order of the files in the directory, the more you know about how the files were constructed, and the order files got put on disk the better. They you can make better educated guesses about the sequence in which the pages got allocated to know where to go look for the file. Do you have anything on the drive you are worried about posting? Can you post an image of the drive? I'm not an expert in this area, but I've seen people recover mail spools at an ISP using dd. People leave ISP's over losing all their mail, so they worked really hard at it (however, that was an ext2 filesystem). Kirby

    1. Re:More questions... by zulux · · Score: 2, Informative

      If a certain sequence of bits on the disk was originally 1011010010001011101001, and it got overwritten with 0110101101010010101111, how -- barring psychics, voodoo, and fairy dust -- can the original be recovered?

      By reading the slop in between tracks. The writes look more like layers, with little bit of data poking out from the edges, to a scanning electron microscope.

      Think of paint layers - at the edge, you can somtimes pick out the previous colors and the order that they were painted.

      Of course, this isen't for meere mortals. People like the CIA get to play with this stuff.

      --

      Moneyed corporations, non-working 'poor' and criminal prisoners are turning productive citizens into tax-slaves.

    2. Re:More questions... by Nucleon500 · · Score: 3, Informative

      It has to do with the analog nature of the storage. If you had 0, 1, 1, 0, and you overwrote that with zeros, you'd then have 0, .1, .1, 0. Chances are that the drive itself (without at least modified firmware) can't tell the difference, but a data recovery lab can. You can actually still read data after it's been written between 5 and 20 times - each time, subtract the obvious and multiply the residue.

    3. Re:More questions... by Gordonjcp · · Score: 2, Informative
      People like the CIA get to play with this stuff.


      Except that they don't. It's entirely a myth that the CIA can read multiply-overwritten data from hard disks. The idea that the tracks look like layers doesn't hold up - you'd have to use less and less write density every time. It doesn't happen that way.


      Now, what you can do - and what does work - is look at the analogue signal from the head and see what the variance from an "average" one or zero is. So, if the head returns a 4mV pulse for a one, on average, then it's likely that a 4.1mV pulse used to be one last time, and a 3.9mV pulse used to be a zero. This is a gross oversimplification, but you get the idea. It works, but not very well.

  4. Name the program please by damu · · Score: 2, Insightful

    If you had this problem then I or anyone will have this problem too, so please let us know what program you are talking about. Was a user error? Was it a bug? Is the bug being worked on?

    --


    Useless sig.
    1. Re:Name the program please by martinde · · Score: 2, Informative

      > If you had this problem then I or anyone will have this problem too, so please let us know what program you are talking about.
      > Was a user error? Was it a bug? Is the bug being worked on?

      I'm not poster so I don't know the answer to your question, but I will say I've accidently done this in K3b. I had files highlighted in the list of files to burn, AND there were files highlighted in the tree view of my filesystem. I hit the delete key thinking it would remove the ones from the list of files to burn; nope, it deleted them from the filesystem!

    2. Re:Name the program please by DarkSarin · · Score: 3, Informative

      The program, which I now feel safe in naming, was CDBakeOven 2.0 (yeah, I know, beta software and all that-it still shouldn't EVER do this!)

      To the user who gave instructions on how to use rebuild tree, those are about the same steps
      I used (same -S option) on --rebuild-tree, to no avail.

      So, the end result is--thanks, but so far the best advice still seems to be to pay the $25 to the folks who made the fs. I may yet do that. In the mean time, I am using my sorry winXP install....

      blech

      --
      "We don't know what we are doing, but we are doing it very carefully,..." Wherry, R.J. Personnel Psychology (1995)
  5. Suddenly... by Anonvmous+Coward · · Score: 5, Insightful

    ...every Windows user looks at that Recycle Bin shortcut on their desktop and smiles.

    (No, that's not really a troll. Human error happens.)

    1. Re:Suddenly... by zulux · · Score: 2, Insightful

      ...every Windows user looks at that Recycle Bin shortcut on their desktop and smiles.

      The recycle bin only works if it's a well-behaved GUI app.

      Do this...

      START->RUN->COMMAND and hit enter.

      type in

      DEL c:\*.* and hit enter.

      If you're asked any questions - say 'yes'

      Now.... Try to find your files in the "Recycle Bin."

      --

      Moneyed corporations, non-working 'poor' and criminal prisoners are turning productive citizens into tax-slaves.

    2. Re:Suddenly... by GreyWolf3000 · · Score: 2, Insightful

      Nevertheless, that is not functionality present with the Recycle Bin. Desktops such as Gnome and KDE both have their own implementations that work about as well. Norton's software is data recovery. Apples and oranges, buddy.

      --
      Slashdot: Where people pretend to be twice as smart as they really are by behaving like children.
    3. Re:Suddenly... by OrangeTide · · Score: 2, Insightful

      Suddenly Bill Gates erases your minds so you forget that Windows stole the idea from MacOS (which stole the idea originally and made it mainstream:)

      --
      “Common sense is not so common.” — Voltaire
  6. Try this by Anonymous Coward · · Score: 5, Informative

    I really don't understand how this was done. None the less you CAN recover from this. Here's a little tutorial I found. I Highly suggest doing the backup first!!! :

    If you're really really desperate, you can do what I did a few weeks ago. In my \
    case, fsck didn't recover the partition either, indeed it crashed. So here's what's \
    I did from the beginning of what I think fixed it:

    1) reiserfsck --rebuild-tree
    2) mount
    3) reiserfsck -S
    4) debugreiserfs to get metadata for Vitaly
    5) mount
    6) mount again

    I'm not sure why this happened, but after the second mount, the partition was not \
    recognizeable as ReiserFS anymore. I suspect it had to do with a few really huge \
    files that were originally on the partition that reisefsck -S tried to recover. In \
    doing so it probably hosed lots of stuff. Now, it was as simple as

    7) reiserfsck --rebuild-tree

    And I had most of my data linked under lost+found! Took me a few hours to sort \
    through it all but I got back most of what I cared about. Maybe if you use the new \
    pre8 fsck you won't need to jump through these hoops. Since the potential for data \
    destruction is high here, I wouldn't blame you for not trying. And yes, this all \
    happened by trial and error ::-)

    This might help too :
    http://marc.theaimsgroup.com/?l=reiserfs&m=1048613 18421306&w=2.

    Good luck!

  7. Ask Namesys by cornice · · Score: 4, Informative

    Pay Namesys $25. They wrote ReiserFS so they should know. You'll be getting really great support and helping those who wrote your file system. Look here:

    http://www.namesys.com/support.html

  8. The way i did it by jjshoe · · Score: 3, Informative
    I managed to re-create the resier file system three times over 20 years of digital photos, with no backup ofcourse. I was able to replay the journal recovering all but the most recent photos.


    I beleive i used the --rebuild-tree option. You should follow the steps in the manpage under Example.


    so in short, man reiserfsck before asking slashdot :)

    --
    -- botsex is {grep;touch;strip;unzip;head;mount} /dev/girl -t {wet;fsck;fsck;yes;yes;yes;umount} {/de
  9. Let me be Mr. Barn-door-closer.... by Bombcar · · Score: 2, Insightful

    But it can be helpful in the future to dedicate, say 10% of your drive to an LVM snapshot space....

    I haven't done this yet (I'm lucky! I have a real tape drive to backup my stuff.....) but I plan to make my system take a snapshot every hour and every day (total of two) so that at most I lose an hour's worth of work.

    Also, I've always wondered if it was possible to make an operating system that would take as long to destroy something as it did to create it. For example, your term paper took ten days to write, so the rm termpaper.tex command would take ten days to run :)

  10. Re:The Coroners Toolkit by menscher · · Score: 3, Informative

    Nice job karma-whoring, but TCT does NOT work with journaled filesystems.

  11. Re:Happened to me the other day with ext3 by deek · · Score: 2, Interesting


    Depending on what you want to undelete, you can always do a grep -a -100 STRING /dev/DEVICE. That recently came in handy for me when I accidently deleted a directory with a script file that I really needed. Took me a whole day to write that script, so I was not eager to rewrite it again. I managed to recover the whole script.

  12. Solution by scheme · · Score: 2, Informative

    Since ext3 is just ext2 with added features, you can undelete the file the way you would do so on ext2. There's actually an undelete howto for ext2. The basic gist of it is that you immediately unmount and remount the partition read only. Then you grab a list of last delete blocks and use that to recontruct the file. I've done it once or twice but I've been fortunate enough to have a tape backup solution that has been able to alleviate the need for this for a while now.

    --
    "When you sit with a nice girl for two hours, it seems like two minutes. When you sit on a hot stove for two minutes, it
  13. Stop mucking around by You're+All+Wrong · · Score: 3, Interesting

    "I was using a GUI burning software that will remain nameless for now"

    _Either_
    - you fucked up, be a man and admit it's your fault;
    - the software fucked up, in which case let others know what it was and how it fucked up so that they can avoid risking the same bug.

    YAW.

    --
    Your head of state is a corrupt weasel, I hope you're happy.
  14. Wow this is so easy I'm surprised no one got it by anthony_dipierro · · Score: 4, Insightful

    How do you recover accidentally deleted files in Reiserfs?

    It's really easy. You just restore from backup.

  15. Some file systems do have a trash can actually. by TheSimkin · · Score: 2, Informative

    Just FYI. Netware's file system does have a trashcan built in and will keep the files that you've deleted. Even multiple versions of them until ther is no room on the storage device, then it will start to actually delete the oldest deleted files at that point. It's quite useful! you can disable the function globally or just on a directory/tree also. It has been doing this since version 2 for sure. Possible even before that.

  16. Re:You again! by Lord+Bitman · · Score: 2, Insightful

    Perhaps also you don't understand that I /like/ holding shift. Delete is a powerful word, you must use it with care.

    --
    -- 'The' Lord and Master Bitman On High, Master Of All