Linux 数据恢复工具extundelete

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux 数据恢复工具extundelete相关的知识,希望对你有一定的参考价值。

  1. 安装

    wget https://jaist.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2

    tar jxvf extundelete-0.2.4.tar.bz2

    cd extundelete-0.2.4/

    ./configure

    [[email protected] extundelete-0.2.4]# ./configure
    Configuring extundelete 0.2.4
    configure: error: in `/usr/local/src/extundelete-0.2.4‘:
    configure: error: C++ compiler cannot create executables

    yum install gcc-c++.x86_64

    [[email protected] extundelete-0.2.4]# ./configure     
    Configuring extundelete 0.2.4
    configure: error: Can‘t find ext2fs library

    [[email protected] extundelete-0.2.4]# yum -y install e2fsprogs-devel

    [[email protected] extundelete-0.2.4]# ./configure

    [[email protected] extundelete-0.2.4]# make

    [[email protected] extundelete-0.2.4]# make install

  2. extundelete用法

    [[email protected] ~]# extundelete --help
    Usage: extundelete [options] [--] device-file
    Options:
      --version, -[vV]       Print version and exit successfully.
      --help,                Print this help and exit successfully.
      --superblock           Print contents of superblock in addition to the rest.
                             If no action is specified then this option is implied.
      --journal              Show content of journal.
      --after dtime          Only process entries deleted on or after ‘dtime‘.
      --before dtime         Only process entries deleted before ‘dtime‘.
    Actions:
      --inode ino            Show info on inode ‘ino‘.
      --block blk            Show info on block ‘blk‘.
      --restore-inode ino[,ino,...]
                             Restore the file(s) with known inode number ‘ino‘.
                             The restored files are created in ./RECOVERED_FILES
                             with their inode number as extension (ie, file.12345).
      --restore-file ‘path‘  Will restore file ‘path‘. ‘path‘ is relative to root
                             of the partition and does not start with a ‘/‘
                             The restored file is created in the current
                             directory as ‘RECOVERED_FILES/path‘.
      --restore-files ‘path‘ Will restore files which are listed in the file ‘path‘.
                             Each filename should be in the same format as an option
                             to --restore-file, and there should be one per line.
      --restore-directory ‘path‘
                             Will restore directory ‘path‘. ‘path‘ is relative to the
                             root directory of the file system.  The restored
                             directory is created in the output directory as ‘path‘.
      --restore-all          Attempts to restore everything.
      -j journal             Reads an external journal from the named file.
      -b blocknumber         Uses the backup superblock at blocknumber when opening
                             the file system.
      -B blocksize           Uses blocksize as the block size when opening the file
                             system.  The number should be the number of bytes.
      --log 0                Make the program silent.
      --log filename         Logs all messages to filename.
    --log D1=0,D2=filename   Custom control of log messages with comma-separated
       Examples below:       list of options.  Dn must be one of info, warn, or
       --log info,error      error.  Omission of the ‘=name‘ results in messages
       --log warn=0          with the specified level to be logged to the console.
       --log error=filename  If the parameter is ‘=0‘, logging for the specified
                             level will be turned off.  If the parameter is
                             ‘=filename‘, messages with that level will be written
                             to filename.
       -o directory          Save the recovered files to the named directory.
                             The restored files are created in a directory
                             named ‘RECOVERED_FILES/‘ by default.

  3. 通过extundelete恢复单个文件

    1.模拟数据误删除环境

    以ext4文件系统为例

    [[email protected] ~]# mkdir /data

    [[email protected] ~]# mkfs.ext4 /dev/sdc1

    [[email protected] ~]# mount /dev/sdc1 /data/

    [[email protected] ~]# cp /etc/passwd /data
    [[email protected] ~]# mkdir /data/test


    [[email protected] ~]# echo "extundelete test" > /data/test/mytest.txt

    [[email protected] data]# md5sum passwd
    f1a0dd6601afdab09a66ab7741c74f66  passwd
    [[email protected] data]# md5sum test/mytest.txt
    eb42e4b3f953ce00e78e11bf50652a80  test/mytest.txt
    [[email protected] data]# rm -rf /data/*

    2.卸载磁盘分区

    [[email protected] data]# cd /mnt/
    [[email protected] mnt]# umount /data

    3.查询可恢复的数据信息

    通过extundelete命令可以查询/dev/sdc1分区可恢复的数据信息

    [[email protected] /]# extundelete /dev/sdc1 --inode 2
    NOTICE: Extended attributes are not restored.
    Loading filesystem metadata ... 38 groups loaded.
    Group: 0
    Contents of inode 2:
    0000 | ed 41 00 00 00 10 00 00 94 aa 75 58 54 aa 75 58 | .A........uXT.uX
    0010 | 54 aa 75 58 00 00 00 00 00 00 02 00 08 00 00 00 | T.uX............
    0020 | 00 00 08 00 05 00 00 00 0a f3 01 00 04 00 00 00 | ................
    0030 | 00 00 00 00 00 00 00 00 01 00 00 00 d5 21 00 00 | .............!..
    0040 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
    0050 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
    0060 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
    0070 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
    0080 | 1c 00 00 00 c8 15 0b 0d c8 15 0b 0d dc 36 bf 4b | .............6.K
    0090 | b2 a8 75 58 00 00 00 00 00 00 00 00 00 00 00 00 | ..uX............
    00a0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
    00b0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
    00c0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
    00d0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
    00e0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
    00f0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................

    Inode is Allocated
    File mode: 16877
    Low 16 bits of Owner Uid: 0
    Size in bytes: 4096
    Access time: 1484106388
    Creation time: 1484106324
    Modification time: 1484106324
    Deletion Time: 0
    Low 16 bits of Group Id: 0
    Links count: 2
    Blocks count: 8
    File flags: 524288
    File version (for NFS): 0
    File ACL: 0
    Directory ACL: 0
    Fragment address: 0
    Direct blocks: 127754, 4, 0, 0, 1, 8661, 0, 0, 0, 0, 0, 0
    Indirect block: 0
    Double indirect block: 0
    Triple indirect block: 0

    File name                                       | Inode number | Deleted status
    .                                                 2
    ..                                                2
    lost+found                                        11             Deleted
    passwd                                            12             Deleted
    test                                              128513         Deleted

    根据上面输出,标记为Deleted状态的是已经删除的文件或目录,同时,还可以看到每个已删除文件inode值,接下来就可以恢复文件了

    4.恢复单个文件

    执行如下命令开始恢复文件

    extundelete /dev/sdc1 --restore-file passwd

以上是关于Linux 数据恢复工具extundelete的主要内容,如果未能解决你的问题,请参考以下文章

Linux 安全工具之extundelete误删除恢复

案例:Oracle数据库文件删除 extundelete工具挖掘恢复删除的数据库文件

Linux中用extundelete恢复误删除的数据

Linux中利用extundelete恢复误删除的数据

linux extundelete 删除文件恢复

Linux系统通过extundelete恢复已删除的数据