アフィリエイト広告を利用しています

広告

posted by fanblog

e2image




e2imageコマンドはe2fsprogsに含まているコマンドで、メタデータをファイルに書き出します。
ext2,ext3,ext4共通で利用出来ます。(kenrel: 2.6.39-rc1 e2fsprogs: 1.41.12)

e2image - ファイルシステムのメタデータをファイルに保存する


e2image [ -rsI ] device image-file

-r 通常のイメージファイルのかわりにraw imageファイルを作成する
raw imageファイルは通常のimageファイルとは2点異なる
1)メタデータが適切なオフセットに配置されることで
e2fsck, dumpe2fs, debugfsなどが直接実行できる
2)raw imageファイルは標準のイメージファイルが持っていない
indirect blockとdirectory blockを持っている(将来的には変更されるかも)

※1)の注意点として、このファイルをコピーや圧縮/非圧縮する場合
sparceファイルを理解しないutilityを使うとFSと同じくらいの
ファイルサイズになってしまう

-s ディレクトリなどのファイル名がそのままimageファイルに送られるので
-sをつけることで、imageファイルを書く前にディレクトリエントリを
ごちゃ混ぜにして、ディレクトリエントリの未使用部分を0埋めする
-sはhash-treeでindexされたディレクトリの問題を分析することの邪魔になるだろう

-I imageファイルに格納したメタデータをデバイスに戻す。緊急事態に
リストアするために利用される。


e2imageで出力したメタデータのファイルをfsckでチェックできる


[root@localhost /]# e2image -r /dev/sda7 test.img
e2image 1.41.14 (22-Dec-2010)



[root@localhost /]# e2fsck -f test.img
e2fsck 1.41.14 (22-Dec-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
test.img: 11/25480 files (9.1% non-contiguous), 8870/101540 blocks


マニュアルによればエキスパートがこの情報を元に復旧する手助けとなるとのことだが、
メタデータのバックアップだけで、データの復旧が出来るのか謎。
ちなみに将来的にはe2fsckとも連携を図ると書いてあるが、取り組んでいるのを聞いたことがないですね。
gitのコミットのタイトル↓も見てみましたが、まだやってないようです。



[root@localhost e2fsprogs]# git whatchanged | grep e2image | grep -v :
Convert tune2fs, dumpe2fs, and e2image to the new bitmap interface
Use BLOCK_FLAG_READ_ONLY flag in debugfs, e2image, and tune2fs
e2image, and tune2fs will work well with filesystems containing
If the disk fills while e2image is writing its output file, it will
e2image in raw-mode appends an extra byte to image-file
In raw mode (-r), e2image appends an extra byte to the image-file's
This problem can be reproduced by doing an e2image -r dev image-file
e2image, etc. Fix ext2fs_open2() so that it returns the error code
[COVERITY] Fix memory leak in e2image (write_raw_image_file)
[COVERITY] Fix memory leak in e2image
Clean up e2image man page, mostly based on suggestions from
send a raw e2image filesystem dump if possible.
Escape hyphens in the e2image and tune2fs man pages so that they show up
e2image -rs is specified.
for dealing with large sparse files (such as e2image files).
Remove debugging printf from e2image -s's code.
Fix minor glitches in the e2image man page.
reading from an e2image file. (New -d option)
administrator to install an metadata stored in an e2image
Fix up extended attribute handling in e2image, resize2fs, and in
error message could be printed on an malloc() failure, and e2image
Add support for raw image files in e2image.
badblocks.c, chattr.c, dumpe2fs.c, e2image.c, findsuper.c, lsattr.c,
Fix program name for e2image.



e2imageをつかってファイルの復旧をしてみる

たいそうなことではないですが、e2imageでとったメタデータのバックアップを
使って削除したファイルを復帰させてみたいと思います。


1.metadataのbackupを作成


[root@localhost /]# e2image -r /dev/sda7 test.img
e2image 1.41.14 (22-Dec-2010)


2.試しにファイルを消してみる
[root@localhost /]# rm /mnt/mp1/a

rm: remove regular empty file `/mnt/mp1/a'? yes


3.aが無くなっていることを確認

[root@bsd086 mnt]# ll /mnt/mp1
total 12
drwx------ 2 root root 12288 Feb 8 19:59 lost+found


4.metadataのbackupをFSへかきだす

[root@localhost /]# dd if=test.img of=/dev/sda7
203080+0 records in
203080+0 records out
103976960 bytes (104 MB) copied, 3.02975 s, 34.3 MB/s


5.もとに戻っていることを確認

[root@localhost /]# ll /mnt/mp1/
total 12
-rw-r--r-- 1 root root 0 Feb 8 20:00 a
drwx------ 2 root root 12288 Feb 8 19:59 lost+found



ext系のファイルシステムではファイルを削除する時に、
メタデータを更新して、データを削除したことにするのでこのようなことが出来ます。

もし、ファイル削除後にデータブロックが違うファイルにより上書き場合は、
メタデータのバックアップで元に戻してもコラプトしたファイルが見えてるでしょうから、
使いどころは限られていると思います。



この記事へのコメント

   

WWW を検索 Linux Blue を検索
プロフィール

uni
仙台でLinuxのエンジニアをしています。 忘備録もかねて主にLinuxについて載せています。 ここからの情報が何かの役に立てば幸いです。
リンク集
Links

<< 2013年01月 >>
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
カテゴリアーカイブ
月別アーカイブ
最新記事
×

この広告は30日以上新しい記事の更新がないブログに表示されております。