reiserfs文件误删的恢复
欲哭无泪,痛定思痛
肠子都悔青了才来研究这些东西。。。
希望大家不要像我这样,一定要:
1。备份
2。不要轻易使用rm命令
3。恢复尽量用文件系统自带的恢复命令而不是恢复软件如testdisk和photorec。testdisk只能恢复误删的分区,而photorec只能恢复特定的80几种格式的文件,连文件名、目录名统统丢失,还有不少错误(如文件类型之类),只能说是下下策。
这可是血的教训阿,大家切记!切记!
下面是我恢复reiserfs分区下误删文件的过程。
因为我有专门一个分区装ubuntu最新测试版的,所以省了不少事情,当然如果你有live cd,那也一样方便。
********************************************
-1。最优先的事项:用dd命令或clonezilla对该分区进行备份,以免恢复失败把原来还在的文件都给删没了。推荐clonezilla。
0。误删文件后,千万千万什么都别干,直接重启机器,进入live cd或其他linux系统。
1。进入非误删文件的系统,,打开终端或直接进控制台。
2。输入
| 代码: |
| sudo umount /dev/xxx |
xxx是你误删文件所在的分区名,一般是sdax或hdax等等。
3。输入
| 代码: |
| sudo reiserfsck –rebuild-tree -S -l undelete.log /dev/xxx |
重建文件系统。提示输入“Yes”,注意Y是大写的,否则不行。也不能直接输入”y”,那根本没用。
4。等待直到一切都结束,你的误删的文件应该回来了,或许有一些丢失或错误。
过程应该是这样的(这个不是我的):
| 代码: |
| reiserfsck 3.6.19 (2003 www.namesys.com) ************************************************************* ** Do not run the program with –rebuild-tree unless ** ** something is broken and MAKE A BACKUP before using it. ** ** If you have bad sectors on a drive it is usually a bad ** ** idea to continue using it. Then you probably should get ** ** a working hard drive, copy the file system from the bad ** ** drive to the good one — dd_rescue is a good tool for ** ** that — and only then run this program. ** ** If you are using the latest reiserfsprogs and it fails ** ** please email bug reports to reiserfs-list@namesys.com, ** ** providing as much information as possible — your ** ** hardware, kernel, patches, settings, all reiserfsck ** ** messages (including version), the reiserfsck logfile, ** ** check the syslog file for any related information. ** ** If you would like advice on using this program, support ** ** is available for $25 at www.namesys.com/support.html. ** ************************************************************* Will rebuild the filesystem (/dev/loop0) tree Will put log info to ‘undelete.log’ Do you want to run this program?[N/Yes] (note need to type Yes if you do): Yes Replaying journal.. |
5。修复完毕,所有恢复记录都在你的undelete.log下。你可以一个一个对照着恢复。接下来就是挂载你开始卸下的分区
| 代码: |
| sudo mount -a |
看到你删掉的文件了么?如果没有,一般就只会在lost+found目录里面,需要root权限才可以进去。奇怪的是用root 不行,只能gksu nautilus进去,当然你也可以把权限改掉。
哈哈,你手快删掉的东西都在吧?如果你在删掉之后还干了一些事情,那么恐怕就不能保证都在了。
*********************************************
好了,这是一个教训,写本文是为了忘却的纪念和备份恢复方法,同时“以儆效尤”。
至于其他文件系统,我想应该也差不多,看看你们文件系统相关操作或搜一下狗狗即可。
后记
因为开始没有想到这么做,做了不少无法挽回的事情,包括把这个区又进行了大量的文件操作,但幸运的是居然还有不少死都不能丢的数据给找回来了,不幸中之大幸。希望大家碰到这种情况时,切莫惊慌,照我说的做就ok了。
Leave a Reply