ext3檔案系統反刪除利器-ext3grep
導讀Linux作為企業級伺服器,資料的安全性至關重要,任何資料德爾丟失和誤刪都是不可容忍的!最近我接觸到一款軟體-ext3grep,它可以恢複誤刪的資料,下面簡單講解一下這個軟體。ext3grep的恢複原理
利用ext3grep恢複檔案時並不依賴特定文字格式設定。首先ext3grep通過檔案系統的root inode(根目錄的inode一般為2)來擷取當前檔案系統下所有檔案的資訊,包括存在的和已經刪除的檔案,這些資訊包括檔案名稱和inode。然後利用inode資訊結合日誌去查詢該inode所在的block位置,包括直接塊、間接塊等資訊。最後利用dd命令將這些資訊備份出來,從而恢複資料檔案。
ext3grep的安裝
ext3grep官方網站:http://code.google.com/p/ext3grep/
網盤下載:http://pan.baidu.com/s/1i47ZPsT
所需的系統相關包如下:
[root@localhost ~]#rpm -qa | grep e2fsprogse2fsprogs-libs-1.39-8.el5e2fsprogs-1.39-8.el5e2fsprogs-devel-1.39-8.el5
以上三個都必須安裝,不然後面的安裝會出現問題。
下面進入編譯安裝階段,過程如下:
[root@localhost /opt]# tar zxvf ext3grep-0.10.2.tar.gz[root@localhost ext3grep-0.10.2]# ./configure[root@localhost ext3grep-0.10.2]# make[root@localhost ext3grep-0.10.2]# make install[root@localhost ext3grep-0.10.2]# ext3grep -vRunning ext3grep version 0.10.2
預設的ext3grep命令放在/usr/local/bin目錄下,請通過“ext3grep --help”擷取詳細使用協助。
實戰ext3grep恢複檔案類比資料誤刪環境
下面通過一個類比環境,詳細介紹使用ext3grep恢複資料檔案的過程:
[root@localhost ~]# mkdir /disk[root@localhost ~]# mkdir /mydata[root@localhost ~]# cd /mydata[root@localhost mydata]# dd if=/dev/zero of=/mydata/disk1 count=102400[root@localhost mydata]#mkfs.ext3 /mydata/disk1
[root@localhost mydata]#mount -o loop /mydata/disk1 /disk[root@localhost mydata]#cd /disk[root@localhost disk]# cp /etc/profile /disk[root@localhost disk]# cp /boot/initramfs-2.6.32-220.el6.i686.img /disk[root@localhost disk]#echo"I am archy" > ext3grep.txt[root@localhost disk]#mkdir /disk/ext3grep[root@localhost disk]#cp /etc/hosts /disk/ext3grep[root@localhost disk]#ls -al
[root@localhost disk]#md5sum profile[root@localhost disk]#md5sum initramfs-2.6.32-220.el6.i686.img[root@localhost disk]#md5sum ext3grep.txt[root@localhost disk]#rm -rf /disk/*[root@localhost /opt]# umount /disk
查詢資料恢複資訊
執行如下命令,查詢需要恢複的資料資訊:
[root@localhost /opt]# ext3grep /mydata/disk1 --ls --inode 2
這條命令主要用於掃描當前檔案系統下所有的資訊,包括存在的和已刪除的檔案,其中含有D標識的就是檔案已被刪除。通過以下命令可以擷取檔案要恢複的路徑資訊:
[root@localhost /opt]# ext3grep /mydata/disk1 --dump-names
恢複刪除資料
單個檔案恢複命令如下:
[root@localhost /opt]# ext3grep /mydata/disk1 --restore-file ext3grep.txt
恢複的檔案存放在/opt/RESTORED_FILES目錄下。
恢複所有已刪除資料的命令如下:
[root@localhost /opt]# ext3grep /mydata/disk1 --reatore-all
本文原創地址:http://www.linuxprobe.com/file-undelete-ext3grep.html