centos7安装ext3grep
前言
在平常我们手机里面删除一个文件,其实文件时并没有被真正删除的,它只是被贴上了一个标记,标记为可被覆盖,只是对于用户来说,它变得不可见了,当有的新的数据进来时则有可能覆盖掉原来的被删除的文件,那么此时该文件才是真正意义上的被删除,如果我们将被删除但还没有被覆盖的文件的标记改回来并恢复文件,那么这个操作即为恢复文件。
ext3grep就是这么一个工具。
安装
安装前准备,输入以下命令检测环境是否ok:
rpm -qa|grep e2fs
必须有以下三个依赖库:
我使用的腾讯云,检查的时候就只e2fsprogs-devel没有,直接使用yum安装即可: yum install -y e2fsprogs-devel
首先去官网(https://code.google.com/archive/p/ext3grep/downloads—)下载压缩包:
这里也给出一个蓝奏云链接方便读者下载,蓝奏云,密码cp9b
先解压:
tar zxf ext3grep-0.10.2.tar.gz
进入目录:
cd ext3grep-0.10.2
环境配置:
./configure
遇到以下提示:
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... pch
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking dependency style of g++... none
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in /root/ext3grep-0.10.2': configure: error: C++ preprocessor "/lib/cpp" fails sanity check See
config.log' for more details.
就算前面咱看不懂,但是最后三排,有两个error,那自然是有问题的
继续面向百度解决问题,原来要安装c艹:
yum install -y gcc-c++
再make预编译时遭遇以下报错:
make all-recursive
make[1]: Entering directory /root/ext3grep-0.10.2' Making all in src make[2]: Entering directory
/root/ext3grep-0.10.2/src'
g++ -Iempty.pch.h -DHAVE_CONFIG_H -I. -I.. -g -O2 -DUSE_MMAP=1 -I/usr/include/ext2fs -I/usr/include/et -include pch.h
-c -o pch.h.gch/6145d4709c827f9d2a94d7691c87ab4e ./pch-source.h
In file included from ./pch-source.h:43:0:
./ext3.h: In member function ‘__u32 Inode::reserved2() const’:
./ext3.h:113:42: error: ‘i_reserved2’ was not declared in this scope
__u32 reserved2(void) const { return i_reserved2; }
^
./ext3.h: In member function ‘void Inode::set_reserved2(__u32)’:
./ext3.h:115:37: error: ‘i_reserved2’ was not declared in this scope
void set_reserved2(__u32 val) { i_reserved2 = val; }
^
make[2]: *** [pch.h.gch/6145d4709c827f9d2a94d7691c87ab4e] Error 1
make[2]: Leaving directory /root/ext3grep-0.10.2/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory
/root/ext3grep-0.10.2'
make: *** [all] Error 2
进入src目录修改ext3.h文件即可,需要添加的地方有两处(添加的内容为彩虹代码块):
第一处:
#ifndef EXT3_H
#define EXT3_H
#ifdef _LINUX_EXT2_FS_H
#error please include this file before any other includes of ext2fs/ext2_fs.h
#endif
#define s_clusters_per_group s_frags_per_group
第二处:
__u32 faddr(void) const { return i_faddr; }
__u16 uid_high(void) const { return i_uid_high; }
__u16 gid_high(void) const { return i_gid_high; }
#ifndef i_reseved2
#define i_reserved2 osd2.hurd2.h_i_author
#endif
读者也可参考该文章https://blog.csdn.net/dizui6048/article/details/101943111
随后再执行make和make install即可
安装好后可以使用ext3grep -v检查是否安装成功,成功后如下:
致歉
为之前看到此篇教程的朋友们致以真诚的道歉,时至今日,2021.4.4,回首看这篇教程我才发现前面,第一处该添加的内容少了一行:#define s_clusters_per_group s_frags_per_group
。所以导致跟着此教程走,ext3grep安装失败,现在已经修改好了,确认教程没有问题了。以后我会在写博文时更加仔细,谨慎,以后还请大家多多指正。