介绍两款Linux文件恢复工具,ext3grep与extundelete,可能在关键时刻会有所帮助。ext3grep仅对ext3文件系统有效,extundelete对ext3与ext4文件系统都有效

一 实验环境
1 软件环境
vmware workstation 9.0.1
ubuntu server 12.10 
ext3grep 0.10.1
extundelete 0.2.4
 
2 外挂磁盘
这里外挂2个磁盘来模拟需要恢复的设备。可以通过两种方式实现
第一种:在虚拟机上添加2块虚拟磁盘,具体方法略
第二种:通过dd命令用文件模拟块设备
简单介绍下第二种方式的命令:
cd /home
dd if=/dev/zero of=sdc1 bs=1M count= #块大小为1M,数量为100,也就是100M
mkfs.ext3 /home/sdc1 #ext3文件系统格式化
mount /home/sdc1 /sdc

本实例采用第一种方式添加2块磁盘,添加后一块ext3格式化,另一块ext4格式化,然后挂载。具体操作过程省略

mount 查看下
/dev/sdb1 on /sdb type ext4 (rw)
/dev/sdc1 on /sdc type ext3 (rw)
3 配置安装源列表
ubuntu配置好安装源列表后,安装软件非常方便,以下是经过测试有效的安装源列表:
root@ubuntu-test:/home# cat /etc/apt/sources.list
deb http://ubuntu.cn99.com/ubuntu/ quantal main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ quantal-updates main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ quantal-security main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu/ quantal-backports main restricted universe multiverse
deb http://ubuntu.cn99.com/ubuntu-cn/ quantal main restricted universe multiverse
二、ext3grep恢复工具
1 安装ext3grep
在ubuntu服务器上可以使用以下命令直接安装ext3grep,使用这种方式可以直接安装相关的依赖关系包,真是太省心了。
aptitude install ext3grep 
或者直接去官网下载源码包安装
官网下载地址:https://code.google.com/archive/p/ext3grep/downloads
编译安装需要先安装依赖
apt-get install e2fslibs-dev  # Centos上用yum install e2fsprogs-devel

如果不安装依赖会报错:

checking for compiler with PCH support... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
Package ext2fs was not found in the pkg-config search path.
Perhaps you should add the directory containing `ext2fs.pc'
to the PKG_CONFIG_PATH environment variable
No package 'ext2fs' found
checking ext2fs/ext2_fs.h usability... no
checking ext2fs/ext2_fs.h presence... no
checking for ext2fs/ext2_fs.h... no
checking ext2fs/ext2fs.h usability... no
checking ext2fs/ext2fs.h presence... no
checking for ext2fs/ext2fs.h... no
configure: error: Missing headers. Please install the package e2fslibs-dev from e2fsprogs, or http://e2fsprogs.sourceforge.net for the upstream tar-ball.

然后编译安装软件

tar xvf ext3grep-0.10..tar.gz
cd ext3grep-0.10.
./configuremake && make install
 
安装完后,可以用以下命令验证下:

2 ext3grep查找被删除的文件
ext3grep --ls --inode  /dev/sdc1 

注意:这里只能看到/dev/sdc1 根目录下的文件与文件夹,不能显示目录下文件
显示目录vmware-tools-distrib下的文件,列表这个目录节点号
ext3grep --ls --inode  /dev/sdc1 

以上红线条标注的表示已经被删除掉的文件或目录
如果想要显示出所有被删除文件的名字,用以下命令:
ext3grep --ls --dump-names /dev/sdc1 > filename.txt      #将显示结果放在一个文件中 
3 恢复单个文件
恢复某个指定的文件,命令如下:
ext3grep --restore-file VMwareTools-9.2.-.tar.gz /dev/sdc1 

然后在当前目录RESTORED_FILES目录下找到被恢复的文件

如果是恢复目录下面的指定文件要加上相对路径
ext3grep --restore-file vmware-tools-distrib/INSTALL.log /dev/sdc1 
 
4 恢复整个设备上的文件
ext3grep --restore-all /dev/sdc1  
5 恢复指定时间点之前或之后的所有文件
ext3grep --restore-all --after  /dev/sdc1 #恢复Apr  : 2013之后被删文件
ext3grep --restore-all --before /dev/sdc1 #恢复Apr : 2013之前被删文件
在RHEL与Ubuntu上测试,发现after与before这两个参数好像没起作用,具体啥原因没暂时还没有找到。
 
三、extundelete恢复工具
1 extundelete软件安装
下载软件
wget http://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2 
安装e2fsprogs和e2fslibs
sudo apt-get install e2fsprogs 
安装e2fslibs-dev
sudo apt-get install e2fslibs-dev 
安装C++
sudo apt-get install build-essential 
安装extundelete
tar -jxvf extundelete-0.2..tar.bz2
cd extundelete-0.2.
./configure --prefix=/usr/local/extundelete
make && make install
验证是否安装成功
cd /usr/local/extundelete/bin
./extundelete -v

2 查看被删除文件

标记为”Deleted”的文件则是被删除的文件
 
3 恢复指定的文件
./extundelete --restore-file aaa /dev/sdb1  

 
4 完全恢复设备上文件
./extundelete --restore-all /dev/sdb1 
 
5 恢复指定的时间点后被删文件
指定一个时间点
date -d "Apr 11 14:30 2013" +%s
 
恢复这个时间点后的文件
./extundelete --restore-all --after “” /dev/sdb1 

如果要恢之前的就用before参数。extundelete命令与after结合使用,在进行恢复时非常有用,可以过滤掉那太旧的文件,减小恢复压力。
 
 

Linux文件恢复利器 ext3grep与extundelete的更多相关文章

  1. 介绍两款Linux文件恢复工具,ext3grep与extundelete https://www.cnblogs.com/lazyfang/p/7699994.html

    介绍两款Linux文件恢复工具,ext3grep与extundelete,可能在关键时刻会有所帮助.ext3grep仅对ext3文件系统有效,extundelete对ext3与ext4文件系统都有效  ...

  2. Linux 文件恢复(XFS & EXT4)

    在Linux中,删除rm命令使用需谨慎,有时候可能由于误操作,导致重要文件删除了,这时不要太紧张,操作得当的话,还是可以恢复的. EXT 类型文件恢复 删除一个文件,实际上并不清除inode节点和bl ...

  3. Linux 文件恢复

    可以恢复,使用系统自还工具debugfs来还原删除的文件 步骤详解 1. 查看一下当前系统版本号,及文件系统格式 [root@localhost ~]# df -T Filesystem Type 1 ...

  4. 使用 Linux 文件恢复工具

    使用 Linux 文件恢复工具         Linux 文件恢复的原理 inode 和 block 首先简单介绍一下 Linux 文件系统的最基本单元:inode.inode 译成中文就是索引节点 ...

  5. 高性能Linux服务器 第6章 ext3文件系统反删除利器ext3grep extundelete工具恢复rm -rf 误删除的文件

    高性能Linux服务器 第6章  ext3文件系统反删除利器ext3grep  extundelete工具恢复rm -rf 误删除的文件 只能用于ext3文件系统!!!!!!!高俊峰(高性能Linux ...

  6. linux extundelete 删除文件恢复

    extundelete是基于Linux的一个数据恢复工具,它通过分析文件系统的日志,解析出所有文件的inode信息,从而可以恢复Linux下主流的ext3,ext4文件系统下被误删除的文件. [问题案 ...

  7. Linux之文件恢复[extundelete,针对rm]

    [恢复过程] 1.下载+安装extundelete cd /tmp wget wget http://jaist.dl.sourceforge.net/project/extundelete/extu ...

  8. 云服务器 ECS Linux 误删除文件恢复方法介绍

    云服务器 ECS Linux 下,rm -rf  意味着一旦删除的文件是无法挽回的.但如果在没有文件覆盖操作的前提下,可以先尝试相关方式进行文件恢复. 本文对此进行简要说明. https://help ...

  9. linux下恢复误删除的文件方法(ext2及ext3)

     linux下恢复误删除的文件方法(ext2及ext3) 2009-12-19 15:23:47 分类: LINUX 如果是ext2文件系统的,直接用debugfs是可以恢复出来的,但对于ext3,d ...

随机推荐

  1. 安装 create-react-app@latest 失败,错误代码:243

    在创建react项目,执行以下命令的时候 npx create-react-app my-app 报错如下: 解决方案: 全局安装即可 npm install -g create-react-app

  2. static和export有什么关系

    export default class Test{ public static a = 1; public static sayHello(){ } } export module Test{ ex ...

  3. SpokenEnglish01_ When's it due?

    1 Pronunciation and Intonation When's it due? 解析:When’s it due? 2 Key Points 2.1 Due adj: 到期的,截止的 It ...

  4. find和grep的使用

    1.find命令的使用 在Linux中可以使用find命令在指定的目录下查找文件.任何位于参数之前的字符串都将被视为欲查找的目录名,当使用该命令时,不设置任何参数,则find命令将在当前目录下查找子目 ...

  5. rfc 5280 X.509 PKI 解析

    本文以博客园的证书为例讲解,不包含对CRL部分的翻译,如没有对第5章节以及6.3小节进行翻译 3.2. Certification Paths and Trust 下面简单介绍了Public-Key ...

  6. SQL2014做数据库主从镜像备份(也可以用于高可用)备忘(非域控)。

    部份内容参考原始文章链接:https://www.cnblogs.com/stragon/p/5643754.html ,同时比较有参考价值的文章:https://blog.csdn.net/sqls ...

  7. aspnetcore identity result.Succeeded SignInManager.IsSignedIn(User) false?

    登陆返回的是 result.Succeeded 为什么跳转到其他页面SignInManager.IsSignedIn(User)为false呢? result.Succeeded _signInMan ...

  8. Python的正则表达式和爬虫

    1.常用元字符 . 匹配除换行符以外的任意字符 \w 匹配字母或数字或下划线 \s 匹配任意的空白符 \d 匹配数字 \b 匹配单词的开始或结束 ^ 匹配字符串的开始 $ 匹配字符串的结束 2.常用限 ...

  9. SpringBoot获得application.properties中数据的几种方式

    转:https://blog.csdn.net/qq_27298687/article/details/79033102 SpringBoot获得application.properties中数据的几 ...

  10. oracle查询包含在子表中的主表数据

    Oracle数据库,查询某表中包含在子表中的数据,子表中数据按特定条件来源于该父表,SQL命令如 ) a_table父表,b_table子表,a和b表都有commandId列,a表的commandId ...