Recovering Deleted Data in Linux Ext3 Filesystem: Use Trash Can

Written by BinnyVA on January 25, 2009 – 11:55 pm -

Deleting Files to the Trash

As most of you know, Ext3 file system don’t have to be defragmented like the FAT32 or NTFS file systems. This is a nice feature – but this has a bad side effect as well. You cannot recover deleted files. This is a good trade-off in a server environment. Its not practical to run a defragmenter on a live server. It might take hours to complete – and disk access will not be allowed in that time. And most server environment have very strong backup mechanisms – so data recovery is not a big issue. But when it comes to the desktop environment, this is a very Bad Thing.

From a desktop user perspective, it is not a huge deal to run a defragmenter once in a while. I used to do it once every month or so when I was on windows. But accidental deletion is a huge problem as most desktop users don’t have a very strong backup system in place.

In Windows(FAT32 or NTFS) if you want a deleted file back, there are file recovery software available that might recover the file. There is a good chance of getting back the file in one piece if you try to recover the file soon. But this is not possible in Ext3 – the way the file system is designed makes it next to impossible. This is because the file system will overwrite the deleted portions – to prevent fragmentation of files. The advantage of this method is that fragmentation will be avoided. The disadvantage is, well, you will not be able to recover deleted files.

Solution: The Trash

There is a very simple solution to this problem – but it is something no self respecting geek will use. The Recycle Bin. The Trash Can. Use it.

The problem is I have not seen anyone other than total newbies delete files into the Trash. Most people I know use the Shift+Delete shortcut to delete. I use a slightly different shortcut – Shift+Delete, Enter. That means I don’t even see the deletion confirmation prompt. And if when I delete something important, the only thing left to do is cry.

I have several backup systems in place – but you know the Murphy’s law when in comes to backups…

You have a backup of everything – except the file that was deleted

So, start using the Trash – do a delete instead of a shift+delete. I would advice removing the confirmation dialog on the delete action to make it go faster. You can do it easily in Konquorer…

  • Open Konquorer
  • Setting > Configure Konquorer…
  • Behavior > Ask Confirmation For
  • Make sure the ‘Move to trash’ checkbox is turned off.

I am sure this is possible in Nautilus as well – but I am not sure how to do it. If any of my readers is a gnome user, please post a comment on how to do it.

One last thing – remember to clean the trash once every two days or so.


del.icio.us | Digg it | reddit | StumbleUpon

Tags: , , , , , , ,
Posted in Configuration, Opinion, Troubleshooting | 13 Comments »

13 Comments to “Recovering Deleted Data in Linux Ext3 Filesystem: Use Trash Can”

  1. Thomas Dybdahl Ahle says:

    Gnome default to no confirmation dialog. Why would you need it, when you can just recover from trash.

    Why do you think that one should clean his or her trash all the time?

  2. BinnyVA says:

    Yeah thats the point – if you use the trash, you can recover the deleted files easily.

    If you don’t clean the trash, the stuff you delete will still take up space on your hard disk. That’s why I recommend you delete the trashed files often.

  3. What is KDE? says:

    You Re 100% correct. As part of my setup of a new system, I do remove the confirm dialog from the Delete action, to encourage trashcan use. The only things that I Shift-Delete are very large files such as videos or .iso files.

  4. Amit Agarwal says:

    what I do is to make sure that rm command also moves the file to particular directory rather than deleting them, as and when necessary on the particular system. Then I have a cron running every second day to clean that directory. Works for me.

  5. BinnyVA says:

    @Amit
    I did not think about the rm command – nice tip.

  6. Carb0n says:

    I use trash…

    Nowadays (lessons learned) I refrain from rm(1) from the command line.

    The only thing I shift-del are movie files left over after converting them to a saner format, .torrent files that are completed. etc etc.

  7. ckyeu says:

    I just lost a whole day’s work. I dont know whether to cry or laugh!! Anyway, point driven home.

  8. BinnyVA says:

    @ckyeu
    I know how you feel – I hate learning stuff the hard way.

  9. Adhil Azeez NV says:

    Hi there,
    And if you really want your deleted files back, there is a somewhat difficult way. http://www.ubuntugeek.com/recover-deleted-files-with-foremostscalpel-in-ubuntu.html . Disclaimer: I never tried this. If you guys use that in a wrong way it can even result in a bulk data loss.

  10. Adhil Azeez NV says:

    Also try http://www.linuxquestions.org/questions/linux-software-2/recovering-a-deleted-file-on-ext3…-almost-there-441914/ . In this thread #11 reply contains some links to some data recovery tools

  11. applexsoft says:

    Yeah thats the point – if you use the trash, you can recover the deleted files easily

  12. gt says:

    For cli lovers, there’s

    http://code.google.com/p/trash-cli/

    I used it back when i was using ubuntu.

    Now it’s simply rm, or F8 within mc.

Leave a Comment