可以先看看文件数据状态:

debugfs:stat

Inode: 196829 Type: regular Mode: 0644 Flags: 0x0 Version: 1

User: 0 Group: 0 Size: 149500

File ACL: 0 Directory ACL: 0

Links: 0 Blockcount: 38

Fragment: Address: 0 Number: 0 Size: 0

ctime: 0x31a9a574 -- Mon May 27 13:52:04 2001

atime: 0x31a21dd1 -- Tue May 21 20:47:29 2001

mtime: 0x313bf4d7 -- Tue Mar 5 08:01:27 2001

dtime: 0x31a9a574 -- Mon May 27 13:52:04 2001

BLOCKS:

594810 594811 594814 594815 594816 594817 ………………………………….

TOTAL: 38

然后就可以用dump指令恢复文件:

debugfs:dump /mnt/hda/01.sav

这样就把文件恢复出来了。退出debugfs:

debugfs:quit

另一种方法是手工编辑inode:

debugfs:mi

Mode [0100644]

User ID [0]

Group ID [0]

Size [149500]

Creation time [0x31a9a574]

Modification time [0x31a9a574]

Access time [0x31a21dd1]

Deletion time [0x31a9a574] 0

Link count [0] 1

Block count [38]

File flags [0x0]

Reserved1 [0]

File acl [0]

Directory acl [0]

Fragment address [0]

Fragment number [0]

Fragment size [0]

Direct Block #0 [594810]

…………………………….

Triple Indirect Block [0]

使用mi指令后每次显示一行信息以供编辑,其它行可以直接按回车表示确认,把deletion time改成0(未删除),Link count改成1。改好后退出debugfs:

debugfs:quit

然后用fsck检查/dev/hda5

fsck /dev/hda5

程序会说找到丢失的数据块,放在lost+found里面。


相关内容