安装extundelete ,安装方法参照 http://www.kuaiwenba.com/article/173.html

编译安装

 ./configure
Configuring extundelete 0.2.0
configure: error: Can't find ext2fs library

要安装相关依赖库 yum install e2fsprogs* e2fslibs* -y

 

 

make又报错

/usr/bin/ld: extundelete: undefined reference to symbol ‘__pthread_key_create@@GLIBC_2.2.5’
/usr/bin/ld: note: ‘__pthread_key_create@@GLIBC_2.2.5’ is defined in DSO /lib64/libpthread.so.0 so try adding it to the linker command line

解决方法见 http://www.caojunfei.com/?p=3582

 

安装好后运行

extundelete  /dev/sda3 –inode 2

会报下面错误

/usr/local/extundelete/bin/extundelete: Bad magic number in super-block when trying to open filesystem /dev/sda3

悲剧,网上搜了下,lvm是有区别的,见 https://diogomonica.com/2012/08/05/raising-the-dead-undeleting-files-in-ext4/

主要是lvm的设备名不是/dev/sda的形式了vgscan查看具体的卷名。最后发现我的卷名是/dev/vg_centosdesktop/lv_root,好了,现在就可以恢复了

运行以下命令恢复单个文件

/usr/local/extundelete/bin/extundelete  /dev/vg_centosdesktop/lv_root  –restore-file  /root/down/php-5.5.17/ext/C/C.c

 

恢复一个目录命令

/usr/local/extundelete/bin/extundelete  /dev/vg_centosdesktop/lv_root  –restore-directory /root/down/php-5.5.17/ext/C

 

全部搞定了,以后再不也不怕rm  -rf 了

Comments are closed.

Post Navigation