首页 > 系统相关 >Linux下面误删除文件使用extundelete工具恢复介绍

Linux下面误删除文件使用extundelete工具恢复介绍

时间:2023-05-08 13:14:48浏览次数:39  
标签:误删除 00 26 extundelete Linux test zw root

操作系统版本:CentOS release 6.4 (Final)      软件版本:extundelete-0.2.4.tar.bz2

PS:该软件恢复文件系统仅支持ext2/ext3/ext4

1. 创建文件系统
[root@zw_test_26_74 /]#  mkfs -t ext4 /dev/sdb3

2.查看文件系统类型
[root@zw_test_26_74 /]# blkid /dev/sdb3  --查看文件系统类型
/dev/sdb3: UUID="b786e8d1-e8ac-4681-ad3a-ff7a39c07146" TYPE="ext4"

也可以用下面方法查看
[root@zw_test_26_74 ~]# file -s /dev/sdb3
/dev/sdb3: Linux rev 1.0 ext4 filesystem data (extents) (huge files)

3.创建一个delete目录,并挂载到刚创建的文件系统上,并创建文件,然后删除文件

[root@zw_test_26_74 /]# mkdir delete
[root@zw_test_26_74 /]# mount /dev/sdb3 /delete
[root@zw_test_26_74 /]# cd /delete
[root@zw_test_26_74 delete]# ls
lost+found
[root@zw_test_26_74 delete]# vi zw.txt      --添加一些内容
[root@zw_test_26_74 delete]# rm -rf zw.txt

4.下载
extundelete 主页:http://extundelete.sourceforge.net/
下载地址:http://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2   --0.2.4版本
        ​​ ​http://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2​​​   --0.2.4版本
           
[root@zw_test_26_74 /]# wget wget http://nchc.dl.sourceforge.net/project/extundelete/extundelete/0.2.4/extundelete-0.2.4.tar.bz2

[root@zw_test_26_74 /]# tar -xvf extundelete-0.2.4.tar.bz2

[root@zw_test_26_74 extundelete-0.2.4]# cd /extundelete-0.2.4


[root@zw_test_26_74 extundelete-0.2.4]# ./configure --prefix=/usr/local/extundelete  && make && make install  
Configuring extundelete 0.2.4
configure: error: Can't find ext2fs library


这是因为extundelete依赖e2fsprogs。

[root@zw_test_26_74 extundelete-0.2.4]# yum -y install e2fsprogs  e2fsprogs-devel

安装e2fsprogs后再次configure 成功。


[root@zw_test_26_74 extundelete-0.2.4]# ./configure  --prefix=/usr/local/extundelete  && make && make install
Configuring extundelete 0.2.4
Writing generated files to disk
make -s all-recursive
Making all in src
Making install in src
  /usr/bin/install -c 'extundelete' '/usr/local/bin/extundelete'

5.查看工具版本
[root@zw_test_26_74 /]# cd /usr/local/extundelete/bin
[root@zw_test_26_74 bin]# ./extundelete -v
extundelete version 0.2.4
libext2fs version 1.41.12
Processor is little endian.

6.卸载分区,注意如果是/ 根目录的删了,把磁盘挂载到其他机器做恢复

[root@zw_test_26_74 ~] fuser -k /delete         <-- 结束使用某分区的进程树
[root@www ~]# umount /delete                    <-- 卸载分区
[root@zw_test_26_74 ~]#  umount /dev/sdb3

7.使用extundelete查看分区上存在的文件
extundelete --inode 2 /dev/sdb2
# --inode 为查找某i节点中的内容,使用2则说明为搜索,如果需要进入目录搜索,只须要指定目录I节点即可

[root@zw_test_26_74 bin]#  extundelete --inode 2 /dev/sdb3
WARNING: Extended attributes are not restored.
Loading filesystem metadata ... 26 groups loaded.
Contents of inode 2:
0000 | ed 41 00 00 00 04 00 00 01 7b c6 56 05 7b c6 56 | .A.......{.V.{.V
0010 | 05 7b c6 56 00 00 00 00 00 00 03 00 02 00 00 00 | .{.V............
0020 | 00 00 00 00 20 00 00 00 e3 10 00 00 00 00 00 00 | .... ...........
0030 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
0040 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
0050 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
0060 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................
0070 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | ................

Inode is Allocated
Group: 0
File mode: 16877
Low 16 bits of Owner Uid: 0
Size in bytes: 1024
Access time: 1455848193
Creation time: 1455848197
Modification time: 1455848197
Deletion Time: 0
Low 16 bits of Group Id: 0
Links count: 3
Blocks count: 2
File flags: 0
File version (for NFS): 0
File ACL: 0
Directory ACL: 0
Fragment address: 0
Direct blocks: 4323, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Indirect block: 0
Double indirect block: 0
Triple indirect block: 0

File name                                       | Inode number | Deleted status
Directory block 4323:
.                                                 2
..                                                2
lost+found                                        11
zw.txt                                           14             Deleted
.zw.txt.swp                                       13             Deleted
zw.txt~                                           12             Deleted


上面标记为deleted的,zw.txt 就是我误删的数据


8. 恢复:
root@zw_test_26_74 bin]# extundelete --restore-all  /dev/sdb3
WARNING: Extended attributes are not restored.
Loading filesystem metadata ... 26 groups loaded.
Loading journal descriptors ... 47 descriptors loaded.
Writing output to directory RECOVERED_FILES/
Searching for recoverable inodes in directory / ...
1 recoverable inodes found.
Looking through the directory structure for deleted files ...
Restored inode 14 to file RECOVERED_FILES/zw.txt
0 recoverable inodes still lost.
[root@zw_test_26_74 bin]# ll
total 1164
-rwxr-xr-x 1 root root 1187047 Feb 19 10:10 extundelete

 

drwxr-xr-x 2 root root    4096 Feb 19 11:20 RECOVERED_FILES

 

[root@zw_test_26_74 bin]# cd RECOVERED_FILES/

 

[root@zw_test_26_74 RECOVERED_FILES]# ll
total 4
-rw-r--r-- 1 root root 150 Feb 19 11:20 zw.txt

可以看到zw.txt 已经恢复到RECOVERED_FILES 目录下了。

9.扩展命令:
--restore-inode 12              # --restore-inode 按指定的I节点恢复
--restore-file zw.txt           # --restore-file 按指定的文件名恢复
--extundelete --restore-all     # --restore-all  是全部恢复 ,默认全将恢复出来的文件放在当前路径 RECOVERED_FILES/ 目录下,文件名为 file.I节点号

 

标签:误删除,00,26,extundelete,Linux,test,zw,root
From: https://www.cnblogs.com/xkc123/p/17381402.html

相关文章

  • Linux下面误删除文件使用extundelete工具恢复介绍
    1.使用rz命令上传extundelete-0.2.4.tar.bz2到/tmp文件夹下并解压软件。1[root@localhosttmp]#tar-jxvfextundelete-0.2.4.tar.bz22.进入到extundelete解压的目录下面,执行编译安装。1234567891011[root@localhost test]#cd/tmp[r......
  • linux环境部署--MySQL5.7二进制源码文件安装
    linux环境部署--MySQL5.7二进制源码文件安装mysql-5.7.11-Linux-glibc2.5-x86_64.tar提取码:1999MySQL5.7卸载1、将安装包解压到/usr/local/sudotarzxvfmysql-5.7.11-Linux-glibc2.5-x86_64.tar.gz-C/usr/local/2、解压后为了方便后面操作可把解压后文件名修改为mysql......
  • Shortcut of Chrome on Windows & Linux
    ShortcutofChromeonWindows&LinuxTab&windowshortcutsActionShortcutOpenanewwindowCtrl+nOpenanewwindowinIncognitomodeCtrl+Shift+nOpenanewtab,andjumptoitCtrl+tReopenpreviouslyclosedtabsinthe......
  • linux系统根目录下常见目录作用
    在Linux下一切皆文件,所有的文件都挂载在一个根文件上。一般有bin、boot、dev等目录。1.根文件内核启动后挂载的第一个文件系统2.bin存放系统的二进制命令(cd、ls、rm、mv)3.bootLinux内核和引导程序所需的目录4.lib/lib32/ilb64程序运行必要的链接库5.ect系统管理和维护方面的......
  • Linux - IO多路复用之select
    1.IO多路转接(复用) IO多路转接也称为IO多路复用,它是一种网络通信的手段(机制),通过这种方式可以同时监测多个文件描述符并且这个过程是阻塞的,一旦检测到有文件描述符就绪(可以读数据或者可以写数据)程序的阻塞就会被解除,之后就可以基于这些(一个或多个)就绪的文件描述符进行......
  • Linux - IO多路复用之epoll
    1.epoll概述epoll全称eventpoll,是linux内核实现IO多路转接/复用(IOmultiplexing)的一个实现。IO多路转接的意思是在一个操作里同时监听多个输入输出源,在其中一个或多个输入输出源可用的时候返回,然后对其的进行读写操作。epoll是select和poll的升级版,相较于这两个......
  • Linux - IO多路复用之poll
    1.poll函数poll的机制与select类似,与select在本质上没有多大差别,使用方法也类似,下面的是对于二者的对比:内核对应文件描述符的检测也是以线性的方式进行轮询,根据描述符的状态进行处理poll和select检测的文件描述符集合会在检测过程中频繁的进行用户区和内核区的拷贝,......
  • linux 中 xargs 中的 -i选项
     001、不使用-i选项[root@PC1test]#lsabvaabvbabvcabvddir1dir2dir3dir4dir5[root@PC1test]#ls|xargsmv{}{}.bak##不使用-i选项mv:cannotstat‘{}’:Nosuchfileordirectorymv:cannotstat‘{}.bak’:Nosuchfileordirecto......
  • 初次安装Linux 1Panel面板体验
    初次安装Linux1Panel面板体验1Panel是Linux下的一款服务器管理工具。和宝塔相比更加轻量化。相比之下各有优点,本文让我们一起来安装1Panel面板。面板优势快速建站 :深度集成WordPress和Halo,域名绑定、SSL证书配置等一键搞定高效管理 通过Web端轻松管理Linux......
  • linux 内核回收
    内核主要有4种LRU链表:enum lru_list{LRU_INACTIVE_ANON = LRU_BASE,LRU_ACTIVE_ANON = LRU_BASE + LRU_ACTIVE,LRU_INACTIVE_FILE = LRU_BASE + LRU_FILE,LRU_ACTIVE_FILE = LRU_BASE + LRU_FILE + LRU_ACTIVE,LRU_UNEVICTABLE,NR_LRU_LISTS};inactive......