diskgenius

EXT4中恢复使用rm命令误删除的文件

2012-8-1 17:28| 发布者: 蝴蝶| 查看: 3162| 评论: 0|原作者: 影子|来自: Linux运维网

摘要: 起因:前几天在公司服务器上误操作将ORACLE某表空间文件给删除了,结果导致几张表不能正常访问遂谷歌了一把发现了神器 extundelete(如果是ext3文件系统请使用ext3grep,本人未做测试),这玩意可比瘟得死下面的各种恢 ...
起因:前几天在公司服务器上误操作将ORACLE某表空间文件给删除了,结果导致几张表不能正常访问
遂谷歌了一把发现了神器 extundelete(如果是ext3文件系统请使用ext3grep,本人未做测试),这玩意可比瘟得死下面的各种恢复工具强大多了(至少本人是这么认为的),下面看步骤:
一、下载及安装软件
extundelete 主页:http://extundelete.sourceforge.net/
下载地址:http://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.0/extundelete-0.2.0.tar.bz2
ubuntu用户可直接安装: apt-get install extundelete

Shell
[root@www ~]# wget http://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.0/extundelete-0.2.0.tar.bz2
[root@www ~]# tar xf extundelete-0.2.0.tar.bz2
[root@www ~]# cd extundelete-0.2.0
[root@www extundelete-0.2.0]# ./configure && make && make install    # 如果提示找不到ext2fs库,使用 yum -y install e2fsprogs* 安装
二、执行删除操作

Shell
[root@www ~]# df -Th
文件系统    类型      容量  已用  可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
              ext4     38G  2.2G   34G   6% /
tmpfs        tmpfs    122M     0  122M   0% /dev/shm
/dev/sda1     ext4    485M   30M  430M   7% /boot
/dev/sdb1     ext4   1003M   18M  935M   2% /mnt/test
[root@www ~]# ls /mnt/test/
extundelete-0.2.0.tar.bz2  hosts  lost+found  resolv.conf
[root@www ~]# rm -rf /mnt/test/hosts /mnt/test/resolv.conf
[root@www ~]# ls /mnt/test/
extundelete-0.2.0.tar.bz2  lost+found
    1.卸载需要恢复文件的分区

Shell

[root@www ~]# fuser -k /mnt/test/               <-- 结束使用某分区的进程树
[root@www ~]# umount /mnt/test                  <-- 卸载分区
    2.使用extundelete查看分区上存在的文件

Shell

[root@www ~]# extundelete --inode 2 /dev/sdb1    # --inode 为查找某i节点中的内容,使用2则说明为搜索,如果需要进入目录搜索,只须要指定目录I节点即可

上图中红框内容可以看出,被删除的两个文件已经被找到,状态为已经删除,接下来就将它们恢复出来

Shell
[root@www ~]# extundelete --restore-inode 13 /dev/sdb1    # --restore-inode 恢复指定的I节点文件,默认全将恢复出来的文件放在当前路径 RECOVERED_FILES/ 目录下,文件名为 file.I节点号
WARNING: Extended attributes are not restored.
Loading filesystem metadata ... 8 groups loaded.
Loading journal descriptors ... 21 descriptors loaded.
Writing output to directory RECOVERED_FILES/
Restored inode 13 to file RECOVERED_FILES/file.13
[root@www ~]# extundelete --restore-inode 14 /dev/sdb1
WARNING: Extended attributes are not restored.
Loading filesystem metadata ... 8 groups loaded.
Loading journal descriptors ... 21 descriptors loaded.
Restored inode 14 to file RECOVERED_FILES/file.14
[root@www ~]# ls RECOVERED_FILES/
file.13  file.14
[root@www ~]# mount /dev/sdb1 /mnt/test/
[root@www ~]# mv RECOVERED_FILES/file.13 /mnt/test/resolv.conf
[root@www ~]# mv RECOVERED_FILES/file.14 /mnt/test/hosts
[root@www ~]# cat /mnt/test/hosts            # 查看被恢复出来的文件 是否与源文件一致
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.250   www.skyelek.com www
192.168.1.250   svn.skkelek.com svn
[root@www ~]# cat /mnt/test/resolv.conf
; generated by /sbin/dhclient-script
search www..com skyelek.com
nameserver 192.168.1.200

开心

鄙视
1

鼓掌

愤怒

可怜

刚表态过的朋友 (1 人)

最新评论

返回顶部