VirtualBoxで動かしてるCentOSのファイルシステムが破損したっぽい。UNEXPECTED INCONSISTENCYエラー

下書きの掘り起こし。2011-10-19に書いたやつ。

Setting up Logical Volume Management:  No Volume groups found
									[  OK  ]

Checking filesystems
/ contains a file system with errors, check forced
/:
Inodes that were part of a corrupted orphan linked list found.

/: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
	(i.e., without -a or -p options)
									[FAILED]

*** An error occurred during the file system check.
*** Dropping you to a shell; the system will reboot
*** with you leave the shell.
*** Warning -- SELinux is active
*** Disabling security enforcement for system recovery.
*** Run 'setenforce 1' to reenable.
Give root password for maintenance
(or type Control-D to continue): _

起動時のカーネルからのメッセージが、こんな事になってました。大文字で表示されてるUNEXPECTED INCONSISTENCYで検索すると、割とメジャーなのか結構情報でてきました。なので、目新しい事はないんですが、初めて出くわしたのでメモとして残しておきます。

対応

ファイルシステムの破損らしく、ext3のようなジャーナルリング機能があれば、修復出来る可能性はあるらしい。その方法は、メッセージに書かれている通りfsckコマンドを-a-pオプション無しで実行するというもので、基本的にメッセージにしたがうのみです。

#rootパスワード入力してEnterすると、下記のプロンプトが表示される。
(Repair filesystem) 1 # _

(Repair filesystem) 1 # mount
/dev/sda1 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devfs (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

mount: warning: /etc/mtab is not writable (e.g. read-only filesystem).
       It's possible that information reported by mount(8) is not
       up to date. For actual information about system mount points
       check the /proc/mounts file.

(Repair filesystem) 2 # fsck -t ext3 /dev/sda1
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
/ contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Inodes that were part of a corrupted orphan linked lit found. Fix<y>?

#様々な修復内容が表示されるけど、内容が分かるはずもなくEnterを押してデフォルトのyで進めていく。

中略
Inode 949668 was part of the orphaned inode list. FIXED.
Delete inode 949669 has zero dtime. Fix<y>?

中略
Inode 1543224 was part of the orphaned inode list. FIXED.
Extended attribute block 100010 has reference count 2, should be 1. Fix<y>?
Extended attribute block 809836 has reference count 20, should be 19. Fix<y>?
Extended attribute block 951297 has reference count 876, should be 871. Fix<y>?
Extended attribute block 951329 has reference count 4, should be 3. Fix<y>?

中略

Pass 2: Checking directory structure

膨大な量が流れたので略

Free blocks count wrong for group #3 (28884, counted=29158).
Fix<y>?

Free blocks count wrong for group #15 (29705, counted=29735).
Fix<y>?

中略

Inode bitmap differences: -98245 -98309 -491173 -949354 -949358 -0949360 中略 -1444660 -1543224
Fix<y>?

/: **** FILE SYSTEM WAS MODIFIED *****
/: ***** REBOOT LINUX *****
/: 193873/1964160 files (1.3% non-contiguous), 1082508/1963938 blocks
(Repair filesystem) 3 # exit

mountしてfsckコマンドを実行した後は、Enterを連打するしか無い感じです。
これで修復が出来てれば、リブートしてCentOSが起動出来ますが、修復しきれないとまたUNEXPECTED INCONSISTENCYエラーが表示され、最悪ループするんだとか。
あと、修復したファイルは/lost+foundに格納されるらしいです。今回は、幸いなことにls /lost+foundしても何も無かったので、実質損害無しだったみたい。

環境

VirtualBox 4.0.12
Guest OS CentOS 5.7
Host OS Fedora 15