[文章作者:张宴 本文版本:v1.0 最后修改:2009.07.06 转载请注明原文链接:http://blog.zyan.cc/linux_ext3_undelete/]

  环境:CentOS 5.3 x86_64下,/dev/sdb1为数据分区/data0,EXT3文件系统。
  前因:误删了/data0/tcsql/cankao/phpcws-1.5.0/httpcws.cpp文件。由于忘了备份httpcws.cpp文件,重新开发工作量较大,因此只有恢复该文件一条路可走。

  debugfs命令针对EXT2分区还行,但对EXT3分区就帮不上忙了。偶然发现的一款开源软件,解决了我的大忙。该软件下载网址为:
  http://code.google.com/p/ext3grep/

  1、先安装ext3grep软件:
wget http://ext3grep.googlecode.com/files/ext3grep-0.10.1.tar.gz
tar zxvf ext3grep-0.10.1.tar.gz
cd ext3grep-0.10.1
./configure
make
make install


  2、umount /data0分区:
umount /data0

  如果提示busy,先kill正在使用这个目录的进程,再umount:
fuser -k /data0
umount /data0


  3、查询所有Inode,(执行需要几分钟~十多分钟):
ext3grep /dev/sdb1 --ls --inode 2

  点击在新窗口中浏览此图片

  4、逐级查找Inode,看是否能找到httpcws.cpp文件(此步骤也可省略):

  点击在新窗口中浏览此图片

  点击在新窗口中浏览此图片

  5、恢复/data0/tcsql/cankao/phpcws-1.5.0/httpcws.cpp文件:
ext3grep /dev/sdb1 --restore-file tcsql/cankao/phpcws-1.5.0/httpcws.cpp

  点击在新窗口中浏览此图片

  如果提示以下信息,则表示恢复成功:
  Restoring tcsql/cankao/phpcws-1.5.0/httpcws.cpp

  这时,执行ext3grep命令的当前目录下将会自动生成一个名为RESTORED_FILES的文件夹,文件夹下的tcsql/cankao/phpcws-1.5.0/httpcws.cpp即为恢复的文件。查看了一下,和被删除前的内容一样,大功告成。


  6、重新mount /data0分区:
mount /dev/sdb1 /data0


  参考资料:http://www.xs4all.nl/~carlo17/howto/undelete_ext3.html




技术大类 » 其他Unix技术 | 评论(53) | 引用(0) | 阅读(84297)
xiaoyao3857
2013-1-22 16:33
啊,知道了杀掉占用目录的方法,kill正在使用这个目录的进程;fuser -k 分区
海阔天空 Homepage
2013-5-13 19:03
海阔天空俏佳人娱乐会所15026982229 小姐服务24小时出差旅游大学生兼职按摩小姐上门,处女开红,兼职空姐,,白俄罗斯小姐,兼职模特,性感少妇全国连锁,就近提供北京、上海、广州等地姐兼职美女上门保健按摩北京小姐上门,上海兼职美眉,广州美女上门保健按摩,西安女大学生兼职,重庆空姐兼职,杭州酒店宾馆美女,温州兼职美女,南京白领兼职,全国本地找小姐上门按摩,模特私拍,援助交际更多请进 www.lvcai.org 查看
acgw
2014-7-31 10:17
thank you so much!
Steven Email Homepage
2015-3-19 02:50
Thank you for this post Weight Loss Tea
roodje Email Homepage
2015-3-20 22:41
Thank you for sharing this post with us asphalt 8 cheats
Graciela H. Brush Email
2019-6-7 21:08
This is really a wonderful code i would say. Extremely good enough to make some good kind of projects following those steps. I would like to include this script on my https://www.australian-writings.org/ blogs and would like to check how to proceed.
fnaf world Email Homepage
2019-7-1 12:23
It's great to have the opportunity to read a good quality article with useful information on topics of interest. I agree with your conclusionfnaf world
Ann R. Lachance Email
2020-4-8 17:23
The educational programs offered by Certus Trading Reviews include courses on stocks and bonds, as well as options and commodities trading. Founder Matt Choi is a Chartered Market Technician with 17 years experience as a trader.
Modi Email
2022-2-12 19:24
koxov Email Homepage
2022-2-12 19:25
Raaj Email
2022-2-23 21:48
Buy a best quality fitness band and start tracking your fitness band with the best fitness band under 2000
write for us development
2022-4-22 17:51
Get a nice quilty development site which gives chance to the new developer for write for us development its nice thing to become popular and get more advance in this field.
分页: 3/3 第一页 上页 1 2 3 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]