Linux误删除文件的恢复操作

 

一、用运SecureCRT远程对操作系统上,查看一下当前系统版本号,及文件系统格式

 

[root@centos6 ~]# cat /etc/redhat-release 

CentOS release 6.8 (Final)

[root@centos6 ~]# cat /proc/version

Linux version 2.6.32-642.el6.x86_64 (mockbuild@worker1.bsys.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC) ) #1 SMP Tue May 10 17:27:01 UTC 2016

[root@centos6 ~]# uname -a

Linux centos6 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

[root@centos6 ~]# uname -r

2.6.32-642.el6.x86_64

 

二、为方便本次实验,我们新创建一文件。

[root@centos6 ~]# mkdir /example

[root@centos6 ~]# cd /example/

[root@centos6 example]# cat /proc/meminfo > web.txt

[root@centos6 example]# ll

total 4

-rw-r--r--. 1 root root 1198 Dec 25 05:35 web.txt

 

 

[root@centos6 example]# df /example/

Filesystem           1K-blocks    Used Available Use% Mounted on

/dev/mapper/vg_centos6-LogVol01

                      18971088 3484148  14516600  20% /

[root@centos6 example]# debugfs

debugfs 1.41.12 (17-May-2010)

debugfs:  open /dev/mapper/vg_centos6-LogVol01

debugfs:  ls -d /example/

 391720  (12) .    2  (12) ..    393297  (4072) web.txt   

debugfs:  quit

 

三、执行删除操作

[root@centos6 example]# rm -rf web.txt

 

四、打开,刚刚被删除文件所在的分区

 

[root@centos6 example]# df /example/

Filesystem           1K-blocks    Used Available Use% Mounted on

/dev/mapper/vg_centos6-LogVol01

                      18971088 3484148  14516600  20% /

 

 

五、用ls 加-d参数显示刚刚删除文件所在的目录

 

[root@centos6 example]# debugfs

debugfs 1.41.12 (17-May-2010)

debugfs:  open /dev/mapper/vg_centos6-LogVol01

debugfs:  ls -d /example/

 391720  (12) .    2  (4084) ..   <393297> (4072) web.txt  

 

六、显示有<>尖括号的就是我们要找的文件Inode 号 执行logdump –I  <19662057> 

debugfs:  logdump -i <393297>

Inode 393297 is at group 48, block 1572970, offset 2048

Journal starts at block 1, transaction 1746

No magic number at block 435: end of journal.

debugfs:  quit

 

七,执行完命令后,显示了一屏信息,我们需要的是下面这一行,并且要记住,后面的值

 

No magic number at block 435: end of journal.

debugfs:  quit

 

九、退出dedugfs

qiut

 

 

十,执行如下命令

 

 

[root@centos6 example]# dd if=/dev/mapper/vg_centos6-LogVol01 of=/example/web.txt bs=2048 count=1 skip=1572970

1+0 records in

1+0 records out

2048 bytes (2.0 kB) copied, 0.00769495 s, 266 kB/s


 

 

十一,以上结果表示恢复成功我们看下/example目录下到底有没有

 

[root@centos6 example]# ll /example/

total 4

-rw-r--r--. 1 root root 2048 Dec 25 05:52 web.txt


 

 

————————————————————————————————————————————————————————

centos7不管用

一、用运SecureCRT远程对操作系统上,查看一下当前系统版本号,及文件系统格式

[root@sheng ~]# cat /etc/redhat-release 

CentOS Linux release 7.4.1708 (Core) 

[root@sheng ~]# cat /proc/version

Linux version 3.10.0-693.5.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Fri Oct 20 20:32:50 UTC 2017

[root@sheng ~]# uname -a

Linux sheng 3.10.0-693.5.2.el7.x86_64 #1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

[root@sheng ~]# uname -r

二、为方便本次实验,我们新创建一文件。

[root@sheng ~]# mkdir example

[root@sheng ~]# cd example/

[root@sheng example]# cat /proc/meminfo > web.txt

[root@sheng example]# ll

total 4

-rw-r--r--. 1 root root 1226 Dec 25 10:03 web.txt

 

[root@sheng example]# ls

web.txt

三、执行删除操作

[root@sheng example]# rm -rf web.txt 

 

四、打开,刚刚被删除文件所在的分区

*****************************************************************************************

查看目录在分区

 

[root@sheng example]# df /root/example

Filesystem          1K-blocks     Used Available Use% Mounted on

/dev/mapper/cl-root  18855936 11376924   7479012  61% /

******************************************************************************************
 

四、运用,系统自还工具debugfs来修复

[root@sheng example]# debugfs

debugfs 1.42.9 (28-Dec-2013)

debugfs:  open /dev/mapper/cl-root

/dev/mapper/cl-root: Bad magic number in super-block while opening filesystem

 

[root@sheng example]# df -Th

Filesystem          Type      Size  Used Avail Use% Mounted on

/dev/mapper/cl-root xfs        18G   11G  7.2G  61% /

.....

不支持xfs文件格式的恢复

 

CentOS7使用Extundelete恢复误删除的文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值