误删之后 不要操作别的 首先卸载或者把这个改成只读的权限添加磁盘并分区,并且挂在
[root@localhost ~]# fdisk -l
[root@localhost ~]# fdisk /dev/sdb
[root@localhost ~]# mkfs.ext4 /dev/sdb1
[root@localhost ~]# mkdir mazhi
[root@localhost ~]# mount /dev/sdb1 mazhi/
1.上传工具包并且解压
[root@localhost ~]# rz extundelete-0.2.4.tar.bz2
[root@localhost ~]# tar xf extundelete-0.2.4.tar.bz2
2.yum安装所需配置文件
[root@localhost ~]# yum -y install gcc* e2fs*
3.进入extundelete开始安装
[root@localhost ~]# cd extundelete-0.2.4
[root@localhost extundelete-0.2.4]# ./configure
Configuring extundelete 0.2.4
Writing generated files to disk
[root@localhost extundelete-0.2.4]# make -j 4
[root@localhost extundelete-0.2.4]# make install
4.错误删除文件(进入自己创的文件夹内测试)
[root@localhost ~]# cd mazhi/
[root@localhost mazhi]# cp /etc/passwd /root/mazhi/
[root@localhost mazhi]# cp /etc/shadow /root/mazhi/
[root@localhost mazhi]# ls
lost+found passwd shadow
[root@localhost mazhi]# rm -rf ./*
[root@localhost mazhi]# ls
5.恢复文件
[root@localhost mazhi] cd
[root@localhost ~]# umount /dev/sdb1 mazhi/
[root@localhost ~]# cd mazhi/
[root@localhost mazhi]# ls
[root@localhost mazhi] extundelete /dev/sdb1 --inode 2#查看所有删除的inode号
File name | Inode number | Deleted status
. 2
.. 2
lost+found 11 Deleted
passwd 12 Deleted
shadow 13 Deleted
[root@localhost mazhi] extundelete /dev/sdb1 --restore-inode 12 通过inode号恢复数据
[root@localhost mazhi] extundelete /dev/sdb1 --restore-file passwod 通过file文件恢复
[root@localhost mazhi] extundelete /dev/sdb1 --restore-directory a 通过目录恢复
[root@localhost mazhi] extundelete /dev/sdb1 --restore-all 恢复全部删除文件
[root@localhost mazhi]# cd RECOVERED_FILES/
[root@localhost RECOVERED_FILES]# ls
passwd shadow