Not suitable for ext3/ext4.
From man:
list_deleted_inodes [limit]
List deleted inodes, optionally limited to those deleted within limit
seconds ago. Also available as lsdel.
This command was useful for recovering from accidental file deletions
for ext2 file systems. Unfortunately, it is not useful for this pur‐
pose if the files were deleted using ext3 or ext4, since the inode's
data blocks are no longer available after the inode is released.
Example:
$ echo Hello > foo.txt
$ ls -ial
35692596 .
35692545 ..
35692597 foo.txt
$ sudo debugfs -R 'inode_dump <35692597>' /dev/sdc5
0000 b481 e803 0600 0000 82d0 d056 82d0 d056 ...........V...V
0020 82d0 d056 0000 0000 e803 0100 0800 0000 ...V............
0040 0000 0000 0100 0000 d36c 2f0b 0000 0000 .........l/.....
0060 0000 0000 0000 0000 0000 0000 0000 0000 ................
*
...
As this is a small file we only have one block i_block (offset 0x28).
The above can be laid out as:
b481 | 81b4 = i_mode : 0100664 (octal)
e803 | 03e8 = i_uid : 1000
0600 0000 | 0000 0006 = i_size_lo : 6
dbd7 d056 | 56d0 d7db = i_atime : Fri Feb 26 23:55:23 CET 2016
dbd7 d056 | 56d0 d7db = i_ctime : Fri Feb 26 23:55:23 CET 2016
dbd7 d056 | 56d0 d7db = i_mtime : Fri Feb 26 23:55:23 CET 2016
0000 0000 | 0000 0000 = i_dtime : 0
e803 | 03e8 = i_gid : 1000
0100 | 0001 = i_links_count : 1
0800 0000 | 0000 0008 = i_blocks_lo : 8, 8 * 512 = 4096 b
0000 0000 | 0000 0000 = i_flags : 0
0100 0000 | 0000 0001 = i_osd1 : 1
Direct Block Address:
d36c 2f0b | 0b2f 6cd3 = i_block[0] : 187657427
0000 0000 | 0000 0000 = ... no more
We can calculate offset to data in partition by block size (here 4096):
0x0b2f6cd3 * 4096 = 768644820992
Then dump by direct read:
$ sudo dd if=/dev/sdc5 bs=1 skip=768644820992 count=6 | hd
00000000 48 65 6c 6c 6f 0a |Hello.|
Now, if we rm foo.txt
, one can fetch the data by same dd
command as above. But it can at any moment be overwritten.
But if we do not know this offset we get short.
$ ls -ai1
35692596 .
35692545 ..
$ sudo debugfs -R 'ls -d <35692596>' /dev/sdc5
35692596 (12) . 35692545 (4084) .. <35692597> (4072) foo.txt
$ sudo debugfs -R 'inode_dump <35692597>' /dev/sdc5
The inode data is now:
b481 |
e803 |
0000 0000 | 0000 0000 = i_size_o : 0 *changed
dbd7 d056 | 56d0 d7db = i_atime : Fri Feb 26 23:55:23 CET 2016
e5d7 d056 | 56d0 d7e5 = i_ctime : Fri Feb 26 23:55:33 CET 2016 *changed
e5d7 d056 | 56d0 d7e5 = i_mtime : Fri Feb 26 23:55:33 CET 2016 *changed
e5d7 d056 | 56d0 d7e5 = i_dtime : Fri Feb 26 23:55:33 CET 2016 *changed
e803 |
0000 | 0000 = i_links_count : 0 *changed
0000 0000 | 0000 0000 = i_blocks_lo : 0 *changed
0000 0000 |
0100 0000 |
0000 0000 | 0000 0000 = i_block[0] : Zeroed out. *changed
0000 0000 |
0000 0000 |
As you can see the block data is zeroed out.