可以恢复,使用系统自还工具debugfs来还原删除的文件

步骤详解

1、 查看一下当前系统版本号,及文件系统格式

[root@localhost ~]# df -T 
Filesystem Type 1K-blocks Used Available Use% Mounted on 
/dev/mapper/VolGroup-lv_root 
ext4 51475068 22730068 26123560 47% / 
tmpfs tmpfs 3966808 68 3966740 1% /dev/shm 
/dev/sda2 ext4 487652 42534 419518 10% /boot 
/dev/mapper/VolGroup-lv_home 
ext4 901188872 20070036 835334364 3% /home

2、新建一个文件夹及文件my.txt,然后删除

[root@localhost local]# mkdir test 
[root@localhost local]# cd test 
[root@localhost test]# touch my.txt 
[root@localhost test]# ll 
总用量 0 
-rw-r–r–. 1 root root 0 1月 4 15:22 my.txt 
[root@localhost test]# rm -f my.txt 
[root@localhost test]# ll 
总用量 0

3、运用,系统自还工具debugfs来修复 打开,刚刚被删除文件所在的分区,用ls 加-d参数显示刚刚删除文件所在的目录

[root@localhost test]# debugfs 
debugfs 1.41.12 (17-May-2010) 
debugfs: open /dev/mapper/VolGroup-lv_root 
debugfs: ls -d /usr/local/test/ 
2378807 (12) . 2098175 (4084) .. <2378808> (4072) my.txt

4、显示有<>尖括号的就是我们要找的文件Inode 号 执行logdump –i <2378808>,然后输入“quit”退出debugfs

debugfs: logdump -i <2378808> 
Inode 2378808 is at group 290, block 9438337, offset 2944 
Journal starts at block 16826, transaction 2237277 
No magic number at block 30648: end of journal. 
debugfs: quit

5、执行以下命令,进行恢复,bs与skip的值分别取自:block 9438337, offset 2944

dd if=/dev/mapper/VolGroup-lv_root of=/usr/local/test/my.txt bs=2944 count=1 skip=9438337

bs对应上面的offset后面的值,skip对应block后面的值

debugfs: quit 
[root@localhost test]# dd if=/dev/mapper/VolGroup-lv_root of=/usr/local/test/my.txt bs=2944 count=1 skip=9438337 
记录了1+0 的读入 
记录了1+0 的写出 
2944字节(2.9 kB)已复制,0.00989032 秒,298 kB/秒 
[root@localhost test]# ls 
my.txt

至此,刚删除的数据已恢复

Linux 文件恢复的更多相关文章

  1. Linux文件恢复利器 ext3grep与extundelete

    介绍两款Linux文件恢复工具,ext3grep与extundelete,可能在关键时刻会有所帮助.ext3grep仅对ext3文件系统有效,extundelete对ext3与ext4文件系统都有效 ...

  2. Linux 文件恢复(XFS & EXT4)

    在Linux中,删除rm命令使用需谨慎,有时候可能由于误操作,导致重要文件删除了,这时不要太紧张,操作得当的话,还是可以恢复的. EXT 类型文件恢复 删除一个文件,实际上并不清除inode节点和bl ...

  3. 使用 Linux 文件恢复工具

    使用 Linux 文件恢复工具         Linux 文件恢复的原理 inode 和 block 首先简单介绍一下 Linux 文件系统的最基本单元:inode.inode 译成中文就是索引节点 ...

  4. Linux 文件系统错误的修复方法 ddrescue替代dd的恢复软件 备用超级块

    Linux 文件系统错误的修复方法  ddrescue替代dd的恢复软件  备用超级块 最近处理的一件 linux 服务器断电导致文件系统启动后文件系统不可读写,数据不可用的案例,现总结下 Linux ...

  5. linux下恢复误删除的文件方法(ext2及ext3)

     linux下恢复误删除的文件方法(ext2及ext3) 2009-12-19 15:23:47 分类: LINUX 如果是ext2文件系统的,直接用debugfs是可以恢复出来的,但对于ext3,d ...

  6. 云服务器 ECS Linux 误删除文件恢复方法介绍

    云服务器 ECS Linux 下,rm -rf  意味着一旦删除的文件是无法挽回的.但如果在没有文件覆盖操作的前提下,可以先尝试相关方式进行文件恢复. 本文对此进行简要说明. https://help ...

  7. Linux之文件恢复[extundelete,针对rm]

    [恢复过程] 1.下载+安装extundelete cd /tmp wget wget http://jaist.dl.sourceforge.net/project/extundelete/extu ...

  8. Linux文件误删之后恢复方法

    前言 今天不小心把一个文件给误删了,因为不想花半天时间重新写,就查找了一下Linux下恢复文件的方法. 因为是刚删不久,文件实际的数据应该还在 首先查看系统分区 Linux:~# df Filesys ...

  9. [转帖]如何备份及恢复Linux文件权限

    如何备份及恢复Linux文件权限   http://embeddedlinux.org.cn/emb-linux/entry-level/201604/10-5337.html 三年前我就干过 chm ...

随机推荐

  1. python - 递归 二分法

    一.一些内置函数 1.revsered  翻转,返回的是迭代器 # 将 s 倒置 s = '不是上海自来水来自海上' # 方法一 print(s[::-1]) # 方法二 s1 = reversed( ...

  2. Cross-Validation & Nested Cross-Validation

    分享stackexchange的一篇问答:https://stats.stackexchange.com/questions/11602/training-with-the-full-dataset- ...

  3. js检测页面离开

    window.location = 'yjk://app.h5.ihaozhuo.com?page=livetrailer&videoLiveId=' + parseInt(this.Requ ...

  4. import com.sun.org.apache.xerces.internal.impl.dv.util.Base64报错

       该类不属于JDK标准库范畴,但在JDK中包含了该类,可以直接使用.但是在eclipse中直接使用却找不到该类. 以下是解决方法步骤: Properties-->JavaBulid Path ...

  5. eregi

    eregi (PHP 4, PHP 5) eregi — 不区分大小写的正则表达式匹配 说明 int eregi ( string $pattern , string $string [, array ...

  6. Rhino学习教程——1.5

    图形面板 图形面板是Rhino为了方便用户操作设置的一个区域,默认提供了“属性”.“图层”.“说明”3个面板(我自定义过了,新增了一个“显示”功能 ). trip:如果要打开更多的图版,可以点击图形面 ...

  7. UVa 11389 - The Bus Driver Problem 难度:0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  8. Python_Mix*re模块基础方法,进阶,正则表达式的使用

    re模块import re 基础方法 findall:匹配所有 ,每一项都是列表中的一个元素,返回的是列表 search只匹配从左到右的第一个,得到的不是直接的结果,而是一个变量,通过这个变量的gro ...

  9. maven jstl The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

    maven jstl 报错 HTTP Status 500 – Internal Server Error Type Exception Report Message The absolute uri ...

  10. C语言:递归函数n!

    #include <stdio.h> long recursion(int n); void main(){ int n; long result; printf("input ...