centOS6.4 extundelete工具恢复rm -rf 删除的目录
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 Box和VMware(优点是你有镜像但无法刻盘)。
好了进入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 删除的目录的更多相关文章
- centOS6.4 extundelete工具恢复rm -rf 删除的目录[转]
原文:http://www.cnblogs.com/patf/p/3368765.html PS:补充下,我在fedora 19上运行的时候遇到的一个问题: 1 [root@localhost ext ...
- 高性能Linux服务器 第6章 ext3文件系统反删除利器ext3grep extundelete工具恢复rm -rf 误删除的文件
高性能Linux服务器 第6章 ext3文件系统反删除利器ext3grep extundelete工具恢复rm -rf 误删除的文件 只能用于ext3文件系统!!!!!!!高俊峰(高性能Linux ...
- 用extundelete恢复rm -rf删的文件
“慎用rm -rf命令,除非你知道此命令带来的后果.”这是一条Linux用户守则,虽然大多数用户都明白这条语句的含义,但是我觉得还需要完善一下,为这条语句加 上一个使用前提:在你确认自己拥有清醒头脑, ...
- Linux下面误删除文件使用extundelete工具恢复介绍
操作系统版本:CentOS release 6.4 (Final) 软件版本:extundelete-0.2.4.tar.bz2 PS:该软件恢复文件系统仅支持ext2/ext3/ext4 ...
- ubuntu恢复rm -rf误删文件
使用extundelete工具 sudo apt-get install extundelete 恢复操作命令 首先需要umount或者read only 分区 umount /dev/partit ...
- 使用 rm -rf 删除了工程目录,然后从 pycharm 中找了回来
一次惊险的 rm -rf 操作,以后删东西真的要小心,慢点操作 前两天周 4 周 5,写了两天的 python 代码没有提交,昨天晚上删日志目录,先跨目录查看了下日志目录的列表情况:ll ~/logs ...
- [linux] rm -rf删除软链接无权限?
一个很简单的命令,使用频率非常高,但一没注意就会失策. 我将别人盘下的list目录软连接到自己盘中,想要删除时: rm -rf list/ #输入时自然地用tab键补全 结果: 试了多次也删除不了,最 ...
- rm -rf删除过多文件提示参数过长
cd /var/tmp/ find . -name "*.log"|xargs rm -rf "*.log"
- CentOS 恢复 rm -rf * 误删数据(转)
一. 将磁盘分区挂载为只读 这一步很重要,并且在误删除文件后应尽快将磁盘挂载为只读.越早进行,恢复的成功机率就越大. 1. 查看被删除文件位于哪个分区 [root@localhost ~]# mo ...
随机推荐
- 20135316王剑桥 linux第十周课实验笔记
关于who 功能说明:显示目前登入系统的用户信息. 语 法:who [-Himqsw][--help][--version][am i][记录文件] 补充说明:执行这项指令可得知目前有那些用户登入系统 ...
- 你应当如何学习C++(以及编程)(转载)
你应当如何学习C++(以及编程)(rev#1) By 刘未鹏(pongba) C++的罗浮宫(http://blog.csdn.net/pongba) Javascript是世界上最受误解的语言,其实 ...
- 微信第一个“小程序”亮相:不是APP胜似APP!
前天晚上,微信终于推出了“小程序”功能.看过效果演示之后,网友表示,好多App可以卸载了! 据了解,微信“小程序”已首批开放给200名拥有微信服务号的开发者进行内测,而且目前开发者发布的小程序无法在用 ...
- margin的理解
1.盒子模型 在进行网页设计的时候,我们使用的是盒子模型,其内容如下: 整个网页就是大盒子套小盒子,小盒子又套更小的盒子来实现的.但是在做网页设计时总是搞不清margin和padding的使用方式,在 ...
- 【Javascript】—— 1 方法function的高级特性
本篇仅仅对于function作简单的讲解,在javascript中function不仅仅是方法,它其实是一个变量,因此拥有自己的属性,并且可以当做参数传递给其他的方法. 那么传统的方法,按照java的 ...
- Moqui学习Day3
添加一个新建表单 添加一个按钮来弹出新建表单,并创建一个转换来处理输入数据操作. 在FindTutorial.xml文件中添加一个转换. <!--新增 列表 --> <transit ...
- Win7 下以管理员身份运行批处理文件,切换JDK版本
Win7下 切换JDK的批处理命令 1. 批处理文件(必须以管理员身份执行)内容如下 @echo off rem --- Base Config 配置JDK的安装目录 --- :init set JA ...
- nginx location的配置
文章转自:http://www.ttlsa.com/nginx/nginx-location-configure/ location的语法配置规则: 语法规则: location [=|~|~*|^~ ...
- bootstrap table简洁扁平的表格
使用方法 1.在html页面的head标签中引入Bootstrap库(假如你的项目还没使用)和bootstrap-table.css. <link rel="stylesheet&qu ...
- 【POJ 3020】Antenna Placement(二分图匹配)
相当于用1*2的板覆盖给定的h*w的格子里的点,求最少的板.可以把格子相邻的分成两个集合,如下图,0为一个集合,1的为一个,也就是(行数+列数)为奇数的是一个集合,为偶数的为另一个集合.1010101 ...