linux系統沒有像windows那樣的回收站,但誤刪文件并非完全無法恢復。本文介紹幾種linux下恢復誤刪文件的方法,請注意,恢復成功率并非100%,操作前務必停止對目標分區的所有寫入操作。
extundelete專用于恢復ext3和ext4文件系統中的刪除文件,利用文件系統日志信息進行恢復。
安裝:
centos: yum install extundelete
Debian: apt-get install extundelete
使用方法:
恢復單個目錄:extundelete /dev/vdb1 –restore-Directory /path/to/directory
恢復單個文件:extundelete /dev/vdb1 –restore-file /path/to/file
恢復所有刪除文件:extundelete /dev/vdb1 –restore-all (謹慎使用)
方法二:lsof命令
lsof命令列出被進程打開的文件。如果刪除的文件仍在被進程使用,lsof可能幫助恢復。
使用方法:
lsof | grep deleted
根據輸出結果手動恢復文件。
方法三:其他數據恢復工具
除了extundelete,foremost、testdisk、photorec等工具也可能有效。
foremost示例 (恢復png文件): foremost -t png -i /dev/sdb1
testdisk用于分區恢復: testdisk
重要提示:
- 立即停止對目標分區的寫入操作,防止數據被覆蓋。
- 數據恢復成功率無法保證,建議定期備份重要數據。
- 使用任何恢復工具前,請仔細閱讀其使用說明。
- 數據恢復復雜,如有疑問,請尋求專業人士幫助。
記住,數據恢復并非易事,操作前請謹慎,并做好充分的準備工作。