Linux 系統下誤刪重要檔案時,ext3grep 是針對 ext3/ext4 檔案系統的強力復原工具。本文完整記錄從安裝、建立測試分區、模擬刪除到實際掃描復原的完整流程,並附上關鍵參數說明,助你在災難發生時冷靜應對。

ext3grep-0.10.2.tar.gztar zxvf ext3grep-0.10.2.tar.gz
cd ext3grep-0.10.2
./configure --prefix=/usr/local/ext3grep
make && make install
安裝完成後,執行檔位於 /usr/local/ext3grep/bin/ext3grep。
| 類別 | 參數 | 用途 |
|---|---|---|
| 動作 | --ls | 列出目錄項目(單行顯示),常搭配過濾器使用 |
--restore-file | 依檔名復原指定檔案 | |
--restore-all | 嘗試復原所有已刪除檔案 | |
| 過濾 | --deleted | 僅處理已刪除的 inode |
--after | 僅處理指定時間後刪除的項目 | |
--before | 僅處理指定時間前刪除的項目 | |
--group | 僅處理特定區組 |
mkdir /tmp/test
dd if=/dev/zero of=file count=102400
mkfs.ext3 file
mount -o loop /tmp/test/file /mnt
cd /mnt
mkdir del && cd del
touch 1 2 3
cd ..
rm -rf del
cd /usr/local/ext3grep/bin
# 掃描根目錄 inode (通常為 2)
./ext3grep /tmp/test/file --ls --inode 2
# 依 inode 復原特定目錄
./ext3grep /tmp/test/file --restore-inode 1234
# 或全盤復原所有已刪除檔案
./ext3grep /tmp/test/file --restore-all
dd 製作完整磁碟映像,在映像檔上操作復原。掌握 ext3grep 基本操作,能在誤刪事故發生時爭取寶貴復原時間。建議平時在測試環境演練流程,真正遇到故障時才能得心應手。