Linux 數據恢復工具extundelete

  • 安裝

    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

    [root@linux 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

    [root@linux extundelete-0.2.4]# ./configure     
    Configuring extundelete 0.2.4
    configure: error: Can't find ext2fs library

    [root@linux extundelete-0.2.4]# yum -y install e2fsprogs-devel

    [root@linux extundelete-0.2.4]# ./configure

    [root@linux extundelete-0.2.4]# make

    [root@linux extundelete-0.2.4]# make install

  • extundelete用法

    [root@linux ~]# 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.

  • 通過extundelete恢復單個文件

    1.模擬數據誤刪除環境

    以ext4文件系統爲例

    [root@linux ~]# mkdir /data

    [root@linux ~]# mkfs.ext4 /dev/sdc1

    [root@linux ~]# mount /dev/sdc1 /data/

    [root@linux ~]# cp /etc/passwd /data
    [root@linux ~]# mkdir /data/test


    [root@linux ~]# echo "extundelete test" > /data/test/mytest.txt

    [root@linux data]# md5sum passwd
    f1a0dd6601afdab09a66ab7741c74f66  passwd
    [root@linux data]# md5sum test/mytest.txt
    eb42e4b3f953ce00e78e11bf50652a80  test/mytest.txt
    [root@linux data]# rm -rf /data/*

    2.卸載磁盤分區

    [root@linux data]# cd /mnt/
    [root@linux mnt]# umount /data

    3.查詢可恢復的數據信息

    通過extundelete命令可以查詢/dev/sdc1分區可恢復的數據信息

    [root@linux /]# 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

  • 發表評論
    所有評論
    還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
    相關文章