Translated message

A translation of this page exists in English.

ext3 ファイルシステムで削除したファイルを復元する

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux
  • ext3 ファイルシステム

Issue

  • ext3 ファイルシステムで削除したファイルを復元する方法は?

Resolution


免責条項: この情報は Red Hat 社が提供していますが、Service Level Agreements および support coverage の適用外となります。提供している情報は保証されていないため、この記事の情報を基に構成した設定やインストールしたアプリケーションは、Red Hat グローバルサポートサービスのサポート適用外となります。このナレッジの目的は、システムのニーズを達成するための情報を提供することです。このナレッジの情報は、お客様の責任のもと使用してください。

以下の手順は、ext3 ファイルシステムで削除されたファイルの復元方法について示しています。

1. テストファイルを作成します。

[root@dsmaster home]# touch test.txt
[root@dsmaster home]# cat test.txt 
this is a test file

2. このテストファイルの i-node を確認します。

[root@dsmaster home]# ll -li test.txt 
579917 -rw-r--r-- 1 root root 20 Feb  3 02:52 test.txt

テストファイルの i-node は 579917 です。

3. このファイルのデータのブロックを確認します。

[root@dsmaster home]# debugfs -w /dev/hda3
debugfs 1.39 (29-May-2006)
debugfs:logdump -i <579917>

    (inode block for inode 579917):
    Inode:579917   Type: regular        Mode:0644   Flags:0x0   Generation:2914279254
    User:     0   Group:     0   Size:20
    File ACL:603590    Directory ACL:0
    Links:1   Blockcount:16
    Fragment:Address:0    Number:0    Size:0
    ctime:0x4b68746c -- Wed Feb  3 02:52:28 2010
    atime:0x4b687485 -- Wed Feb  3 02:52:53 2010
    mtime:0x4b68746c -- Wed Feb  3 02:52:28 2010
    Blocks:(0+1):619053 

以下の行を確認します。

    Blocks:(0+1):619053 

このテストファイルのデータのブロックは 619053 です。

4. このテストファイルを削除します。

[root@dsmaster home]# rm test.txt 
rm: remove regular file `test.txt'? y

5. 削除したテストファイルを復元します。

[root@dsmaster home]# dd if=/dev/hda3 of=/tmp/test.txt bs=4096 count=1 skip=619053
1+0 records in
1+0 records out
4096 bytes (4.1 kB) copied, 0.0010089 seconds, 4.1 MB/s

6. テストファイルの内容を確認します。

[root@dsmaster home]# cat /tmp/test.txt 
this is a test file

注意:

システムを再起動すると、削除したファイルのジャーナルは見つからず、削除したファイルを復元できませんでした。

したがって、削除したファイルを復元したい場合は、ファイルを削除した後にシステムを再起動しないようにしてください。

ext2 ファイルシステムで削除したファイルを復元する方法については、Can I recover a deleted file on ext2 file system? を参照してください。

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments