編集 最近の変更 全部 履歴 差分 生データ トップ ヘルプ

nemuiDoc: あるext3復旧レポート

ReverseLinks: IndexPage (790d)

Invalid argument while checking ext3 journal と言うエラーで fsck がかからないファイルシステムをどうやって復旧したか。そのレポート。 結果だけ知りたい人は一番最後のまとめだけどうぞ。

最初に注意

この方法は余り良くないかもしれない(と言うか多分良くない)。 こういう方法もあるのだという参考程度に。

発端

RedHat が起動できなくなったので見てくれと言われる

いってみると確かに起動できない、grub で kernel を探そうにもディレクトリエントリが読めない。(何かの範囲外にある?とか言うエラーが出た様に思う。記憶が曖昧)。

前提/現時点で分かっていること

とりあえずそのディスクを別のマシンに繋げてチェックしたら以下のことは分かった。

tempest:~# fsck.ext2 -n -b 32768 /dev/sda1
e2fsck 1.32 (09-Nov-2002)
/: Invalid argument while reading block 16777991

/: Invalid argument reading journal superblock

fsck.ext2: Invalid argument while checking ext3 journal for /

とにかく fsck がかからない

復旧作業

と言う訳で、取り敢えず journal log を使わずに fsck がかかるように しようとする。

debugfs でジャーナリングの機能を無理矢理無効にしてみる

tempest:~# 
debugfs 1.32 (09-Nov-2002)
debugfs:  feature -has_journal
Filesystem features: filetype sparse_super
debugfs:  quit

fsck とオプションが違うので注意。

取り敢えず無効になったらしい。でも、

tempest:~# fsck.ext2 -n -b 32768 /dev/sda1
e2fsck 1.32 (09-Nov-2002)
/: Invalid argument while reading block 16777991

/: Invalid argument reading journal superblock

fsck.ext2: Invalid argument while checking ext3 journal for /

fsck は駄目。しかし、

tempest:~# mount -t ext2 -o ro /dev/sda1 /mnt

マウントできた。マウントの時はちゃんと無視してくれている模様。

とはいっても、

tempest:~# df /mnt
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/scsi/host1/bus0/target0/lun0/part1
                      18967764     32828  17971416   1% /mnt

tempest:~# ls -la /mnt
total 0

壊れているので(?)何も見えない。

tempest:~# umount /mnt

どうしようもないので、umount。

マウントできたと言うことは、先ほどの debugfs で一応スーパーブロックは 修復されているはず、というわけで情報を取ってみる。

tempest:~# dumpe2fs -h  /dev/sda1
dumpe2fs 1.32 (09-Nov-2002)
Filesystem volume name:   /
Last mounted on:          <not available>
Filesystem UUID:          f7732902-66ca-11d7-9fb5-99c5b2a5cd03
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      filetype sparse_super
Default mount options:    (none)
Filesystem state:         not clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              2410624
Block count:              4817602
Reserved block count:     240880
Free blocks:              4733734
Free inodes:              2410613
First block:              0
Block size:               4096
Fragment size:            4096
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         16288
Inode blocks per group:   509
Last mount time:          n/a
Last write time:          Wed Apr 16 17:13:04 2003
Mount count:              0
Maximum mount count:      -1
Last checked:             Sat Apr  5 03:26:35 2003
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
ext2fs_read_bb_inode: Illegal triply indirect block found 

内容が怪しいけれど、取り敢えず読めている。

しかし、

tempest:~# fsck.ext2 -n -b 32768 /dev/sda1
e2fsck 1.32 (09-Nov-2002)
/: Invalid argument while reading block 16777991

/: Invalid argument reading journal superblock

fsck.ext2: Invalid argument while checking ext3 journal for /

やっぱり fsck はかからない。

この時 -b オプションを付けないで試して見るべきだった。もしかしたらそれだけで解決したかも知れない。

きっと journal log の情報が何処かに残っているんだろうということで、 もう一度 debugfs

tempest:~# debugfs -w -s 32768  -b 4096 /dev/sda1
debugfs 1.32 (09-Nov-2002)
debugfs:  feature filetype sparse_super has_journal
Filesystem features: has_journal filetype sparse_super

一旦 has_journal のフラグを元に戻す。 そして、スーパーブロックの情報を取ると、

debugfs:  show_super_stats -h
Filesystem volume name:   /
Last mounted on:          <not available>
Filesystem UUID:          f7732902-66ca-11d7-9fb5-99c5b2a5cd03
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal filetype sparse_super
Default mount options:    (none)
Filesystem state:         not clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              2410624
Block count:              4817602
Reserved block count:     240880
Free blocks:              4733734
Free inodes:              2410613
First block:              0
Block size:               4096
Fragment size:            4096
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         16288
Inode blocks per group:   509
Last mount time:          n/a
Last write time:          Wed Apr 16 17:20:19 2003
Mount count:              0
Maximum mount count:      -1
Last checked:             Sat Apr  5 03:26:35 2003
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal UUID:             <none>
Journal inode:            8
Journal device:           0x0000
First orphan inode:       0
Directories:              2

Journal inode: 8 が怪しそうなのでなんとか無効にしてみる。

debugfs(8) と set_super_value -l によれば unsigned int との事なので、 取り敢えず 0 を設定。

debugfs:  set_super_value journal_inum 0

特にエラーは出ない。設定出来た様だ。

debugfs:  show_super_stats -h
Filesystem volume name:   /
Last mounted on:          <not available>
Filesystem UUID:          f7732902-66ca-11d7-9fb5-99c5b2a5cd03
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal filetype sparse_super
Default mount options:    (none)
Filesystem state:         not clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              2410624
Block count:              4817602
Reserved block count:     240880
Free blocks:              4733734
Free inodes:              2410613
First block:              0
Block size:               4096
Fragment size:            4096
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         16288
Inode blocks per group:   509
Last mount time:          n/a
Last write time:          Wed Apr 16 17:20:19 2003
Mount count:              0
Maximum mount count:      -1
Last checked:             Sat Apr  5 03:26:35 2003
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal UUID:             <none>
Journal inode:            0
Journal device:           0x0000
First orphan inode:       0
Directories:              2

確かに 0 になっている

debugfs:  feature -has_journal
Filesystem features: filetype sparse_super

もう一度ジャーナリングを無効にする。

debugfs:  quit

debugfs を脱出して、再度 fsck

tempest:~# fsck.ext2 -n -b 32768 /dev/sda1
e2fsck 1.32 (09-Nov-2002)
/ was not cleanly unmounted, check forced.
fsck.ext2: Illegal triply indirect block found while reading bad blocks inode
This doesn't bode well, but we'll try to go on...
Pass 1: Checking inodes, blocks, and sizes
Bad block inode has illegal block(s).  Clear? no

Illegal block #0 (16777472) in bad block inode.  IGNORED.
Illegal block #1 (16777472) in bad block inode.  IGNORED.
Illegal block #2 (16777472) in bad block inode.  IGNORED.
Illegal block #3 (16777472) in bad block inode.  IGNORED.
Illegal block #4 (16777472) in bad block inode.  IGNORED.
Illegal block #5 (16777472) in bad block inode.  IGNORED.
Illegal block #6 (16777472) in bad block inode.  IGNORED.
Illegal block #7 (16777472) in bad block inode.  IGNORED.
Illegal block #8 (16777472) in bad block inode.  IGNORED.
Illegal block #9 (16777472) in bad block inode.  IGNORED.
Illegal block #10 (16777472) in bad block inode.  IGNORED.
Illegal block #11 (16777472) in bad block inode.  IGNORED.
Illegal block #-1 (16777472) in bad block inode.  IGNORED.
Illegal block #-2 (16777472) in bad block inode.  IGNORED.
Illegal block #-3 (16777472) in bad block inode.  IGNORED.
Error while iterating over blocks in inode 1: Illegal triply indirect block found
e2fsck: aborted

/: ********** WARNING: Filesystem still has errors **********

/: 11/2410624 files (0.0% non-contiguous), 83868/4817602 blocks

OK. ちゃんとチェックに行ってくれている。

後は自動復旧モード(単に全部の質問に yes と答えるモード)で fsck を走らせる。

tempest:~# fsck.ext2 -y -b 32768 /dev/sda1
(とんでもなく長いので略)

終わったら mount してみよう

tempest:~# mount -t ext2 -o ro /dev/sda1 /mnt
tempest:~# df /mnt
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/scsi/host1/bus0/target0/lun0/part1
                      18967764   1039628  16964616   6% /mnt

今度は巧くいっている雰囲気。

辛うじて復旧は出来た

中を見て見ると、

tempest:~# ls /mnt
lost+found

やはり / が壊れた様だ。 全部 lost+found の中へいってしまった……

tempest:/mnt/lost+found# ls |head    
#1042436
#1042443
#1058730
#1058776
#1058814
#1075013
#1075029
#114113
#114114
#114115
tempest:/mnt/lost+found# ls | wc -l
   8687

こんな有り様。

しかし、ディレクトリ構成が一部でも残っている事に賭けて find

tempest:/mnt/lost+found# find .  -type d
.
./#293185
./#293185/bin
./#293185/libexec
./#293185/libexec/awk
./#293185/libexec/openssh
./#293185/libexec/emacs
./#293185/libexec/emacs/21.2
./#293185/libexec/emacs/21.2/i386-redhat-linux
./#293185/share
./#293185/share/doc
./#293185/share/doc/glibc-common-2.2.5
./#293185/share/doc/glibc-common-2.2.5/examples.threads
./#293185/share/doc/libjpeg-6b
./#293185/share/doc/HTML
./#293185/share/doc/HTML/img
./#293185/share/doc/HTML/img-de

深い階層は比較的無事な雰囲気。

調べてみると、必要なデータがあるディレクトリ以下はちゃんと残っていた。 ここをtarで固めて渡しておしまい。

まとめ

Invalid argument while checking ext3 journal と言うエラーで ext3 に fsck が かからないときは、debugfs の set_super_value コマンドを使って journal_inum の値を 0 にすれば一応無理矢理 fsck をかけることはできる。

しかし。そもそも、fsck にジャーナル情報を無視するオプションがあればこんな必要は無い。


突っ込みをどうぞ:

名前: E-mail:


最終更新: 2006-09-13/17:53:13 +0900 (799d)