数据恢复
场景:用于rm -rf 误删除的文件
先添加一块硬盘sdb
fdisk /dev/sdb
格式化
mkfs -t ext3 /dev/sdb
创建挂载点目录
mkdir -p /tmp/sdb1
挂载
mount /dev/sdb /tmp/sdb1
创建测试数据
cp /etc/passwd /tmp/sdb1/
cp /etc/hosts /tmp/sdb1/
mkdir -p /tmp/sdb1/a/b/c
cp a.txt /tmp/sdb1//a/
echo "aaa" > a.txt
cp a.txt /tmp/sdb1//a/
cp a.txt /tmp/sdb1//a/b/
touch /tmp/sdb1/a/b/kong.txt
rm -rf a/ hosts passwd
取消挂载
umount /dev/sdb1
使用extundelete工具
1.上传
2.解压
tar jxf extundelete-0.2.4.tar.bz2
3.配置,编译,安装
./configure && make && make install
检索误删除的数据
extundelete /dev/sdb --inode 2
四种恢复方式
1.inode节点恢复
extundelete /dev/sdb --restore-inode 12
2.文件名恢复
extundelete /dev/sdb --restore-file hosts
3.恢复目录
extundelete /dev/sdb --restore-directory a
4.恢复所有
extundelete /dev/sdb --restore-all
对比数据
diff /etc/passwd file.12
恢复的数据在
extundelete /dev/sdb --restore-all
对比数据
diff /etc/passwd file.12
恢复的数据在