6

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.

Chindraba
  • 2,058

1 Answers1

5

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.