PS:补充下,我在fedora 19上运行的时候遇到的一个问题:

 [root@localhost extundelete-0.2.]# ./configure
Configuring extundelete 0.2.
configure: error: in `/usr/local/src/extundelete-0.2.':
configure: error: C++ compiler cannot create executables
See `config.log' for more details

查看了下config.log文件发现与gcc-c++有关。所以运行yum -y install gcc-c++这个库后问题解决

 总计                                             kB/s | 8.2 MB     :
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : libstdc++-devel-4.8.-.fc19.i686 /
正在安装 : gcc-c++-4.8.-.fc19.i686 /
验证中 : libstdc++-devel-4.8.-.fc19.i686 /
验证中 : gcc-c++-4.8.-.fc19.i686 / 已安装:
gcc-c++.i686 :4.8.-.fc19 作为依赖被安装:
libstdc++-devel.i686 :4.8.-.fc19 完毕!
[root@localhost extundelete-0.2.]# ./configure
Configuring extundelete 0.2.
Writing generated files to disk
[root@localhost extundelete-0.2.]# yum install gcc-c++

首先。Linux下很多人都喜欢用rm -rf去删除目录。但是rm --help提示这是一个非常危险的命令、谨慎用之。

这里公司一台服务器。同事在操作的过程中误删掉一个目录。而且是非常重要的。

尝试恢复cat /etc/redhat-release 查看为rhel4版本。很老了这就有一个问题出现yum无法用。

先用一个ext3grep 工具恢复。但是该工具--help 提示没有针对目录恢复的参数 只有一个all 我尝试用时间戳恢复当时时间段的数据效果不理想、

而且跟要命的是当我查看分区的时候df -aT发现这个删除的目录进入奇迹般的划分在了与/一个分区。0 0这意味着我挂载为只读分区时要杀掉一

切与/根分区有关的进程;所有反复思索后决定一个好的办法:

USB移动硬盘安装一个便携Linux系统,并在其上面安装extundelete工具因为这个工具需要几个包的支持。而rhel4的系统现在yum已经无法使用

安装支持包都很困难。索性放弃。

关于USB移动硬盘系统。与我们用的stat 硬盘安装系统一样。可以用光盘镜像安装选择USB设备为安装设备。或者用虚拟机安装都可以。这里我就

不多说推荐虚拟机Virtual BoxVMware(优点是你有镜像但无法刻盘)。

好了进入centOS6.4后

下载extundelete:wget http://pkgs.fedoraproject.org/repo/pkgs/extundelete/extundelete-0.2.4.tar.bz2/77e626ad31433680c0a222069295d2ca/extundelete-0.2.4.tar.bz2

 [root@vbok src]# wget http://pkgs.fedoraproject.org/repo/pkgs/extundelete/extundelete-0.2.4.tar.bz2/77e626ad31433680c0a222069295d2ca/extundelete-0.2.4.tar.bz2
 [root@vbok src]# tar jxvf extundelete-0.2..tar.bz2

直接./configure make make install 但我运行./configure时报错:

 [root@vbok src]# cd extundelete-0.2.
[root@vbok extundelete-0.2.]# ./configure
Configuring extundelete 0.2.
configure: error: Can't find ext2fs library

提示 ext2fs library 少几个包的支持

 [root@vbok extundelete-0.2.]# yum -y install ext2fs

OK 在运行make三部曲

[root@vbok extundelete-0.2.]# ./configure
Configuring extundelete 0.2.
Writing generated files to disk

当然如果你make完后就可以使用这个工具的

 [root@vbok extundelete-0.2.]# make
make -s all-recursive
Making all in src
extundelete.cc:: 警告:未使用的参数‘flags’

直接在~/src/extundelete --help

[root@vbok extundelete-0.2.]# src/extundelete --help

或者在运行 make install 这时会安装到/usr/local/bin/extundelete 下

我还是推荐make完就成了。因为假如你要恢复的目录正好是/usr 那你就还需要在./configure下加参数。浪费时间效果一样

OK来演示下恢复吧

 [root@vbok /]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/vg_vbok-gen
25G 541M 23G % /
tmpfs 943M 232K 943M % /dev/shm
/dev/sdb1 485M 36M 424M % /boot
/dev/mapper/vg_vbok-home
20G 172M 19G % /home
/dev/mapper/vg_vbok-opt
11G 156M .9G % /opt
/dev/mapper/vg_vbok-usr
39G .2G 34G % /usr
/dev/sdb3 51G 16K 51G % /vfat

我在/opt下创建了个目录 “1“ 下面有多个子目录和文件。然后我将其删除。

(看看现在的时间)并回到extundelete 安装目录下将opt目录挂载为只读为了保护数据防止重写。

 root@vbok /]# cd opt/
[root@vbok opt]# ls
lost+found rh
[root@vbok opt]# date
2013年 10月 14日 星期一 :: CST
[root@vbok opt]# rm -rf
[root@vbok opt]# ls
lost+found rh
[root@vbok opt]# cd /usr/local/src/extundelete-0.2.
[root@vbok extundelete-0.2.]# mount -o remount,ro /dev/mapper/vg_vbok-opt

这里说下我要用到的参数 src/extundelete --help

 --restore-directory 'path'
Will restore directory 'path'. 'path' is relative to the
--restore-all Attempts to restore everything.
--after dtime Only process entries deleted on or after 'dtime'.
--before dtime Only process entries deleted before 'dtime'.

第一个是 恢复目录 path为路径后面跟要恢复那个目录的路径

第二个是 恢复所有

第三个是 恢复dtime这个时间戳以后删除的文件

第四个是恢复这个时间戳以前删除的文件  (这里说下,卡时间恢复是非常好用的参数。你可以指定恢复那个时间到那个时间之间的数据)

基本这几个选项就够恢复了,当然还有--restore-files 参数来恢复单个文件。

OK开始

我上面在删除的时间date了下系统时间所以我就来生成下 删除前和删除后的时间戳用来定位我要恢复的目录,然后利用工具恢复删除的目录

[root@vbok extundelete-0.2.]# date -d "2013-10-14 16:43" +%s

[root@vbok extundelete-0.2.]# date -d "2013-10-14 16:58" +%s  

[root@vbok extundelete-0.2.]# src/extundelete /dev/mapper/vg_vbok-opt --after / --before  --restore-directory 

OK恢复完成,这里要注意的是在用恢复目录选项的时候,后面接的目录是以opt后的目录。也就是说 /dev/mapper/vg-vbox-opt 已经代表了/opt这个目录我们只需要接着写 opt后面的目录 例如要恢复/opt/1/2/3 这个目录 我们后面的路径为 1/2/3 就可以恢复3这个目录了 当然有时间戳指定时间段后就可以用--restore-all恢复这个时间段删除的所有数据了。OK

 NOTICE: Extended attributes are not restored.
Loading filesystem metadata ... groups loaded.
Loading journal descriptors ... descriptors loaded.
Searching for recoverable inodes in directory ...
recoverable inodes found.
Looking through the directory structure for deleted files ...
recoverable inodes still lost.
[root@vbok extundelete-0.2.]# cd RECOVERED_FILES/
[root@vbok RECOVERED_FILES]# LS
-bash: LS: command not found
[root@vbok RECOVERED_FILES]# ls [root@vbok RECOVERED_FILES]# cd
[root@vbok ]# ls [root@vbok ]# cd /
[root@vbok ]# ls
a
[root@vbok ]# cd ..//c
-bash: cd: ..//c: 不是目录
[root@vbok ]# cd ..//c

数据 完好无损。

在讲/opt这个分区挂载回读写的,不会的可以reboot重启下也可以

centOS6.4 extundelete工具恢复rm -rf 删除的目录的更多相关文章

  1. centOS6.4 extundelete工具恢复rm -rf 删除的目录[转]

    原文:http://www.cnblogs.com/patf/p/3368765.html PS:补充下,我在fedora 19上运行的时候遇到的一个问题: 1 [root@localhost ext ...

  2. 高性能Linux服务器 第6章 ext3文件系统反删除利器ext3grep extundelete工具恢复rm -rf 误删除的文件

    高性能Linux服务器 第6章  ext3文件系统反删除利器ext3grep  extundelete工具恢复rm -rf 误删除的文件 只能用于ext3文件系统!!!!!!!高俊峰(高性能Linux ...

  3. 用extundelete恢复rm -rf删的文件

    “慎用rm -rf命令,除非你知道此命令带来的后果.”这是一条Linux用户守则,虽然大多数用户都明白这条语句的含义,但是我觉得还需要完善一下,为这条语句加 上一个使用前提:在你确认自己拥有清醒头脑, ...

  4. Linux下面误删除文件使用extundelete工具恢复介绍

    操作系统版本:CentOS release 6.4 (Final)      软件版本:extundelete-0.2.4.tar.bz2 PS:该软件恢复文件系统仅支持ext2/ext3/ext4 ...

  5. ubuntu恢复rm -rf误删文件

    使用extundelete工具 sudo apt-get install extundelete 恢复操作命令 首先需要umount或者read only 分区  umount /dev/partit ...

  6. 使用 rm -rf 删除了工程目录,然后从 pycharm 中找了回来

    一次惊险的 rm -rf 操作,以后删东西真的要小心,慢点操作 前两天周 4 周 5,写了两天的 python 代码没有提交,昨天晚上删日志目录,先跨目录查看了下日志目录的列表情况:ll ~/logs ...

  7. [linux] rm -rf删除软链接无权限?

    一个很简单的命令,使用频率非常高,但一没注意就会失策. 我将别人盘下的list目录软连接到自己盘中,想要删除时: rm -rf list/ #输入时自然地用tab键补全 结果: 试了多次也删除不了,最 ...

  8. rm -rf删除过多文件提示参数过长

    cd /var/tmp/ find . -name "*.log"|xargs rm -rf "*.log"

  9. CentOS 恢复 rm -rf * 误删数据(转)

    一. 将磁盘分区挂载为只读 这一步很重要,并且在误删除文件后应尽快将磁盘挂载为只读.越早进行,恢复的成功机率就越大. 1.  查看被删除文件位于哪个分区 [root@localhost  ~]# mo ...

随机推荐

  1. LeetCode:Remove Duplicates from Sorted Array I II

    LeetCode:Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place su ...

  2. Linux(9.28-10.4)学习笔记

    三种数字表示 无符号数: 基于传统的二进制表示法,表示大于或者等于零的数字. 补码(有符号数): 表示有符号数整数的最常见的方式,有符号数就是只可 以为正或者为负的数. 浮点数: 表示实数的科学计数法 ...

  3. Linux第13周学习笔记

    网络编程 客户端-服务器编程模型 每个网络应用都是基于客户端-服务器模型. 一个应用是由一个服务器进程和一个或者多个客户端进程组成. 服务器管理某种资源,并通过操作资源来为客户端提供某种服务. 基本操 ...

  4. .tostring()格式化大全

    C 货币 2.5.ToString("C") ¥2.50 D 十进制数 25.ToString("D5") 00025 E 科学型 25000.ToString ...

  5. Android Studio配置Git及Git文件状态说明

    Android Studio配置Git还是比较简单的,麻烦的是可能中间出现各种问题.如果你想了解或感兴趣,请往下看. 首先你得下载Git客户端,网址:http://git-scm.com/downlo ...

  6. 变量监控 指令 gt-wach

    index8.html <html><head> <title>变量监控指令 gt-watch</title> <script src=" ...

  7. Library not found for -lPods 解决方法

    使用cocoapods 经常会遇到的问题. 1. Library not found for -lPods 2. Pods was rejected as an implicit dependency ...

  8. 关于python中PIL的安装

    python 的PIL安装是一件很蛋痛的事, 如果你要在python 中使用图型程序那怕只是将个图片从二进制流中存盘(例如使用Scrapy 爬网存图),那么都会使用到 PIL 这库,而这个库是出名的难 ...

  9. CNN 手写数字识别

    1. 知识点准备 在了解 CNN 网络神经之前有两个概念要理解,第一是二维图像上卷积的概念,第二是 pooling 的概念. a. 卷积 关于卷积的概念和细节可以参考这里,卷积运算有两个非常重要特性, ...

  10. WCF 入门 (21)

    前言 再不写一篇就太监了,哈哈. 第21集 WCF里面的Binding Bindings in WCF 其实不太了解为什么第21集才讲这个Binding,下面都是一些概念性的东西,不过作为一个入门视频 ...