Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to undelete a large file I deleted using the rm -r command on the directory it was located in. The file was on a 1TB usb external harddisk. Nothing was written to the disk after the file was deleted, I simply unmounted and realised my mistake. I'm fairly sure I know the name of the file, although it would be handy to be able to see a list of previous files in case there was another deleted by mistake.

I've seen this question: how to undelete files on btrfs partition?

I tried what was suggested there but had no luck:

./btrfs-undelete /dev/sdb1 mydir/file.name
Searching roots... found 0 roots.
rm: cannot remove '/tmp/btrfs-undelete.19720': No such file or directory
Didn't find 'mydir/file.name'

I am therefore stumped. Any suggestions would be appriciated.

share|improve this question
    
Looking at the btrfs-undelete script it actually has some odd stuff in it: /find-root /dev/mapper/queen-home – Paul Brownsea Jun 4 '13 at 19:09
up vote 3 down vote accepted

I think I did it.

I first did

btrfs-find-root /dev/sdb1

Which gave me a large list. The one that I was interested in was:

Well block 65626112 seems great, but generation doesn't match, have=1000, want=1001

So now I mounted another hard disk as I was short of space. Then I did:

btrfs restore -t 65626112 /dev/sdb1 /media/usb

Using the 65626112 which I had found from the previous command. It is now restoring the files from the btrfs filesystem to /media/usb and I can copy any I want and delete the rest. If I still don't find the file I am after I can use the next block from the list until I do.

share|improve this answer
    
I should mention it is restoring everything that was on the drive at that time. So plenty of space is needed. – Paul Brownsea Jun 6 '13 at 22:37
    
There's a new --dry-run option, use it with -v to see the list of files that would be restored. – eMPee584 Mar 1 '14 at 2:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .