使用 extundelete 恢复rm误操作

  • 系统:CentOS 7
  • 文件系统:EXT4

今天 YCHEUNG 不小心用 rm 命令误删了一个名字奇奇怪怪的文件,因为名字太奇怪想不起来它是啥,怕是重要文件,所以急急忙忙去找办法恢复。

随手一找就看到可以用 linux 自带的文件恢复工具 debugfs 来进行恢复,但是只能恢复 ext2 文件系统的文件.... 于是 YCHEUNG 用 mount 命令查看了一下,文件系统是 ext4 的...呵呵呵呵.....orz.....

然后看到有人说比较便利的方法是用 extundelete 工具,它可以直接用 yum install extundelete 安装,也可以参照官网的说明编译安装。

恢复文件前先让主机offline哦~

一个简单的命令: $extundelete --restore-directory /var/aaa/ -o /var/bbb/restore /dev/xvda 第一个文件路径是你误删的文件所在文件夹,第二个路径被恢复的文件存放路径, 第三个是设备名。

$extundelete --restore-directory /var/aaa/ -o /var/bbb/restore /dev/xvda


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) 

最后,由于想起来那个文件是什么,也就没继续尝试下去。

以后要慎用 rm 命令了,呜呜呜~

Y Cheung

Y Cheung

Blogger, Programer & Traveler.
Shanghai