如何恢复 Linux 上删除的文件 (3)
http://tech.ddvip.com 2008年01月22日 社区交流
内容摘要:恢复系统中删除的文件是一个非常繁琐的过程,而 e2undel 这个工具可以用来方便地恢复文件系统中已删除的文件。本文将首先讨论 e2undel 的工作原理和用法,并对之进行一些改进。然后讨论了文件系统故障、文件系统重建、磁盘物理损坏等情况下应该如何恢复数据。
编译之后会生成一个名为 e2undel 的可执行文件,其用法如下:
清单3. e2undel 的用法
# ./e2undel
./e2undel 0.82
usage: ./e2undel -d device -s path [-a] [-t]
usage: ./e2undel -l
'-d': file system where to look for deleted files
'-s': directory where to save undeleted files
'-a': work on all files, not only on those listed in undel log file
'-t': try to determine type of deleted files w/o names, works only with '-a'
'-l': just give a list of valid files in undel log file
e2undel 实际上并没有像前面介绍的使用 e2fsck 那样的方法一样真正将已经删除的文件恢复到原来的文件系统中,因为它并不会修改磁盘上 ext2 使用的内部数据结构(例如索引节点、块位图和索引节点位图)。相反,它仅仅是将所删除文件的数据恢复出来并将这些数据保存到一个新文件中。因此,-s 参数指定是保存恢复出来的文件的目录,最好是在另外一个文件系统上,否则可能会覆盖磁盘上的原有数据。如果指定了 -t 参数,e2undel 会试图读取文件的前 1KB 数据,并试图从中确定该文件的类型,其原理与系统中的 file 命令非常类似,这些信息可以帮助判断正在恢复的是什么文件。
下面让我们来看一个使用 e2undel 恢复文件系统的实例。
清单4. 使用 e2undel 恢复文件的实例
# ./e2undel -a -t -d /dev/sda2 -s /tmp/recover/
./e2undel 0.82
Trying to recover files on /dev/sda2, saving them on /tmp/recover/
/dev/sda2 opened for read-only access
/dev/sda2 was not cleanly unmounted.
Do you want wo continue (y/n)? y
489600 inodes (489583 free)
977956 blocks of 4096 bytes (941677 free)
last mounted on Fri Dec 28 16:21:50 2007
reading log file: opening log file: No such file or directory
no entries for /dev/sda2 in log file
searching for deleted inodes on /dev/sda2:
|==================================================|
489600 inodes scanned, 26 deleted files found
user name | 1 <12 h | 2 <48 h | 3 <7 d | 4 <30 d | 5 <1 y | 6 older
-------------+---------+---------+---------+---------+---------+--------
root | 0 | 0 | 0 | 2 | 0 | 0
phost | 24 | 0 | 0 | 0 | 0 | 0
Select user name from table or press enter to exit: root
Select time interval (1 to 6) or press enter to exit: 4
inode size deleted at name
-----------------------------------------------------------
13 35840 Dec 19 17:43 2007 * ASCII text
14 10485760 Dec 19 17:43 2007 * ASCII text
Select an inode listed above or press enter to go back: 13
35840 bytes written to /tmp/recover//inode-13-ASCII_text
Select an inode listed above or press enter to go back:
user name | 1 <12 h | 2 <48 h | 3 <7 d | 4 <30 d | 5 <1 y | 6 older
-------------+---------+---------+---------+---------+---------+--------
root | 0 | 0 | 0 | 2 | 0 | 0
phost | 24 | 0 | 0 | 0 | 0 | 0
Select user name from table or press enter to exit:
#
来源:ibm 作者:冯锐 王磊 责编:豆豆技术应用
- Linux/Unix 新闻
- Linux/Unix 入门
- Linux/Unix 命令
- Linux/Unix 安装
- Linux 嵌入式系统
- Linux/Unix 编程
- Linux/Unix 管理
- Linux/Unix 桌面
- Linux/Unix 内核
- Linux/Unix 软件
- SCO Unix
- NetBSD
- OpenBSD
- Redhat/Fedora Linux
- 手机
- Linux/Unix find 搜索命令
- Linux/Unix vi 命令
- Linux/Unix kde 桌面环境
- Linux/Unix GNOME 桌面环境
- Linux/Unix Make 命令
- Linux/Unix crontab 命令
- Linux/Unix ext3 文件系统
- Linux/Unix 文件系统详解
- Linux/Unix ADSL 拨号设置
- Linux/Unix GRUB 配置及应用
- Linux/Unix nfs配置
- Linux/Unix 硬件信息查看及管理
- Linux/Unix 优化
- Linux/Unix 交换分区Swap管理及应用
- Linux/Unix 用户管理
- Linux/Unix Ramdisk
- Linux/Unix 密码恢复管理
- Linux/Unix 文件删除恢复
- Linux/Unix fdisk分区
- Linux/Unix lvs负载均衡管理
- Linux/Unix root用户
- Linux/Unix 集群
- Linux/Unix 日志
- 更多Linux/Unix专题……