Linux下刪除的文件如何恢復


Linux下刪除的文件如何恢復
參考自:
[1]linux下誤操作刪除文件如何恢復
[2]Linux實現刪除撤回的方法
以/home/test.txt為例
1、df -T 文件夾 找到當前文件所在磁盤分區

df -T /home
Filesystem     Type     1K-blocks     Used Available Use% Mounted on
/dev/sda1      ext4      40251776 22367924  15839180  59% /

2、切換到管理員用戶

su

3、使用debugfs工具修復刪除的文件

#進入debugfs
debugfs
#打開文件分區
open /dev/sda1
#查看當前文件夾下可以恢復的所有文件列表
ls -d /home

2171092  (12) .    2107347  (12) ..    2136755  (20) openfile.c   
2136636  (20) write_test.c    2140733  (16) write    2159955  (20) pid.c   
2140780  (20) test.txt    2140768  (16) pid    2143056  (20) file2.txt   
2097430  (3940) a.out   <2165564> (3916) pthread_test.c~ 
#找到對應的參數帶入命令
logdump -i <2140780>

Inode 2165564 is at group 264, block 8392825, offset 3456
Journal starts at block 14, transaction 948674
No magic number at block 7828: end of journal.
退出debugfs,開始恢復文件
quit

4、恢復文件

dd if=/dev/sda1 of=/home/test.txt bs=3456 count=1 skip=8392825


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM