ubuntu恢复被rm误删的数据及原理
昨天一不小心,执行了rm xx -rf,把一个项目删除了。然后就是各种悔恨,各种自责,这个项目可是一周的工作量啊。最后肯定得解决,于是google搜索发现了恢复神器extundelete,最后顺利恢复了所有被我无意中的删除的文件。感谢上天,感谢extundelete。下面将个人的经历总结下。
如何使用extundelete
- sudo apt-get install extundelete
2) 使用
使用这个也很简单。使用extundelete–help命令,可以告诉我们很多。
- Itleaks@ Itleaks::~$ extundelete --help
- Usage: extundelete [options] [--] device-file
- Options:
- ……………….
- --after dtime Only process entries deleted on or after 'dtime'.
- --before dtime Only process entries deleted before 'dtime'.
- Actions:
- …………
- --restore-file 'path' Will restore file 'path'. 'path' is relative to root
- of the partition and does not start with a '/' (it
- must be one of the paths returned by --dump-names).
- The restored file is created in the current
- directory as 'RECOVERED_FILES/path'.
- --restore-files 'path' Will restore files which are listed in the file 'path'.
- Each filename should be in the same format as an option
- to --restore-file, and there should be one per line.
- --output-dir 'path' Restore files in the output dir 'path'.
- By default the restored files are created under current directory 'RECOVERED_FILES'.
- --restore-all Attempts to restore everything.
- ………..
我们知道当我们不小心删除了有用的文件,我们一般是比较容易知道删除的时间的,因此,使用时间这个option可以很快并且精确的恢复出我们想要的文件。那这个dtime怎么生成。请参考如下命令:
- Itleaks@ Itleaks:~$ date -d "2014-06-01 23:02:00" +%s
- 1401634920
%s的意思是seconds since 1970-01-01 00:00:00 UTC,就是输入时间与1970-01-0100:00:00的时间差
然后就可以使用这个来恢复了
- sudo extundelete /dev/sda8 --after 1401634920--restore-all
现在我们来做个试验:具体操作如下
- Itleaks@ Itleaks:/tmp$ echo "recovery test"> itleaks.test
- Itleaks@ Itleaks:/tmp$ rm itleaks.test
- Itleaks@ Itleaks:/tmp$ date -d "2014-06-01 22:28:00" +%s
- 1401632880
- Itleaks@ Itleaks:/tmp$ sudo extundelete /dev/sda8 --after 1401632880 --restore-all
- Only show and process deleted entries if they are deleted on or after 1401632880 and before 9223372036854775807.
- WARNING: Extended attributes are not restored.
- WARNING: EXT3_FEATURE_INCOMPAT_RECOVER is set.
- The partition should be unmounted to undelete any files without further data loss.
- If the partition is not currently mounted, this message indicates
- it was improperly unmounted, and you should run fsck before continuing.
- If you decide to continue, extundelete may overwrite some of the deleted
- files and make recovering those files impossible. You should unmount the
- file system and check it with fsck before using extundelete.
- Would you like to continue? (y/n)
- y
- Loading filesystem metadata ... 378 groups loaded.
- Loading journal descriptors ...
- 27106 descriptors loaded.
- Searching for recoverable inodes in directory / ...
- 85 recoverable inodes found.
- Looking through the directory structure for deleted files ...
- ………………..
- Unable to restore inode 2360218 (etc/brltty/brl-fs-bumpers.kti): No undeleted copies found in the journal.
- Unable to restore inode 2359564 (etc/mtab~): No undeleted copies found in the journal.
- Restored inode 2883641 to file RECOVERED_FILES/tmp/itleaks.test
- Itleaks@ Itleaks:/tmp$ tree RECOVERED_FILES/
- RECOVERED_FILES/
- └── tmp
- └── itleaks.test
- 1 directory, 1 file
extundelete原理
这个是由于linuxext3文件系统的组织结构决定的,如下图:
在Linux系统中,超级块描述了分区的信息,一个分区被分为两个部分,索引节点表和数据块区,这个在格式化的时候就定下来了。文件(目录也是文件的一种,只不过它的内容是描述目录下的文件的)由索引节点描述,索引节点描述了文件的修改时间,文件的名称,文件的数据块地址等等。并且,linux对于文件删除操作是个懒动作,删除文件时系统只是将文件对应的索引节点及其拥有的数据块置为free(将nlink=0),而并没有做其他清空的,只有当这个索引节点或者数据块被真正用到的时候才会修改里面的数据。这就为我们文件修复提供了可趁之机。由于系统中的索引节点是固定大小的,因此可以很轻松的遍历扫描系统中所有的索引节点,找出free的索引节点并检查其数据块是否已经被用,如果没有则可修复并修复。同时,由于索引节点里的时间等信息也是保留的,因此就可以根据时间来恢复特定的被删除的文件。
文件误删除后的注意事项
从上面的分析可知,误删文件后,尽量不要做大的数据操作,以避免被删除的文件的数据块被重新使用,导致数据完全丢失。
/********************************
* 本文来自博客 “爱踢门”
* 转载请标明出处:http://blog.csdn.net/itleaks
******************************************/
ubuntu恢复被rm误删的数据及原理相关推荐
- 恢复被rm意外删除数据文件
恢复被rm意外删除数据文件 ======================== 对于rm,很多人都有惨痛的教训.我也遇到一次,一下午写的程序就被rm掉了,幸好只是一个文件,第二天很快又重新写了一遍.但是 ...
- 如何恢复苹果笔记本电脑误删的数据?
电脑作为日常办公的工具,很多人操作使用都很熟练.但是这主要是针对Windows系统,如今使用Mac系统的也越来越多,许多用户刚从Windows系统切换到Mac系统,由于对Mac系统了解不够,经常出现误 ...
- linux还原环境,Linux环境利用恢复被rm意外删除数据文件
Linux环境下不小心在操作系统误rm删除数据文件后,在没有重启数据库或者操作系统的情况下可以利用操作系统句柄恢复.[@more@]1.数据库版本信息: SQL> select * from v ...
- 怎样恢复win10分区误删的数据
盘符丢失是比较常见的数据恢复案例,需要注意,盘符丢失后不要再重建新的分区.保护好文件丢失现场,可以最大程度的恢复出文件.具体的恢复方法看正文了解. 工具/软件:星空数据恢复软件 步骤1:先百度搜索并下 ...
- oracle delete原理,如何恢复并理解oracle删除数据的原理
对于误DROP表的情况,也可以直接用闪回方法恢复数据(要保证被删除数据的块没被覆写).由于oracle在删除表时,没有直接清空表所占的块,oracle把这些已删除的表的信息放到了一个虚拟容器" ...
- 恢复rm -rf 的数据
目录[-] 一. 将磁盘分区挂载为只读二. 使用数据恢复工具 extundelete1. 下载2. 编译三. 挂载新硬盘1 在xen上挂载一块磁盘给B2 登录服务器B, 准备挂载新磁盘.四.通 ...
- Linux 平台下 误删 oracle 数据文件的恢复方法
1 问题描述 之前写过一篇删除oracle home目录的blog,参考: Linux 平台误删 home oracle 根目录的解决方法 http://www.cndba.cn/Dave/arti ...
- ubuntu下使用extundelete恢复使用rm删除的文件
ubuntu下使用extundelete恢复使用rm删除的文件 一.原因 我这次文件误删主要是因为,在写Makefile文件时,没有考虑周全,在执行make clean时删除了源文件,总之虚惊一场.庆 ...
- Linux中如何恢复被误删的数据文件
Linux环境中文件被删除的恢复,通常有几种情况,如果数据库实例还未停止,那么恢复很easy,如果实例停掉, 那么可能需要借助相关的工具来进行恢复,这里我进行简单的描述. 1. 使用工具进行恢复(ex ...
最新文章
- JS计算两个时间相差多久,相差年,月,日,小时,分钟
- bootstrap与Select2使用小结
- 2020年女人体重表,看看你是不是标准的模特体重
- win7计算机内存占用高,WIN7系统电脑内存占用高的解决办法有哪些
- 1059 Prime Factors
- lncrna研究,2021最新相关资料合集
- 多任务学习漫谈:分主次之序
- 使用jMeter构造逻辑上有依赖关系的一系列并发请求
- Mac OS使用技巧十八:Safari碉堡功能之一制作Widget
- android setimageresource取list的,Java ImageView.setImageTintList方法代码示例
- sql server 性能分析工具
- Java中如何使用匿名内部类?
- 【5分钟 Paper】Deterministic Policy Gradient Algorithms
- Python 中Python 为什么要继承 object 类
- windows系统维护工具箱
- Snipaste安装教程及软件(截图工具)
- IDEA kotlin项目报错 kotlin not configured
- Apache Shiro 1.2.4 反序列化漏洞(CVE-2016-4437 )
- 【转】那些年搞不懂的高深术语——依赖倒置•控制反转•依赖注入•面向接口编程
- 免费又好用的Windows任务栏透明化工具——Translucent TB
热门文章
- 十一假期,分享几个好玩儿的GitHub项目
- html中写页边距,html整体页面边距怎么设置
- 逼自己养成成长型思维模式
- Java基础知识(一) 基本概念
- DOSBox使用总结——调整DOSBox窗口并自动挂载指定目录
- Kylin RT OLAP reassign流程即重新分配replica_set 流程
- 商标注册计算机软件app属于第几类,软件商标属于第几类?
- OpenHarmony 简介:使用鸿蒙操作系统,开发者能做的是啥呢,学习NodJS,可以开发应用了。后续慢慢学习,赶紧去加星星。
- 输入一个数,分别输出个位,十位,百位
- 安卓实战:自定义软键盘 (2)