Linux下EXT3文件误删除如何恢复文件数据如何恢复

在Linux上如何使用ext3grep恢复文件
我的图书馆
在Linux上如何使用ext3grep恢复文件
  Linux系统操作中,有时会不小心删除重要文件,而能够恢复删除文件的软件有很多,ext3grep就是其中的一种,ext3grep在使用中需要用到不少命令,下面小编就给大家介绍下Linux使用ext3grep的方法。
  步骤:
  目前的最新版本是:ext3grep-0.10.2.tar.gz
  我系统的环境是:虚拟机
  [root@localhost bin]# uname -a
  Linux localhost.localdomain 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:54 EDT
i686 i386 GNU/Linux
  [root@localhost bin]# cat /etc/issue
  Red Hat Enterprise Linux Server release 5.4 (Tikanga)
  & &安装很简单
  tar zxvf ext3grep-0.10.2.tar.gz
  cd ext3grep-0.10.2
  。/configure --prefix=/usr/local/ext3grep
  make install
  顺利安装完成。
  然后进入么安装目录看一下,只有一个bin
  [root@localhost ext3grep]# pwd
  /usr/local/ext3grep
  [root@localhost ext3grep]# ls
  进到bin里面看一下
  [root@localhost ext3grep]# cd bin
  [root@localhost bin]# ls
  ext3grep
  我们可以看一下帮助,下面是部分
  [root@localhost bin]# 。/ext3grep -h
  Running ext3grep version 0.10.2
  。/ext3grep: invalid option -- h
  N implying --superblock.
  Usage: 。/ext3grep [options] [--] device-file
  Options:
  --version, -[vV] Print version and exit successfully.
  --help, Print this help and exit successfully.
  --superblock Print contents of superblock in addition to the rest.
  If no action is specified then this option is implied.
  --print Print content of block or inode, if any.
  --ls Print directories with only one line per entry.
  This option is often needed to turn on filtering.
  --accept filen Accept ‘filen’ as a legal filename. Can be used multi-
  ple times. If you change any --accept you must remove
  BOTH stage* files!
  --accept-all Simply accept everything as filename.
  --journal Show content of journal.
  --show-path-inodes Show the inode of each directory component in paths.
  Filters:
  --group grp Only process group ‘grp’。
  --directory Only process directory inodes.
  --after dtime Only entries deleted on or after ‘dtime’。
  --before dtime Only entries deleted before ‘dtime’。
  --deleted Only show/process deleted entries.
  --allocated Only show/process allocated inodes/blocks.
  --unallocated Only show/process unallocated inodes/blocks.
  --reallocated Do not suppress entries with reallocated inodes.
  Inodes are considered ‘reallocated’ if the entry
  is deleted but the inode is allocated, but also when
  the file type in the dir entry and the inode are
  different.
  --zeroed-inodes Do not suppress entries with zeroed inodes. Linked
  entries are always shown, regardless of this option.
  --depth depth Process directories recursively up till a depth
  of ‘depth’。
  Actions:
  --inode-to-block ino Print the block that contains inode ‘ino’。
  --inode ino Show info on inode ‘ino’。
  If --ls is used and the inode is a directory, then
  the filters apply to the entries of the directory.
  If you do not use --ls then --print is implied.
  --block blk Show info on block ‘blk’。
  If --ls is used and the block is the first block
  of a directory, then the filters apply to entries
  of the directory.
  If you do not use --ls then --print is implied.
  --histogram=[atime|ctime|mtime|dtime|group]
  Generate a histogram based on the given specs.
  Using atime, ctime or mtime will change the
  meaning of --after and --before to those times.
  --journal-block jblk Show info on journal block ‘jblk’。
  --journal-transaction seq
  Show info on transaction with sequence number ‘seq’。
  --dump-names Write the path of files to stdout.
  This implies --ls but suppresses it‘s output.
  --search-start str Find blocks that start with the fixed string ’str‘。
  --search str Find blocks that contain the fixed string ’str‘。
  --search-inode blk Find inodes that refer to block ’blk‘。
  --search-zeroed-inodes Return allocated inode table entries that are zeroed.
  --inode-dirblock-table dir
  Print a table for directory path ’dir‘ of directory
  block numbers found and the inodes used for each file.
  开始工作之前,我们先来制作一个分区,然后来做试验
  [root@localhost bin]# mkdir /tmp/test
  [root@localhost bin]# dd if=/dev/zero of=file count=102400
  [root@localhost bin]#mkfs.ext3 file
  ######按Y继续
  [root@localhost bin]#mount -o loop /tmp/test/file /mnt
  看一下有没有挂上
  [root@localhost bin]# df -HT
  Filesystem Type Size Used Avail Use% Mounted on
  /dev/mapper/VolGroup00-LogVol00
  ext3 20G 4.3G 15G 23% /
  /dev/sda1 ext3 104M 13M 86M 13% /boot
  tmpfs tmpfs 185M 0 185M 0% /dev/shm
  /tmp/test/file
  ext3 51M 5.1M 44M 11% /mnt
  然后写入数据到里面
  [root@localhost bin]#cd /mnt
  [root@localhost bin]#ls
  lost+found
  [root@localhost mnt]# mkdir del
  [root@localhost mnt]# cd del
  [root@localhost del]# touch 1 2 3
  [root@localhost del]# ls
  1 2 3 lost+found
  [root@localhost del]# cd 。。
  [root@localhost mnt]#rf -rf del
  [root@localhost bin]#ls
  lost+found
  下面开始恢复了
  [root@localhost mnt]#cd /usr/local/ext3grep/bin
  扫描一下分区
  [root@localhost bin]# 。/ext3grep /tmp/test/file --ls --inode 2
  Running ext3grep version 0.10.2
  Number of groups: 7
  Loading group metadata.。。 done
  Minimum / maximum journal block: 447 / 4561
  Loading journal descriptors.。。 sorting.。。 done
  The oldest inode block that is still in the journal, appears to be from
= Wed Sep 14 14:04:53 2011
  Number of descriptors in journal: 36; min / max sequence numbers: 2 / 6
  Inode is Allocated
  Finding all blocks that might be directories.
  D: block containing directory start, d: block containing more directory entries.
  Each plus represents a directory start that references the same inode as a directory start that we found previously.
  Searching group 0: DD++D++
  Searching group 1:
  Searching group 2:
  Searching group 3:
  Searching group 4:
  Searching group 5:
  Searching group 6:
  Writing analysis so far to ’file.ext3grep.stage1‘。 Delete that file if you want to do this stage again.
  Result of stage one:
  3 inodes are referenced by one or more directory blocks, 2 of those inodes are still allocated.
  1 inodes are referenced by more than one directory block, 1 of those inodes is still allocated.
  0 blocks contain an extended directory.
  Result of stage two:
  2 of those inodes could be resolved because they are still allocated.
  All directory inodes are accounted for!
  Writing analysis so far to ’file.ext3grep.stage2‘。 Delete that file if you want to do this stage again.
  The first block of the directory is 433.
  Inode 2 is directory “”。
  Directory block 433:
  。-- File type in dir_entry (r=regular file, d=directory, l=symlink)
  | 。-- D: D R: Reallocated
  Indx Next | Inode | Deletion time Mode File name
  ==========+==========+----------------data-from-inode------+-----------+=========
  0 1 d 2 drwxr-xr-x 。
  1 2 d 2 drwxr-xr-x 。。
  2 end d 11 drwx------ lost+found
  3 4 r 12 D
Wed Sep 14 14:05:55 2011 rrw-r--r-- 1
  4 5 r 13 D
Wed Sep 14 14:05:55 2011 rrw-r--r-- 2
  5 6 r 14 D
Wed Sep 14 14:05:55 2011 rrw-r--r-- 3
  6 end d 1833 D
Wed Sep 14 14:05:55 2011 drwxr-xr-x del
  [root@localhost bin]# 。/ext3grep /tmp/test/file --restore-file del --depth del
  Running ext3grep version 0.10.2
  Number of groups: 7
  Minimum / maximum journal block: 447 / 4561
  Loading journal descriptors.。。 sorting.。。 done
  The oldest inode block that is still in the journal, appears to be from
= Wed Sep 14 14:04:53 2011
  Number of descriptors in journal: 36; min / max sequence numbers: 2 / 6
  Writing output to directory RESTORED_FILES/
  Loading file.ext3grep.stage2.。。 done
  下面开始恢复文件
  [root@localhost bin]# 。/ext3grep /tmp/test/file --restore-all
  Running ext3grep version 0.10.2
  Number of groups: 7
  Minimum / maximum journal block: 447 / 4561
  Loading journal descriptors.。。 sorting.。。 done
  The oldest inode block that is still in the journal, appears to be from
= Wed Sep 14 14:05:13 2011
  Number of descriptors in journal: 36; min / max sequence numbers: 3 / 9
  Loading file.ext3grep.stage2.。。 done
  Restoring 1
  Restoring 2
  Restoring 3
  Restoring del/1
  Restoring del/2
  Restoring del/3
  这个命令是恢复所有的,当然也可以恢复指定文件的。
  可以看到在当前目录下,多了一个目录
  [root@localhost bin]# ls
  RESTORED_FILES ext3grep
  我们进去看一下
  [root@localhost bin]# cd RESTORED_FILES/
  [root@localhost RESTORED_FILES]# ls
  1 2 3 del lost+found
  上面就是Linux使用ext3grep恢复文件的方法介绍了,通过本文的介绍可以看出,ext3grep不仅能够恢复所有被删除的文件,还能恢复指定的文件。(转自系统之家网站)
[转]&[转]&[转]&[转]&[转]&[转]&
喜欢该文的人也喜欢&>&ext4文件恢复
ext4文件恢复
上传大小:884KB
ext4文件恢复ext4文件恢复ext4文件恢复ext4文件恢复ext4文件恢复ext4文件恢复
综合评分:0
{%username%}回复{%com_username%}{%time%}\
/*点击出现回复框*/
$(".respond_btn").on("click", function (e) {
$(this).parents(".rightLi").children(".respond_box").show();
e.stopPropagation();
$(".cancel_res").on("click", function (e) {
$(this).parents(".res_b").siblings(".res_area").val("");
$(this).parents(".respond_box").hide();
e.stopPropagation();
/*删除评论*/
$(".del_comment_c").on("click", function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_invalid/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parents(".conLi").remove();
alert(data.msg);
$(".res_btn").click(function (e) {
var parentWrap = $(this).parents(".respond_box"),
q = parentWrap.find(".form1").serializeArray(),
resStr = $.trim(parentWrap.find(".res_area_r").val());
console.log(q);
//var res_area_r = $.trim($(".res_area_r").val());
if (resStr == '') {
$(".res_text").css({color: "red"});
$.post("/index.php/comment/do_comment_reply/", q,
function (data) {
if (data.succ == 1) {
var $target,
evt = e || window.
$target = $(evt.target || evt.srcElement);
var $dd = $target.parents('dd');
var $wrapReply = $dd.find('.respond_box');
console.log($wrapReply);
//var mess = $(".res_area_r").val();
var mess = resS
var str = str.replace(/{%header%}/g, data.header)
.replace(/{%href%}/g, 'http://' + window.location.host + '/user/' + data.username)
.replace(/{%username%}/g, data.username)
.replace(/{%com_username%}/g, data.com_username)
.replace(/{%time%}/g, data.time)
.replace(/{%id%}/g, data.id)
.replace(/{%mess%}/g, mess);
$dd.after(str);
$(".respond_box").hide();
$(".res_area_r").val("");
$(".res_area").val("");
$wrapReply.hide();
alert(data.msg);
}, "json");
/*删除回复*/
$(".rightLi").on("click", '.del_comment_r', function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_comment_del/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parent().parent().parent().parent().parent().remove();
$(e.target).parents('.res_list').remove()
alert(data.msg);
//填充回复
function KeyP(v) {
var parentWrap = $(v).parents(".respond_box");
parentWrap.find(".res_area_r").val($.trim(parentWrap.find(".res_area").val()));
评论共有0条
VIP会员动态
CSDN下载频道资源及相关规则调整公告V11.10
下载频道用户反馈专区
下载频道积分规则调整V1710.18
spring mvc+mybatis+mysql+maven+bootstrap 整合实现增删查改简单实例.zip
资源所需积分/C币
当前拥有积分
当前拥有C币
输入下载码
为了良好体验,不建议使用迅雷下载
ext4文件恢复
会员到期时间:
剩余下载个数:
剩余积分:0
为了良好体验,不建议使用迅雷下载
积分不足!
资源所需积分/C币
当前拥有积分
您可以选择
程序员的必选
绿色安全资源
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
您的积分不足,将扣除 10 C币
为了良好体验,不建议使用迅雷下载
无法举报自己的资源
你当前的下载分为234。
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可返还被扣除的积分
被举报人:
请选择类型
资源无法下载 ( 404页面、下载失败、资源本身问题)
资源无法使用 (文件损坏、内容缺失、题文不符)
侵犯版权资源 (侵犯公司或个人版权)
虚假资源 (恶意欺诈、刷分资源)
含色情、危害国家安全内容
含广告、木马病毒资源
*投诉人姓名:
*投诉人联系方式:
*版权证明:
*详细原因:
ext4文件恢复微信公众号
ext3grep文件系统反删除利器的安装与使用
Linux作为企业级服务器,数据的安全性至关重要,任何数据的丢失和误删除都是不可容忍的。做为系统管理员,一定要有数据保护意识,不但要对服务器数据进行定期备份,而且还要具有在误删除数据后将其快速恢复的技能。本章重点讲述Linux下的ext3文件系统中用于数据恢复的开源软件ext3grep。通过这个软件,可以快速、准确地恢复误删除的数据。
最后,通过两个实例具体介绍利用ext3grep恢复数据的详细过程。
&rm&rf&带来的困惑
&&& 国外一份非常著名的Linux系统管理员守则中有这么一条:&慎用rm -rf命令,除非你知道此命令将带来什么后果&。可见,这个命令对系统管理员的重要性。在实际的工作中,由此命令带来的误删除数据的案例屡见不鲜,很多系统管理员都遇到过或者犯过这样的错误。
由于开发人员对命令不熟悉,或者粗心大意、疏于管理,执行了此命令,数据在一瞬间就被清空了。Linux不具备类似回收站的功能,这就意味着数据会丢失。虽然Linux自身提供了恢复数据的机制,但是这个功能基本没用,要恢复数据,通过常规手段是无法完成的,此时,只有找专业的数据恢复公词来恢复数据,这样无疑要付出很大的成本,造成无法估量的损失。
&&& 可见,作为系统管理员,一定要有数据安全意识,数据保护意识,严格遵守相关维护守则,将这种失误带来的损失降低到最低。幸运的是,Linux下提供了一款恢复误删数据的开源软件,利用这个ext3文件系统数据恢复工具ext3grep可以恢复误删除的数据。
&ext3grep的安装与使用
&&& ext3grep是一个开源的ext3文件系统反删除工具。在ext3grep出现之前,数据被删除后,通过常规手段恢复基本上是不可能的,虽然debugfs命令可以对ext2文件系统做一些恢复,但是对ext3文件系统就无能为力了。ext3是一个日志型文件系统,ext3grep正是通过分析ext3文件系统的日志信息来恢复被删除的文件和数据的。
1、ext3grep的恢复原理
在介绍ext3grep恢复原理之前,先介绍一下文件系统中inode的一些相关知识。inode是文件系统组成的最基本单元,是文件系统连接任何子目录、任何文件的桥梁。它包括了文件系统中文件基本属性和存放数据的位置等相关信息。每个文件由两部分组成:一部分是inode,另一部分是block。block用来存储数据,inode用来存储数据索引信息,包括文件大小、读写权限、属主、归属的用户组等。操作系统根据用户指令,通过inode值就能很快找到对应的文件。
&&& 打个比方,存储设备或磁盘分区就相当于一本书,block相当于书中的每一页,inode相当于这本书的目录。一本书有很多内容,要查找某部分的内容,先查找目录,然后就能很快定位到想要查看的内容。
&&& 在Linux下可以通过&ls -id&命令来查看某个文件或者目录的inode值。例如查看根目录的inodc值,可以输入:
[root@localhost ~]# ls -id /
&&& 由此可知,根目录的inode值为2。
&&& 利用ext3grep恢复文件时并不依赖特定文件格式。首先ext3grep通过文件系统的rootinode(根目录的inode一般为2)来获得当前文件系统下所有文件的信息,包括存在的和已经删隙的文件,这些信息包括文件名和inode。然后利用inode信息结合日志去查询该inode所在的block位置,包括直接块、间接块等信息。最后利用dd命令将这些信息备份出来,从而恢复数据文件。
2、ext3grep的安装过程
&&& 操作系统环境:CentOS release 6.40
&&& cxt3grep版本:ext3grep-0.10.2。
&&& ext3grep官方网站:http://code.google.com/p/ext3grep/,可以从这里下载最新的ext3grep版本。这里下载的是http://ext3grep.googlecode.com/files/ext3grep-0.10.2.tar.gz
&&& 所需的系统相关包:
[root@localhost software]# rpm -qa | grep e2fsprogs
e2fsprogs-libs-1.41.12-14.el6_4.2.i686
e2fsprogs-devel-1.41.12-14.el6_4.2.i686
e2fsprogs-1.41.12-14.el6_4.2.i686
&&& 系统必须安装e2fsprogs-libs,不然后面ext3grep的安装会出现问题。
&&& 下面进入编译安装阶段,过程如下:
[root@localhost software]# wget http://ext3grep.googlecode.com/files/ext3grep-0.10.2.tar.gz
-- 16:06:58--& http://ext3grep.googlecode.com/files/ext3grep-0.10.2.tar.gz
正在解析主机 ext3grep.googlecode.com... 74.125.128.82, 05:c00::52
正在连接 ext3grep.googlecode.com|74.125.128.82|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1K) [application/x-gzip]
正在保存至: &ext3grep-0.10.2.tar.gz&
100%[=======================================&] 236,364&&&&& 362K/s&& in 0.6s&&&
16:06:59 (362 KB/s) - 已保存 &ext3grep-0.10.2.tar.gz& [364])
[root@localhost software]# tar zxvf ext3grep-0.10.2.tar.gz
[root@localhost software]# cd ext3grep-0.10.2
[root@localhost ext3grep-0.10.2]# ./configure
[root@localhost ext3grep-0.10.2]# make
[root@localhost ext3grep-0.10.2]# make install
[root@localhost ext3grep-0.10.2]# ext3grep -v
Running ext3grep version 0.10.2
ext3grep v0.10.2, Copyright (C) 2008 Carlo Wood.
ext3grep comes with ABSOLUTELY NO WARRANTY;
This prog your freedom to use, change
and distribute this program is protected by the GPL.
这里,ext3grep就安装完成了,默认的ext3grep命令放在/usr/local/bin目录下。ext3grep的使用非常简单,这里不做介绍,可以通过&ext3grep --help&获取详细的使用帮助。
其他类似的新闻
● ● ● ● ● ● ● ● ● ●
其他相关的新闻
大家感兴趣的内容
小伙伴最爱的新闻
小伙伴还关注了以下信息
小伙伴关注的焦点
小伙伴都在关注的热门词
Copyright (C)
ITHOV.COM Inc. All Rights Reserved
孝感风信信息技术有限公司 ● 版权所有如何恢复linux下删除的文件 (下)
现在请将附件中的 createfile.sh 文件下载到本地,并将其保存到
/tmp/test 目录中,这个脚本可以帮助我们创建一个特殊的文件,其中每行包含 1KB
字符,最开始的14个字符表示行号。之所以采用这种文件格式,是为了方便地确认所恢复出来的文件与原始文件之间的区别。这个脚本的用法如下:
# ./createfile.sh [size in KB] [filename]
第 1 个参数表示所生成的文件大小,单位是 KB;第 2 个参数表示所生成文件的名字。
下面让我们创建几个测试文件:
# cd /tmp/test#./createfile.sh 35 testfile.35K#./createfile.sh 10240 testfile.10M# cp testfile.35K testfile.35K.orig# cp testfile.10M testfile.10M.orig
上面的命令新创建了大小为 35 KB 和 9000KB 的两个文件,并为它们各自保存了一个备份,备份文件的目的是为了方便使用 diff 之类的工具验证最终恢复出来的文件与原始文件完全一致。
ls 命令的 –i 选项可以查看有关保存文件使用的索引节点的信息:
# ls -li | sort11 drwx------ 2 root root
16384 Oct 29 20:08 lost+found12 -rwxr-xr-x 1 root root
1406 Oct 29 20:09 createfile.sh13 -rw-r--r-- 1 root root
35840 Oct 29 20:09 testfile.35K14 -rw-r--r-- 1 root root
Oct 29 20:10 testfile.10M15 -rw-r--r-- 1 root root
35840 Oct 29 20:10 testfile.35K.orig16 -rw-r--r-- 1 root root
Oct 29 20:11 testfile.10M.orig
第一列中的数字就是索引节点号。从上面的输出结果我们可以看出,索引节点号是按照我们创建文件的顺序
而逐渐自增的,我们刚才创建的 35K 大小的文件的索引节点号为 13,10M 大小的文件的索引节点号为 14。debugfs
中提供了很多工具,可以帮助我们了解进一步的信息。现在执行下面的命令:
# echo "stat &13&" | debugfs /dev/sdb6debugfs 1.39 (29-May-2006)Inode: 13
Type: regular
Flags: 0x0
Generation: User:
Size: 35840File ACL: 0
Directory ACL: 0Links: 1
Blockcount: 72Fragment:
Address: 0
Size: 0ctime: 0x -- Mon Oct 29 20:09:59 2007atime: 0x4726849d -- Mon Oct 29 20:10:53 2007mtime: 0x -- Mon Oct 29 20:09:59 2007BLOCKS:(0-8):TOTAL: 9
输出结果显示的就是索引节点 13 的详细信息,从中我们可以看到诸如文件大小(35840=35K)、权限(0644)等信息,尤其需要注意的是最后 3 行的信息,即该文件被保存到磁盘上的 4096 到 4104 总共 9 个数据块中。
下面再看一下索引节点 14 (即 testfile.10M 文件)的详细信息:
# echo "stat &14&" | debugfs /dev/sdb6debugfs 1.39 (29-May-2006)Inode: 14
Type: regular
Mode: 0644
Flags: 0x0
Generation: User:
Size: File ACL: 0
Directory ACL: 0Links: 1
Blockcount: 20512Fragment:
Address: 0
Size: 0ctime: 0x -- Mon Oct 29 20:10:29 2007atime: 0x -- Mon Oct 29 20:11:01 2007mtime: 0x -- Mon Oct 29 20:10:29 2007BLOCKS:(0-11):, (IND):24588, (12--25612, (DIND):25613, (IND):25614, ():, (IND):26639, ():TOTAL: 2564
和索引节点 13 相比,二者之间最重要的区别在于 BLOCKS
的数据,testfile.10M 在磁盘上总共占用了 2564
个数据块,由于需要采用二级间接寻址模式进行访问,所以使用了4个块来存放间接寻址的信息,分别是2、2,其中
25613块中存放的是二级间接寻址的信息。linux ext3文件被删除如何恢复Ext3文件系统结构的简单介绍
在Linux所用的Ext3文件系统中,文件是以块为单位存储的,默认情况下每个块的大小是1K,不同的块以块号区分。每个文件还有一个节点,节点中包含
有文件所有者,读写权限,文件类型等信息。对于一个小于12个块的文件,在节点中直接存储文件数据块的块号。如果文件大于12个块,那么节点在12个块号
之后存储一个间接块的块号,在这个间接块号所对应的块中,存储有256个文件数据块的块号(Ext2fs中每个块号占用4字节,这样一个块中所能存储的块
号就是)。如果有更大的文件,那么还会在节点中出现二级间接块和三级间接块。
2。恢复被误删文件的方法
大多数Linux发行版都提供一个debugfs工具,可以用来对Ext3文件系统进行编辑操作。不过在使用这个工具之前,还有一些工作要做。
首先以只读方式重新挂载被误删的文件所在分区。使用如下命令:(假设文件在/usr分区)
mount -r -n -o remount /usr
-r表示只读方式挂载;-n表示不写入/etc/mtab,如果是恢复/etc上的文件,就加上这个参数。如果系统说xxx partion busy,可以用fuser命令查看一下是哪些进程使用这个分区上的文件:
fuser -v -m /usr
如果没有什么重要的进程,用以下命令停掉它们:(看清楚了,远程操作的千万别冲动,不然你会受到惩罚的)
fuser -k -v -m /usr
然后就可以重新挂载这些文件系统了。
如果是把所有的文件统一安装在一个大的/分区当中,可以在boot提示符下用linux
single进入单用户模式,尽量减少系统进程向硬盘写入数据的机会,要不干脆把硬盘挂在别的机器上。另外,恢复出来的数据不要写到/上面,避免破坏那些
有用的数据。如果机器上有dos/windows,可以写到这些分区上面:
mount -r -n /dev/hda1 /mnt/had
然后就可以执行debugfs:(假设Linux在 /dev/hda5)
#debugfs /dev/hda5
就会出现debugfs提示符debugfs:
使用lsdel命令可以列出很多被删除的文件的信息:
debugfs:lsdel
debugfs: 2692 deleted inodes found.
Inode Owner Mode Size Blocks Time deleted
2 1/ 1 Sun May 13 19:22:46 2001
…………………………………………………………………………………
644 4 1/ 1 Tue Apr 24 10:11:15 2001
500 38/ 38 Mon May 27 13:52:04 2001
列出的文件有很多(这里找到2692个),第一字段是文件节点号,第二字段是文件所有者,第三字段是读写权限,接下来是文件大小,占用块数,删除时间。然后就可以根据文件大小和删除日期判断那些是我们需要的。比如我们要恢复节点是196829的文件:
可以先看看文件数据状态:
debugfs:stat
Inode: 196829 Type: regular Mode: 0644 Flags: 0x0 Version: 1
User: 0 Group: 0 Size: 149500
File ACL: 0 Directory ACL: 0
Links: 0 Blockcount: 38
Fragment: Address: 0 Number: 0 Size: 0
ctime: 0x31a9a574 -- Mon May 27 13:52:04 2001
atime: 0x31a21dd1 -- Tue May 21 20:47:29 2001
mtime: 0x313bf4d7 -- Tue Mar 5 08:01:27 2001
dtime: 0x31a9a574 -- Mon May 27 13:52:04 2001
811 815 817 ………………………………….
然后就可以用dump指令恢复文件:
debugfs:dump /mnt/hda/01.sav
这样就把文件恢复出来了。退出debugfs:
debugfs:quit
另一种方法是手工编辑inode:
debugfs:mi
Mode [0100644]
User ID [0]
Group ID [0]
Size [149500]
Creation time [0x31a9a574]
Modification time [0x31a9a574]
Access time [0x31a21dd1]
Deletion time [0x31a9a574] 0
Link count [0] 1
Block count [38]
File flags [0x0]
Reserved1 [0]
File acl [0]
Directory acl [0]
Fragment address [0]
Fragment number [0]
Fragment size [0]
Direct Block #0 [594810]
…………………………….
Triple Indirect Block [0]
使用mi指令后每次显示一行信息以供编辑,其它行可以直接按回车表示确认,把deletion time改成0(未删除),Link count改成1。改好后退出debugfs:
debugfs:quit
然后用fsck检查/dev/hda5
fsck /dev/hda5
程序会说找到丢失的数据块,放在lost+found里面。'
&&&回复&&&:
提供针对oracle初学者及进阶的数据库培训,欢迎大家咨询:
微信公众号:
wisdomone9
北京盛拓优讯信息技术有限公司. 版权所有 京ICP备号 北京市公安局海淀分局网监中心备案编号:10
广播电视节目制作经营许可证(京) 字第1234号 中国互联网协会会员

我要回帖

更多关于 手机文件误删除恢复 的文章

 

随机推荐