zoukankan      html  css  js  c++  java
  • 使用 ext3grep 恢复数据试验成功 笔记

    使用 ext3grep 恢复数据试验成功 笔记
     
    来源:  Linux论坛  日期: 2009.07.07 10:03 (共有条评论)  我要评论
     
    # software download address : [url]http://code.google.com/p/ext3grep/downloads/list[/url]
    # 1、安装 cd /opt wget [url]http://ext3grep.googlecode.com/files/ext3grep-0.10.1.tar.gz[/url] tar -zxf ext3grep-0.10.1.tar.gz cd ext3grep-0.10.1 ./configure make make install
    # 2、制造分区 mkdir /home/sheng cd /home/sheng dd if=/dev/zero of=file count=102400 mkfs.ext3 file # !!!!按Y继续 mount -o loop /home/sheng/file /mnt/
    # 可以看到已经挂上去了 df -h
    # 写入数据到 /mnt mkdir /mnt/del echo 1 > /mnt/del/1 echo 2 > /mnt/del/2 echo 3 > /mnt/del/3
    # 删除数据 rm -rf /mnt/del
    # 3、开始恢复 # 卸载文件所在的分区 /home/sheng/file umount /home/sheng/file # 查看 df -h
    # 扫描分区 ext3grep /home/sheng/file --ls --inode 2
    - - - - -
    [root@db1 sheng]# ext3grep /home/sheng/file --ls --inode 2 Running ext3grep version 0.10.1 Number of groups: 7 Loading group metadata... done Minimum / maximum journal block: 447 / 4561 Loading journal descriptors... sorting... done The oldest inode block that is still in the journal, appears to be from 12454502                                                                                             09 = Sat Jun 20 06:23:29 2009 Number of descriptors in journal: 17; min / max sequence numbers: 2 / 3 Inode is Allocated Finding all blocks that might be directories. D: block containing directory start, d: block containing more directory entries. Each plus represents a directory start that references the same inode as a direc                                                                                             tory start that we found previously.
    Searching group 0: DDD++ Searching group 1: Searching group 2: Searching group 3: Searching group 4: Searching group 5: Searching group 6: Writing analysis so far to 'file.ext3grep.stage1'. Delete that file if you want                                                                                              to do this stage again. Result of stage one:   3 inodes are referenced by one or more directory blocks, 2 of those inodes are                                                                                              still allocated.   1 inodes are referenced by more than one directory block, 1 of those inodes is                                                                                              still allocated.   0 blocks contain an extended directory. Result of stage two:   2 of those inodes could be resolved because they are still allocated. All directory inodes are accounted for!
    Writing analysis so far to 'file.ext3grep.stage2'. Delete that file if you want                                                                                              to do this stage again. The first block of the directory is 433. Inode 2 is directory "". Directory block 433:           .-- File type in dir_entry (r=regular file, d=directory, l=symlink)           |          .-- D: Deleted ; R: Reallocated Indx Next |  Inode   | Deletion time                        Mode        File nam                                                                                             e ==========+==========+----------------data-from-inode------+-----------+========                                                                                             =    0    1 d       2                                         drwxr-xr-x  .    1    2 d       2                                         drwxr-xr-x  ..    2  end d      11                                         drwx------  lost+fou                                                                                             nd    3  end d    5497  D 1245450214 Sat Jun 20 06:23:34 2009  drwxr-xr-x  del [root@db1 sheng]#
    - - - - -
    # 查询 ext3grep /home/sheng/file --ls --inode 2
    # 恢复单个 仅目录 里面的文件恢复失败 .. ext3grep /home/sheng/file --restore-file del --depth del
    # 恢复目录里面的一个文件 ext3grep /home/sheng/file --restore-file del/1
    # 恢复所有文件 ext3grep /home/sheng/file --restore-all

     点击下载软件:ext3grep
    1. 查看所需的相关库
    [root@ns2 ~]# rpm -qa |grep e2fsprogs
    e2fsprogs-libs-1.39-8.el5
    e2fsprogs-1.39-8.el5
    e2fsprogs-devel-1.39-8.el5

    注:RHEL4下没有libs程序,但依然可以安装ext3grep 0.7.0 必须要有e2fsprogs-libs,不然在后面ext3grep的安装会有问题。
    2.查看一下分区情况: [root@ns2 ~]# df –h

    3. 需要软件 http://code.google.com/p/ext3grep/downloads/list 先下载软件 [root@ns2 ~]# cd /root/src/ [root@ns2 src]#  wget  http://ext3grep.googlecode.com/files/ext3grep-0.6.0.tar.gz  src 注:作者已下载过不再下载
    4.安装ext3grep A.先挂载光盘

    B.安装步骤:  1.[root@ns2 ~]# tar zxvf ext3grep-0[1].10.1.tar.gz  –C  /usr/src  <将文件解压到/usr/src目录下> 2.[root@ns2 ~]# cd /usr/src/ext3grep-0.10.1 ->  <进入目录中> 3.[root@ns2 ~]#  ./configure      <配置> 4.[root@ns2 ~]# make && make install  <编译并安装>

    5.为方便实验,我们可以模拟一个出来,下面是模拟步骤: a.      #  mkdir  /data/ b.      #  cd /data/ c.      #  dd  if=/dev/zero  of=disk1  count=2048000 d.      #  mkfs.ext3  disk1 e.      #  mkdir  -p  /dfs/a f.       #  mount  -o  loop  /data/disk1  /asd/a

    如图,已建立一个模拟分区/data/disk1
    6./asd/a下新建文件beijing shanghai
    7.后将beijingshanghai 文件删除

    8. 文件没有了然后我们来恢复: 首先必须umount掉误删除数据的分区: [root@ns2 ~]# umount /data/disk1 [root@ns2 ~]# df –h

    9. 确认卸载,然后使用ext3grep来恢复。 [root@ns2 ~]# ext3grep  /data/disk1  --ls  --inode 2 这里会创建扫描分区

    从图中可以看到被删除的beijing,shanghai两个文件
    10.恢复数据 [root@ns2 ~]# ext3grep  /data/disk1 --restore-file  shanghai
    数据成功恢复 [root@ns2 ~]# ext3grep  /data/disk1 --restore-file  Beijing
    11.[root@ns2 ~]# ls -la RESTORED_FILES/

    注:被恢复的数据默认恢复到RESTORED_FILES/目录下
    12.在RESTORED_FILES下的成功恢复的文件或目录可以做任意操做,作者将其又放回到了原位置

    注:至此所有操做已做完,如果数据在其他分区中,同样卸载误删除数据的分区,执行和以上操作相同的恢复步骤!

  • 相关阅读:
    oracle 10g正则表达式REGEXP_LIKE用法
    impdp时出现ORA-39125错误的解决方法
    使用rman恢复备份集到不同的主机上
    ORA-01110: data file 1: '/opt/ora10g/oradata/orcla/system01.dbf'错误
    Oracle模拟文件损坏BBED
    RMAN进行基于数据块的恢复
    转:Java中Image的水平翻转、缩放与自由旋转操作
    hue耗流量优化
    解决hue/hiveserver2对于hive date类型显示为NULL的问题
    解决kylin sync table报错:MetaException(message:java.lang.ClassNotFoundException Class org.apache.hive.hcatalog.data.JsonSerDe not found
  • 原文地址:https://www.cnblogs.com/timssd/p/4406728.html
Copyright © 2011-2022 走看看