今天突然想到要测试下文件恢复,网上看到很多人用一款ext3grep的软件,下下来使用后发现 效果不佳,只能恢复小文件,不能恢复目录。后来又找到一款名叫extundelete的软件,使用后发现不错,官网据说还能恢复ext4文件系统下的文件
以下是实验记录:
[root@localhost tmp]# cd /boot[root@localhost boot]# mount -o remount,rw /boot[root@localhost boot]# ll总计 10795-rw-r--r-- 1 root root 12288 2021年05月15日 config-2。6。2021年05月15日8。el5drwxr-xr-x 2 root root 1024 2021年05月15日 01:49 grubdrwxr-xr-x 2 root root 1024 2021年05月15日 01:57 grub_bak-rw------- 1 root root 3383766 2021年05月15日 17:09 initrd-2。6。2021年05月15日8。el5。imgdrwx------ 2 root root 12288 2021年05月15日 16:52 lost+found-rw-r--r-- 1 root root 80032 2021年05月15日 messagedrwxr-xr-x 2 root root 1024 2021年05月15日 01:53 mynewkernel-rw-r--r-- 1 root root 102182 2021年05月15日 02:11 symvers-2。
6。2021年05月15日8。el5。gz_bak-rw-r--r-- 1 root root 年05月15日 23:45 System。map-rw-r--r-- 1 root root 年05月15日 System。map-2。6。2021年05月15日8。el5-rw-r--r-- 1 root root 年05月15日 vmlinuz-2。6。2021年05月15日8。el5-rw-r--r-- 1 root root 2538768 2021年05月15日 01:50 vmlinuz-2。6。38。6[root@localhost boot]# rm -rf config-2。6。2021年05月15日8。el5[root@localhost boot]# sync确定删除了config-2。6。2021年05月15日8。el5 文件[root@localhost boot]# mount -o remount,ro /boot为了安全,把要恢复的分区挂载为只读extundelete的下载与安装就不写说来了现在开始恢复cd /tmp[root@localhost tmp]# /usr/local/extundelete/bin/extundelete /dev/sda1 --ls --inode 2#先用命令检索下分区下文件File name | Inode number | Deleted statusDirectory block 512:。
2。。 2lost+found 11grub 10041System。map 18message 12initrd-2。6。2021年05月15日8。el5。img 17System。map-2。6。2021年05月15日8。el5 13config-2。6。2021年05月15日8。el5 14 Deletedsymvers-2。6。2021年05月15日8。el5。gz 15 Deletedvmlinuz-2。6。2021年05月15日8。el5 16grub_bak 8033mynewkernel 4017vmlinuz-2。6。38。6 4018symvers-2。6。2021年05月15日8。el5。gz_bak 19[root@localhost tmp]# /usr/local/extundelete/bin/extundelete /dev/sda1 --restore-file config-2。6。2021年05月15日8。el5WARNING: Extended attributes are not restored。Loading filesystem metadata 。
。。 13 groups loaded。Loading journal descriptors 。。。 410 descriptors loaded。Writing output to directory RECOVERED_FILES/Restored inode 14 to file RECOVERED_FILES/config-2。6。2021年05月15日8。el5
去文件夹下的RECOVERED目录下看看[root@localhost tmp]# ll RECOVERED_FILES/总计 12-rw-r--r-- 1 root root 12288 2021年05月15日 02:25 config-2.6.2021年05月15日8.el5
文件恢复成功 !
补充:
extundelete是唯一一款能恢复lvm(逻辑卷管理)的 软件,恢复步骤是一样的node.js安装linux,恢复文件夹的话用选项--restore-all 在linux+centos5.3+lvm上恢复50M的文件夹成功。
另外要注意的是linux恢复被删除的文件linux中文乱码,文件恢复后但文件的权限可能不同了,软连接可能也不同,我试验了恢复了软连接的时候恢复到了源文件。
本文转自hb_fukua 51CTO博客linux恢复被删除的文件,原文链接:年05月15日5095,如需转载请自行联系原作者