Linux ext3/ext4 文件系统数据恢复

Linux ext3/ext4 文件系统数据恢复
ext3             ext3grep
ext3/ext4     extundelete
下载地址: 
ext3grep          https://code.google.com/p/ext3grep/downloads/list
extundelete     http://nchc.dl.sourceforge.net/project/extundelete/extundelete
安装依赖组件:
yum -y install gcc gcc-c++ make e2fsprogs-devel e2fsprogs-libs
安装 ext3grep
[root@localhost src]# tar zxf ext3grep-0.10.2.tar.gz
[root@localhost src]# cd ext3grep-0.10.2
[root@localhost ext3grep-0.10.2]# ./configure ; make ; make install
[root@localhost ~]# ext3grep -v
Running ext3grep version 0.10.2
ext3grep v0.10.2, Copyright (C) 2008 Carlo Wood.
ext3grep comes with ABSOLUTELY NO WARRANTY;
This program is free software; your freedom to use, change
and distribute this program is protected by the GPL.

安装 extundelete
[root@localhost src]# tar jxf extundelete-0.2.4.tar.bz2
[root@localhost src]# cd extundelete-0.2.4
[root@localhost extundelete-0.2.4]# ./configure ; make ; make install
[root@localhost ~]# extundelete -v
extundelete version 0.2.4
libext2fs version 1.41.12
Processor is little endian.

验证数据恢复:
文件系统: ext3
使用工具: ext3grep
[root@localhost ~]# mkfs.ext3 /dev/my_vg/my_lv       # 将分区格式化为 ext3
[root@localhost ~]# mount /dev/my_vg/my_lv /data/    # 挂载到 /data 目录
[root@localhost ~]# cd /data/
[root@localhost data]# mkdir share                   # 创建测试目录
[root@localhost data]# echo "***************************" > file1.txt
[root@localhost data]# echo "&&&&&&&&&&&&&&&&&&&&&&&&&&&" > share/file2.txt   # 测试文件
[root@localhost data]# rm -rf *       # 我们将 data 目录下的所有文件、目录全部删除
[root@localhost data]# cd /tmp/       # 切换到别的目录
[root@localhost tmp]# umount /data/   # 卸载分区
[root@localhost tmp]# ext3grep /dev/my_vg/my_lv --ls --inode 2  # 使用工具通过 inode 值扫描(一般“根”目录的 inode 都是 2)
<=====================================================================================>
Inode 2 is directory "".
Directory block 835:
          .-- File type in dir_entry (r=regular file, d=directory, l=symlink)
          |          .-- D: Deleted ; R: Reallocated
Indx Next |  Inode   | Deletion time                        Mode        File name
==========+==========+----------------data-from-inode------+-----------+=========
   0    1 d       2                                         drwxr-xr-x  .
   1  end d       2                                         drwxr-xr-x  ..
   2    5 d      11  D 1399471894 Wed May  7 22:11:34 2014  drwx------  lost+found
   3  end d   24577  D 1399471894 Wed May  7 22:11:34 2014  drwxr-xr-x  share
   4  end r      13  D 1399471894 Wed May  7 22:11:34 2014  rrw-r--r--  file1.txt

<=====================================================================================>
# 这里扫描到了我们删除的东西,有字母 D 标识的表示已经删除
# 接下来我们在扫描一下 /data/ 目录下的 share 目录
[root@localhost tmp]# ext3grep /dev/my_vg/my_lv --ls --inode 24577
<=====================================================================================>
Inode 24577 is directory "share".
Directory block 112640:
          .-- File type in dir_entry (r=regular file, d=directory, l=symlink)
          |          .-- D: Deleted ; R: Reallocated
Indx Next |  Inode   | Deletion time                        Mode        File name
==========+==========+----------------data-from-inode------+-----------+=========
   0    1 d   24577  D 1399471894 Wed May  7 22:11:34 2014  drwxr-xr-x  .
   1    2 d       2                                         drwxr-xr-x  ..
   2  end r   24578  D 1399471894 Wed May  7 22:11:34 2014  rrw-r--r--  file2.txt

<=====================================================================================>
# 这里也扫描到了被删除的文件
# 现在我们只恢复 /data/share/file2.txt
[root@localhost tmp]# ext3grep /dev/my_vg/my_lv --restore-inode 24578
# 恢复回在当前目录下的 RESTORED_FILES/ 目录下,文件以 inode.文件 i 节点号命名
[root@localhost tmp]# cat RESTORED_FILES/inode.24578
&&&&&&&&&&&&&&&&&&&&&&&&&&&
# 我们可以看到文件内容没有改变,所以  文件恢复成功!
# 接下来 我们恢复被删除的全部内容
[root@localhost tmp]# ext3grep /dev/my_vg/my_lv --restore-all
[root@localhost tmp]# ls RESTORED_FILES/
file1.txt  inode.24578  lost+found  share
[root@localhost tmp]# ls RESTORED_FILES/share/
file2.txt
# 成功 ! 接下来就是修改权限,然后将他们移回原位!

文件系统: ext4
使用工具: extundelete
[root@localhost ~]# mkfs.ext4 /dev/my_vg/my_lv
[root@localhost ~]# mount /dev/my_vg/my_lv /data/
[root@localhost ~]# cd /data/
[root@localhost data]# mkdir public
[root@localhost data]# echo "ooooooooooooooooooooo" > file1.txt
[root@localhost data]# echo "mmmmmmmmmmmmmmmmmmmmm" > public/file2.txt
[root@localhost data]# rm -rf *
[root@localhost data]# cd /tmp/
[root@localhost tmp]# umount /data/
[root@localhost tmp]# extundelete /dev/my_vg/my_lv --inode 2
<=====================================================================================>
File name                                       | Inode number | Deleted status
.                                                 2
..                                                2
lost+found                                        11             Deleted
public                                            131073         Deleted
file1.txt                                         12             Deleted

<=====================================================================================>


###########   说实话 , 这里我遇到麻烦了 !!!



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值