centos6上误删除了文件怎样恢复?

centos6上误删除了文件怎样恢复?

  • 创建一个新磁盘 /dev/sdb,创建分区 /dev/sdb1,格式化,挂载到 /tmp/sdb1上

  • 模拟环境
mkdir /tmp/sdb1
cp /etc/passwd /tmp/sdb1/
cp /etc/hosts /tmp/sdb1/
mkdir -p /tmp/sdb1/a/b/c
echo aaa > /tmp/sdb1/a.txt
echo bbb > /tmp/sdb1/a/b/b.txt
touch /tmp/sdb1/a/b/kong.txt
cd /tmp/sdb1/
rm -rf a a.txt hosts passwd
  • 安装 extundelete
yum install e2fsprogs-devel -y
cd /usr/local/src/
wget https://sourceforge.net/projects/extundelete/files/latest/download/extundelete-0.2.4.tar.bz2
tar jxvf extundelete-0.2.4.tar.bz2
cd extundelete-0.2.4
yum install gcc-c++ -y
./configure --prefix=/usr/local/extundelete && make && make install
  • 卸载 /tmp/sdb1
umount /tmp/sdb1/
  • 查看删除掉的文件
/usr/local/extundelete/bin/extundelete /dev/sdb1/ --inode 2
  • 恢复所有
/usr/local/extundelete/bin/extundelete /dev/sdb1 --restore-all

常用选项

/usr/local/extundelete/bin/extundelete /dev/sdb1 --restore-inode 12
/usr/local/extundelete/bin/extundelete /dev/sdb1 --restore-file passwd
/usr/local/extundelete/bin/extundelete /dev/sdb1 --restore-directory a

查看 extundelete 的帮助信息

/usr/local/extundelete/bin/extundelete -h

转载于:https://blog.51cto.com/13480443/2105088

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值