zoukankan      html  css  js  c++  java
  • fm rf 删除 恢复

    谷歌了一把发现了神器 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

    1
    2
    3
    4
    [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* 安装

    二、执行删除操作

    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    [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.卸载需要恢复文件的分区

    1
    2
    [root@www ~]# fuser -k /mnt/test/               <-- 结束使用某分区的进程树
    [root@www ~]# umount /mnt/test                  <-- 卸载分区

        2.使用extundelete查看分区上存在的文件

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

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

    01
    02
    03
    04
    05
    06
    07
    08
    09
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    [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.skyelek.com skyelek.com
    nameserver 192.168.1.200
  • 相关阅读:
    线程池-java高并发编程详解第八章记录
    类加载过程-《java高并发编程详解》第九章 重点记录
    Actuator Elasticsearch healthcheck error
    【译】优雅的停止docker容器
    spring cloud之Eureka不能注销docker部署的实例
    spring cloud之Eureka
    spring cloud之docker微服务客户端注册eureka问题
    spring cloud consul上下线体验
    [Kerberos] Kerberos教程(二)
    [Kerberos] Kerberos教程(一)
  • 原文地址:https://www.cnblogs.com/yinjian/p/2681047.html
Copyright © 2011-2022 走看看