Settings

Theme

Restoring accidentally deleted files on Linux

sabotage-linux.github.io

77 points by potus_kushner 7 years ago · 7 comments

Reader

rnhmjoj 7 years ago

If you are using ext4 there is extundelete that simplifies the process, it requires to remount the filesystem read-only, though.

  mount -o remount,ro /dev/sda1
  extundelete --restore-all --after $(date -d "-1 hours" +%s) /dev/sda1
  find /RECOVERED_FILES -name accidentally_deleted_file 
  mount -o remount,rw /dev/sda1
theamk 7 years ago

Another fast way to search for text in binary files is to use "grep -abo" (treat all files as text / print matches only / print file offsets).

dusted 7 years ago

Anyone checked if that is actually faster than just using grep on the blockdevice? I've used grep the few times I've had a need for it, and just copied the source off the terminal when its found something. (Tell grep to give you some lines before and after a match, and tell it to treat the blockdevice as plain-text).. You usually get some trash before/after the matches, those could be terminal control characers, but a those can be trimmed with, drumroll: tr.

rrauenza 7 years ago

Last time I had this happen (thankfully a long time ago) I just used Perl against the block device and used a regex.

Forensic tools also work well for this.

aurox 7 years ago

Thanks, this will come in handy. Needed it a bunch in the past.

jvanderbot 7 years ago

shouldn't that be (addr1-addr2+1)? Or does dd copy the first byte plus the count?

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection