今天突然想到要測試下文件恢復,網上看到很多人用一款ext3grep的軟件,下下來使用後發現 效果不佳,只能恢復小文件,不能恢復目錄。後來又找到一款名叫extundelete的軟件,使用後發現不錯,官網據說還能恢復ext4文件系統下的文件
以下是實驗記錄:
[root@localhost tmp]# cd /boot
[root@localhost boot]# mount -o remount,rw /boot
[root@localhost boot]# ll
總計 10795
-rw-r--r-- 1 root root 12288 2009-01-22 config-2.6.18-128.el5
drwxr-xr-x 2 root root 1024 05-13 01:49 grub
drwxr-xr-x 2 root root 1024 05-12 01:57 grub_bak
-rw------- 1 root root 3383766 02-24 17:09 initrd-2.6.18-128.el5.img
drwx------ 2 root root 12288 02-24 16:52 lost+found
-rw-r--r-- 1 root root 80032 2009-03-17 message
drwxr-xr-x 2 root root 1024 05-12 01:53 mynewkernel
-rw-r--r-- 1 root root 102182 05-13 02:11 symvers-2.6.18-128.el5.gz_bak
-rw-r--r-- 1 root root 1784432 05-11 23:45 System.map
-rw-r--r-- 1 root root 1188481 2009-01-22 System.map-2.6.18-128.el5
-rw-r--r-- 1 root root 1889308 2009-01-22 vmlinuz-2.6.18-128.el5
-rw-r--r-- 1 root root 2538768 05-12 01:50 vmlinuz-2.6.38.6
[root@localhost boot]# rm -rf config-2.6.18-128.el5
[root@localhost boot]# sync
確定刪除了config-2.6.18-128.el5 文件
[root@localhost boot]# mount -o remount,ro /boot
為了安全,把要恢復的分區掛載為只讀
extundelete的下載與安裝就不寫說來了
現在開始恢復
cd /tmp
[root@localhost tmp]# /usr/local/extundelete/bin/extundelete /dev/sda1 --ls --inode 2
#先用命令檢索下分區下文件
File name | Inode number | Deleted status
Directory block 512:
. 2
.. 2
lost+found 11
grub 10041
System.map 18
message 12
initrd-2.6.18-128.el5.img 17
System.map-2.6.18-128.el5 13
config-2.6.18-128.el5 14 Deleted
symvers-2.6.18-128.el5.gz 15 Deleted
vmlinuz-2.6.18-128.el5 16
grub_bak 8033
mynewkernel 4017
vmlinuz-2.6.38.6 4018
symvers-2.6.18-128.el5.gz_bak 19
[root@localhost tmp]# /usr/local/extundelete/bin/extundelete /dev/sda1 --restore-file config-2.6.18-128.el5
WARNING: Extended attributes are not restored.
Loading filesystem metadata ... 13 groups loaded.
Loading journal descriptors ... 410 descriptors loaded.
Writing output to directory RECOVERED_FILES/
Restored inode 14 to file RECOVERED_FILES/config-2.6.18-128.el5
去文件夾下的RECOVERED目錄下看看
[root@localhost tmp]# ll RECOVERED_FILES/
總計 12
-rw-r--r-- 1 root root 12288 05-13 02:25 config-2.6.18-128.el5
文件恢復成功 !