close

又一次把code給rm -rf..
這次不是我的錯啊..
唉..沒備份,說什麼都沒用..
還是恭喜獲得刪錯檔VIP一枚....


救檔程序:
1. 關機或umount檔案所在partition,免得rw造成新東西覆蓋過舊檔,真的會欲救無力..
2. 努力懊惱..評估[重生file] vs [救file]的經濟效益..
3. 使用tools,或是使用手動.

--------------------------------------------------------------------------------

基本上:
ext2上的檔案都還好,可是如果是非ext2上的檔案..查G大神,得到的答案幾乎都是,加油吧..= ="

Q: How can I recover (undelete) deleted files from my ext3 partition?
Actually, you can't! This is what one of the developers, Andreas Dilger, said about it:
In order to ensure that ext3 can safely resume an unlink after a crash, it actually zeros out the block pointers in the inode, whereas
ext2 just marks these blocks as unused in the block bitmaps and marks the inode as "deleted" and leaves the block pointers alone.

Your only hope is to "grep" for parts of your files that have been deleted and hope for the best.

--------------------------------------------------------------------------------

tools
-
[R-Studio] [FinalData]

很方便,會把所有東西都用目錄的方式列出來...也都號稱支援NTFS,ext2,ext3...file system,
屬於利用掃描磁碟的方式,所以時間上都有一定程度的久啊~~
這次使用的經驗是:
FinalData:找不到linux的partition..只搜尋到NTFS的..
R-Studio:找不到ext3上我要救的檔案,但是ext3上其他刪掉的卻都看得到..
呼...使用tools真的是一切都要看機運啊..
當然還有其他的tools,可是這兩個是曾經用過還不錯用...也懶得再去試機運了..

--------------------------------------------------------------------------------

手動
-
ext2:
[root@aaa root]# debugfs /dev/hda3
*/dev/hda3 == 錯刪的檔案所在分割區

debugfs:lsdel
*列出被刪除的檔案清單

Inode  Owner  Mode  Size  Blocks  Time deleted
*inode編號,檔案所有者,檔案權限設定,檔案大小,檔案使用的區塊數,被刪除的時間

debugfs:stat<15>
*列出inode編號15的狀態

debugfs:dump<15> /home/test/test.txt
*將inode編號15所指的檔案,儲存為/home/test下的test.txt

debugfs:quit
*離開debugfs

最後查看看檔案內容,如果內容不符,就表示區塊已經被其他檔案拿去用勒,救不回來了..
請節哀..

--------------------------------------------------------------------------------

手動
-
如ext3..其他Linux file system(只能救文字類檔):

利用grep和關鍵字搜尋
[root@aaa root]# grep -a -B100 -A100 'This is delete file' /dev/hda2 > /home/test/test.txt
*-a 將分割區視為文字檔掃描
*-B100 找到關鍵字後,顯示前100行的資料
*-A100 找到關鍵字後,顯示後100行的資料
*'This is delete file' 關鍵字
*/dev/hda2 檔案所在分割區
*/home/test/test.txt 儲存到/home/test/下的test.txt

這種方法要先知道檔案內的關鍵字和檔案可能大小..
而且,如果檔案所在的區塊不連續,就要利用不同的關鍵字搜尋..
然後把找到的東西,開始做剪貼拼湊的動作....真的很麻煩就是了...
可是這次.,就是多虧了這個方法,才把code給救回來...>.<....雖然搞很久...哈..



利用strings搜尋
[root@aaa root]# strings /dve/hda2 > /home/test/test.txt
*把/dev/hda2下所有能用文字模式印出的東西通通存到/home/test/test.txt一個檔案裡

再用搜尋,刪減的方式,擷出要的部份..
這種方法..要有夠大的另一個patition好存data..最好也要知道關鍵字,比較好找要的那一段啦..

--------------------------------------------------------------------------------

幾次的深深體會..
要嘛勤做備份...
要嘛就請不要在晃神的狀態下操作重要的東西...
重要重要啊~~







arrow
arrow
    全站熱搜

    bcli 發表在 痞客邦 留言(2) 人氣()