Bootstrap

Linux系统:第十三章:centos误删文件如何恢复文件数据

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Linux运维全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上运维知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip1024b (备注运维)
img

正文

提示:这里主要介绍centos误删文件如何恢复文件数据的情况,视频以xfs为例,博文会讲解xfs和ext4分区类型。


提示:以下是本篇文章正文内容,下面案例可供参考

一、查看分区类型

=====================================================================

我们创建的centos对应的每个分区都有不同类型,可以通过以下命令进行查看,不同的分区类型恢复的命令也不相同,本文以xfs分区为例,作为演示,附带视频讲解。

df -T

xfs分区

在这里插入图片描述

ext4分区

在这里插入图片描述

二、使用centos7软件恢复工具extundelete作为文件恢复

===============================================================================================

1.安装extundelete


下载依赖包:

yum install e2fsprogs-devel e2fsprogs e2fsprogs-libs


2.上传extundelete安装包到自定义目录下面


百度网盘链接:https://pan.baidu.com/s/1UNS3TJxmnSuDWeI1sgarLQ

提取码:d9sb

这里我是去到/usr/local目录下面创建了一个software的目录,将安装包通过WinSCP上传上去了


3.解压安装包


在/usr/local/software目录下解压安装包

tar -jxvf extundelete-0.2.4.tar.bz2


4.进到解压后的安装包目录下面执行命令


yum -y install gcc

yum -y install gcc-c++

cd extundelete-0.2.4

./configure

make

make install

which extundelete


5.创建data目录和deletefile文件


cd /

mkdir /data

cd /data

touch deletefile


6.(xfs分区的)


备份命令

xfsdump -f /tmp/dump_data /data

-> dump_data

-> media0

出现这个xfsdump: Dump Status: SUCCESS说明备份成功了

6.(ext4分区的)


查看删除目录

/usr/local/bin/extundelete --inode 2 /dev/sda2

NOTICE: Extended attributes are not restored.

WARNING: EXT3_FEATURE_INCOMPAT_RECOVER is set.

The partition should be unmounted to undelete any files without further data loss.

If the partition is not currently mounted, this message indicates

it was improperly unmounted, and you should run fsck before continuing.

If you decide to continue, extundelete may overwrite some of the deleted

files and make recovering those files impossible. You should unmount the

file system and check it with fsck before using extundelete.

Would you like to continue? (y/n)

y

Loading filesystem metadata … 285 groups loaded.

Group: 0

Contents of inode 2:

0000 | 6d 41 00 00 00 10 00 00 e2 b2 6a 61 66 b2 6a 61 | mA…jaf.ja

0010 | 66 b2 6a 61 00 00 00 00 00 00 13 00 08 00 00 00 | f.ja…

0020 | 00 00 08 00 22 00 00 00 0a f3 01 00 04 00 00 00 | …"…

0030 | 00 00 00 00 00 00 00 00 01 00 00 00 26 24 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 | …

0080 | 1c 00 00 00 d0 7f eb 7d d0 7f eb 7d 00 53 f7 34 | …}…}.S.4

0090 | a2 be 68 61 00 00 00 00 00 00 00 00 00 00 02 ea | …ha…

00a0 | 07 06 44 00 00 00 00 00 1c 00 00 00 00 00 00 00 | …D…

00b0 | 73 65 6c 69 6e 75 78 00 00 00 00 00 00 00 00 00 | selinux…

00c0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | …

00d0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | …

00e0 | 00 00 00 00 73 79 73 74 65 6d 5f 75 3a 6f 62 6a | …system_u:obj

00f0 | 65 63 74 5f 72 3a 72 6f 6f 74 5f 74 3a 73 30 00 | ect_r:root_t:s0.

Inode is Allocated

File mode: 16749

Low 16 bits of Owner Uid: 0

Size in bytes: 4096

Access time: 1634382562

Creation time: 1634382438

Modification time: 1634382438

Deletion Time: 0

Low 16 bits of Group Id: 0

Links count: 19

Blocks count: 8

File flags: 524288

File version (for NFS): 0

File ACL: 0

Directory ACL: 0

Fragment address: 0

Direct blocks: 127754, 4, 0, 0, 1, 9254, 0, 0, 0, 0, 0, 0

Indirect block: 0

Double indirect block: 0

Triple indirect block: 0

File name | Inode number | Deleted status

. 2

… 2

lost+found 11

boot 2097153

dev 1179649

proc 1835009

run 1966081

sys 131073

etc 1310721

root 1441793

tmp 262145

var 393217

data 1048577

usr 1572865

bin 17

sbin 16

lib 13

lib64 15

home 524289

media 1703937

mnt 655361

opt 786433

srv 917505

可以找到data 1048577

/usr/local/bin/extundelete --inode 1048577 /dev/sda2

NOTICE: Extended attributes are not restored.

WARNING: EXT3_FEATURE_INCOMPAT_RECOVER is set.

The partition should be unmounted to undelete any files without further data loss.

If the partition is not currently mounted, this message indicates

it was improperly unmounted, and you should run fsck before continuing.

If you decide to continue, extundelete may overwrite some of the deleted

files and make recovering those files impossible. You should unmount the

file system and check it with fsck before using extundelete.

Would you like to continue? (y/n)

y

Loading filesystem metadata … 285 groups loaded.

Group: 128

Contents of inode 1048577:

0000 | ed 41 00 00 00 10 00 00 98 b3 6a 61 88 b3 6a 61 | .A…ja…ja

0010 | 88 b3 6a 61 00 00 00 00 00 00 03 00 08 00 00 00 | …ja…

0020 | 00 00 08 00 06 00 00 00 0a f3 01 00 04 00 00 00 | …

0030 | 00 00 00 00 00 00 00 00 01 00 00 00 20 20 40 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 1c 85 44 00 00 00 00 00 00 00 00 | …D…

0070 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | …

0080 | 1c 00 00 00 00 08 6b d0 00 08 6b d0 14 06 2c a7 | …k…k…,.

0090 | 66 b2 6a 61 d0 76 ae 7d 00 00 00 00 00 00 02 ea | f.ja.v.}…

00a0 | 07 06 3c 00 00 00 00 00 23 00 00 00 00 00 00 00 | …<…#…

00b0 | 73 65 6c 69 6e 75 78 00 00 00 00 00 00 00 00 00 | selinux…

00c0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | …

00d0 | 00 00 00 00 00 00 00 00 00 00 00 00 75 6e 63 6f | …unco

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注运维)
img

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
6e 75 78 00 00 00 00 00 00 00 00 00 | selinux…

00c0 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | …

00d0 | 00 00 00 00 00 00 00 00 00 00 00 00 75 6e 63 6f | …unco

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注运维)
[外链图片转存中…(img-D74cZLYX-1713373132525)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

悦读

道可道,非常道;名可名,非常名。 无名,天地之始,有名,万物之母。 故常无欲,以观其妙,常有欲,以观其徼。 此两者,同出而异名,同谓之玄,玄之又玄,众妙之门。

;