[ Main Page ]

機器の故障 - 日本光電 Neuropack (2) (WindowsNT 4.0の復旧編)

機器の修理というよりは、制御用PCのハードディスクのWindowsNTの復旧なので、ソフトウエアの話題である。 日本光電のNeuropackは古くから販売されており、ブラウン管組み込みの世代から1代上の機種はMEB-2200になるが、 WindowsNT 4.0/ ISAボードバージョンがあるのを最近知った。研究室ではUSBバージョンしか見たことしかなかった。

Maxtorの6.4GBのハードディスクが故障してしまい、バッドセクタが出て起動しなくなったので、復旧が必要となった。 昔の機種が動いている場合は、故障に備えて、まず、ハードディスクの全セクタのイメージバックアップ(dd) をとるべきであったが、今回は油断してとっていなかったのが災いした。マシンはDELLのOptiPlex GX110 PentiumIII 500MHzで、20年近く前の機種になるから、良く持ったとも言える。

dd rescueによるイメージ取得とchkdsk

執筆時点では、GNU ddrescueがお勧めである。 始めに一通り読んでから読めないところを何回か再読込する。残念ながら一部読み込みが出来なかった。hexeditで周囲をチェックすると大まかに損傷部位が推測出来るが、一部は不明であった。

ddrescue -n -v /dev/sdb sdb.img sdb.log
ddrescue -d -f -r 3 -v /dev/sdb sdb.img sdb.log
# Mapfile. Created by GNU ddrescue version 1.22
# Command line: ddrescue --fill=- DEADBEEF.txt sdb.img sdb.log
# Start time: 2018-10-02 22:52:11
# Current time: 2018-10-02 22:52:11
# Finished
# current_pos current_status current_pass
0x4005EC00 + 22
# pos size status
0x00000000 0x0034CC00 +
0x0034CC00 0x00000200 - system
0x0034CE00 0x002AF400 +
0x005FC200 0x00000200 - null00
0x005FC400 0x0000D400 +
0x00609800 0x00000200 - FAT table ?before INDX(
0x00609A00 0x10665E00 +
0x10C6F800 0x00000200 - system.ALT
0x10C6FA00 0x00014C00 +
0x10C84600 0x00000200 - WSH file ?
0x10C84800 0x07486200 +
0x1810AA00 0x00000200 - system.alt
0x1810AC00 0x27EB1C00 +
0x3FFBC800 0x00000200 - ?
0x3FFBCA00 0x00032600 +
0x3FFEF000 0x00000200 - ?
0x3FFEF200 0x00011C00 +
0x40000E00 0x00000200 - ?
0x40001000 0x00044400 +
0x40045400 0x00000200 - ?
0x40045600 0x00008200 +
0x4004D800 0x00000200 - ?
0x4004DA00 0x00011200 +
0x4005EC00 0x00000200 - ?
0x4005EE00 0x140583200 +

損傷ファイル検索

printf   DEADBEEF > DEADBEEF.txt
losetup -o $((512*63)) -f sdb.img /dev/loop0
mount -o ro /dev/loop0 /mnt/hd
$MFTMirr does not match $MFT (record 0).
Failed to mount '/dev/loop0': Input/output error
NTFS is either inconsistent, or there is a hardware fault, or it's a
SoftRAID/FakeRAID hardware. In the first case run chkdsk /f on Windows
then reboot into Windows twice. The usage of the /f parameter is very
important! If the device is a SoftRAID/FakeRAID then first activate
it and mount a different device under the /dev/mapper/ directory, (e.g.
/dev/mapper/nvidia_eahaabcc1). Please see the 'dmraid' documentation
for more details.
testdisk sdb.img
...
find /mnt/hd -type f -exec grep "DEADBEEF" '{}' ';'
Binary file /mnt/hd1/pagefile.sys matches
grep: /mnt/hd1/WINNT/system32/SAMLIB.DLL: Input/output error
grep: /mnt/hd1/WINNT/system32/RPCLTS1.DLL: Input/output error
Binary file /mnt/hd1/WINNT/system32/config/system matches
Binary file /mnt/hd1/WINNT/system32/config/SYSTEM.ALT matches
grep: /mnt/hd1/WINNT/Profiles/Administrator/SendTo/メール受信者.MAPIMail: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/Windows NT エクスプローラ.lnk: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/アクセサリ/Unicode 文字コード表.lnk: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/アクセサリ/外字エディタ.lnk: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/アクセサリ/文字コード表.lnk: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/アクセサリ/時計.lnk: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/アクセサリ/電卓.lnk: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/アクセサリ/オブジェクト パッケージャ.lnk: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/アクセサリ/マルチメディア/ボリューム コントロール.lnk: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/アクセサリ/マルチメディア/メディア プレーヤー.lnk: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/アクセサリ/メモ帳.lnk: Input/output error
grep: /mnt/hd1/WINNT/Profiles/Administrator/スタート メニュー/プログラム/アクセサリ/ワードパッド.lnk: Input/output error
grep: /mnt/hd1/WINNT/Fonts/ariblk.ttf: Input/output error

IDEハードディスクは CF(コンパクトフラッシュ) と信号・プロトコルが基本同じなので、簡単な変換基板があれば基本的にシリコンディスク化できる。書き戻し先はCFへ行った。

CFの構造の一例

Disk /dev/sdb: 14.9 GiB, 16022200320 bytes, 31293360 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 200 31293359 31293160 14.9G c W95 FAT32 (LBA)

Linux上でマウントすると$MFTのエラーで進まないので、TestDiskでMFTだけ復旧させて走らせるが、 いくつかのファイルがI/Oエラーになるようで、 B+ treeも一部損傷しているようである。 まず別のWindowsNT 4.0 (VMware等)でchkdsk /Fを走らせて出来る範囲で修復した。修復したイメージを書き戻した時の始めの起動時のエラーは、下記で、ハイブの損傷であった。

次のファイルが存在しないかまたは壊れているため、Windows を起動できませんでした: \WINNT\SYSTEM32\CONFIG\SYSTEM

レジストリハイブの損傷

SYSTEMハイブはSYSTEMとSYSTEM.ALTの二つが保持されており、調べたところ運良く両方で別のアドレスが損傷していたので、 バイナリエディタ(Stirling)でそれぞれを見ながら補完しつつ修復した。

Stirling

これで済んだと思って書き戻して起動させると今度はBSOD画面で別のエラーが出力される。

Stop c0000135(Unable to locate DLL)
The dynamic link library winsrv could not be found in the specified path Default load path.

Begining dump of physical memory....

このエラーはwinsrv.dllが壊れている時も出るが、SOFTWAREハイブが損傷している時も出る。 regedit.exeでHKEY_USERに一時的にSOFTWAREハイブをロードさせてもエラーは出ないが、内部的には何らかの損傷があると思われる。 repairディレクトリ等にある別の正常なSOFTWAREハイブ(software._等のrepairファイルは圧縮ファイルなので、中の$$hive$$.tmpを7zip等で解凍して作る)の 中身をすべてクリアしてから、NirsoftRegFileExport.exe で損傷のあると思われるSOFTWAREハイブをテキスト出力し、パスを上記でロードさせているツリーに書き換えてから読み込み、 ハイブアンロードすると正常なハイブが生成される。これをもう一度書き戻すとまた別のエラーになる。

STOP: c000021a {Fatal System Error}
The Windows Logon Process system process terminated unexpectedly with a status of 0xc0000080 (0x00000000 0x0000000)
The system has been shutdown.

万事休すと思われたが、今度はめげずに、WindowsNT 4.0 SP6aのDLL、EXE、SYS、DRV、TTF等をすべて上書きしてみる。すると今度はVGAドライバに切り替わってログイン画面の前まで来るが、 肝心の下のログイン画面が待てども待てどもいっこうに現れない。少なくともいくつかのDLLは壊れていたか、MFTの損傷でアドレスがおかしくなって正常なファイルでなくなっていたと思われる。 今度はセキュリティハイブがおかしいと思い、SAMハイブとSECURITYハイブとdefaultハイブを 同様にregedit.exeで作り直して書き戻すが、効果がない。SAMとSECURITYについてはレジストリアクセスのセキュリティ要件が少し難しいので、 こちらだけはrepairディレクトリのSAMとSECURITYを書き戻すと、やっとログイン画面に辿り着き、ログインできた。 プロファイルが再作成されたりするので、前のNTuser.datハイブやその他のファイルはレジストリエディタで書き戻すかコピーする必要があるが、これは上記に比べればずっと楽だろう。

WindowsNT Logon

最後に分かってしまえば、だいぶ楽だが、辿り着くまでは数日かかってしまった。現象だけでどこが壊れているか判断するのはかなり難しい。 さらに、エラー表示だけでどこがおかしいと完全に特定できるわけでもない。こういう時はソースコードがあると楽である。デバッガがあるとなおさらか。 尤も、WindowsNTのソースコードは契約で取得出来るし、同コードが流出したことはあったので、頑張ればどこからか取得することはできるかもしれないが。 regedit.exeではロード出来るハイブに何らかの損傷があってエラーが出ていたというのは よくわからないが、ハイブを再構成したのはWindows7上であったが使えたことから、こんなに昔のWindowsNTとも未だに互換性のあるファイル構造であるのには驚いた。 昔の技術に基づいて今の技術があるということは実感させられる。久しぶりにWindowsに振り回された感があるが、バックアップの重要性を再認識した件であった。

[After the bad review of the play in the "New York Times".]

Joey: Hey, tell ya what. Let me walk you home. We'll stop by every news stand
and burn every copy of their Times and the Post.

Kate: Why the Post?

Joey: Oh, you didn't see the Post?

Kate: No. You?

Joey: No. Why?

    -- David Crane & Marta Kauffman
    -- "Friends" (T.V. Show) ( http://en.wikipedia.org/wiki/Friends )

That's me in the corner.
That's me in the spotlight.
Losing my abstraction.

Trying to keep my point of view...
And I don't know if I can do it.
Oh no, I code too much.
Haven't debugged enough.

Is that why I heard you laughing?
I thought that I heard you ping.
I think I thought I saw you reply.

    -- Andy Armstrong and Randal L. Schwartz
    -- Perl module-authors post ( http://www.nntp.perl.org/group/perl.module-authors/2007/05/msg5435.html )


Powered by UNIX fortune(6)
[ Main Page ]