extundelete恢复Linux删除文件
问题描述:Linux误删除文件就尴尬了rm -rf *,extundelete可以对文件系统ext3、ext4
01、extundelete-0.2.4下载
http://extundelete.sourceforge.net/
http://pan.baidu.com/s/1bYmqqa
http://nchc.dl.sourceforge.NET/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2
http://pan.baidu.com/s/1kVyspRT #extundelete二进制文件,在centos6.5下编译的
http://pan.baidu.com/s/1nvlxbip #extundelete.zip源码
02、编译前准备工作
yum install -y e2fsprogs e2fsprogs-libs e2fsprogs-devel
03、编译安装
tar -xjf extundelete-0.2.0.tar.bz2
cd extundelete-0.2.0
./configure
make
src/extundelete --help
04、参数文件详解
[root@100-lab stu]# ./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'. 默认s date +%s
--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 /dev/sda3 --restore-file
extundelete /dev/sda3 --restore-all #恢复分区所有被删除的文件(inode未被分区的原文件)
05、重新挂载被误删除文件的磁盘
注意:恢复亦有局限性,并不代表能完全恢复。只要源文件的inode未被重新分配,既可以恢复被删除的文件。
mount -o remount,ro /dev/partition #重新挂载分区,以只读模式
umont /dev/sdc1
mount -o ro /dev/sdc1 /mnt
./extundelete --node 2 /dev/sdc1
File name | Inode number | Deleted status
. 2
.. 2
lost+found 11 Deleted
extundelete-0.2.4.zip 12 Deleted
extundelete-0.2.4 8161 Deleted
./extundelete --restore-inode 12 /dev/sdc1
[root@localhost stu]# ll RECOVERED_FILES/ total 132 -rw-r--r-- 1 root root 133965 Jun 1 11:41 file.12
./extundelete --restore-file extundelete-0.2.4.zip /dev/sdc1
./extundelete --restore-all /dev/sdc1
NOTICE: Extended attributes are not restored. Loading filesystem metadata ... 8 groups loaded. Loading journal descriptors ... 42 descriptors loaded. Searching for recoverable inodes in directory / ... 5 recoverable inodes found. Looking through the directory structure for deleted files ... 2 recoverable inodes still lost.
转载:
http://ixdba.blog.51cto.com/2895551/1566856/