前言
在平常我們手機里面刪除一個文件,其實文件時並沒有被真正刪除的,它只是被貼上了一個標記,標記為可被覆蓋,只是對於用戶來說,它變得不可見了,當有的新的數據進來時則有可能覆蓋掉原來的被刪除的文件,那么此時該文件才是真正意義上的被刪除,如果我們將被刪除但還沒有被覆蓋的文件的標記改回來並恢復文件,那么這個操作即為恢復文件。
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安裝失敗,現在已經修改好了,確認教程沒有問題了。以后我會在寫博文時更加仔細,謹慎,以后還請大家多多指正。