undelete a just deleted file on ext4 with extundelete
Looking at the usage guide on extundelete it seems as though you're limited to undeleting files to a few ways.
Restoring all
extundelete is designed to undelete files from an unmounted partition to a separate (mounted) partition. extundelete will restore any files it finds to a subdirectory of the current directory named “RECOVERED_FILES”. To run the program, type “extundelete --help” to see various options available to you.
Typical usage to restore all deleted files from a partition looks like this:
$ extundelete /dev/sda4 --restore-all
Restoring a single file
In addition to this method highlighted in the command line usage:
--restore-file path/to/deleted/file
Attemps to restore the file which was deleted at the given filename,
called as "--restore-file dirname/filename".
So you should be able to accomplish what you want doing this:
$ extundelete --restore-file /var/tmp/test.iso /dev/sda4
NOTE: In both cases you need to know the device, /dev/sda4
to perform this command. You'll have to remount the filesystem as readonly. This is one of the conditions of using extundelete
and there isn't any way around this.
Typical usage scenario when undeleting all files includes need to restore all files deleted from /dev/sdX1
during approximately last hour:
mount -o remount,ro /dev/sdX1
extundelete --restore-all --after $(date -d "-2 hours" +%s) /dev/sdX1
find RECOVERED_FILES/
If satisfied with recovered files:
mount -o remount,rw /dev/sdX1
extundelete didn't work for me but ext4magic did.