hack のためのネタ帳, etc,,,

不良クラスタの情報

ルートフォルダの $BadClus ファイルが保持している。
このファイルは NTFS の metadata を保持したシステムファイルで通常は見ることができない。
基本的には inode 8 が割り当てられているものらしい。

UNIX 系の OS で ntfsprogs 等のツールを利用することでいろいろと情報を操作することができるようだ。
mount 時に show_sys_files オプションを付加しても存在を確認することができる。
Windows では R-Studio のようなデータ復旧ソフトを用いると metafile としてアクセスがすることが可能である。

以下 /dev/sda1 が目的の NTFS パーティションであるとして例示する。

ntfsls を用いると以下のように inode, ファイルサイズ及び作成日時を確認することができる。
# ntfsls /dev/sda1 -lisp '$BadClus'
      8           0 Aug 28 23:03 2005 $BadClus

上記の例では inode 8 でサイズは 0 バイト、2005-08-28 23:03 に作られた事が分かる。

attribute を確認するには ntfsinfo を用いる。-i オプションで inode を直接でしていしても良いし -F オプションで、絶対パス指定しても良い。ここでは -F オプションの例を示す。
# ntfsinfo -F '$BadClus' /dev/sda1
Dumping Inode 8 (0x8)
Upd. Seq. Array Off.:	 48 (0x30)
Upd. Seq. Array Count:	 3 (0x3)
Upd. Seq. Number:	 60 (0x3c)
LogFile Seq. Number:	 0x2001119
MFT Record Seq. Numb.:	 8 (0x8)
Number of Hard Links:	 1 (0x1)
Attribute Offset:	 56 (0x38)
MFT Record Flags:	 IN_USE 
Bytes Used:		 400 (0x190) bytes
Bytes Allocated:	 1024 (0x400) bytes
Next Attribute Instance: 6 (0x6)
MFT Padding:	00 00 
Dumping attribute $STANDARD_INFORMATION (0x10) from mft record 8 (0x8)
	Resident: 		 Yes
	Attribute flags:	 0x0000
	Attribute instance:	 0 (0x0)
	Data size:		 72 (0x48)
	Resident flags:		 0x00
	File Creation Time:	 Sun Aug 28 23:03:12 2005
	File Altered Time:	 Sun Aug 28 23:03:12 2005
	MFT Changed Time:	 Sun Aug 28 23:03:12 2005
	Last Accessed Time:	 Sun Aug 28 23:03:12 2005
	File attributes:	 HIDDEN SYSTEM (0x00000000)
	Maximum versions:	 0 
	Version number:		 0 
	Class ID:		 0 
	User ID:		 0 (0x0)
	Security ID:		 256 (0x100)
	Quota charged:		 0 (0x0)
	Update Sequence Number:	 0 (0x0)
Dumping attribute $FILE_NAME (0x30) from mft record 8 (0x8)
	Resident: 		 Yes
	Attribute flags:	 0x0000
	Attribute instance:	 3 (0x3)
	Data size:		 82 (0x52)
	Resident flags:		 0x01
	Parent directory:	 5 (0x5)
	File Creation Time:	 Sun Aug 28 23:03:12 2005
	File Altered Time:	 Sun Aug 28 23:03:12 2005
	MFT Changed Time:	 Sun Aug 28 23:03:12 2005
	Last Accessed Time:	 Sun Aug 28 23:03:12 2005
	Allocated Size:		 0 (0x0)
	Data Size:		 0 (0x0)
	Filename Length:	 8 (0x8)
	File attributes:	 HIDDEN SYSTEM (0x00000000)
	Namespace:		 Win32 & DOS
	Filename:		 '$BadClus'
Dumping attribute $DATA (0x80) from mft record 8 (0x8)
	Resident: 		 Yes
	Attribute flags:	 0x0000
	Attribute instance:	 2 (0x2)
	Data size:		 0 (0x0)
	Resident flags:		 0x00
Dumping attribute $DATA (0x80) from mft record 8 (0x8)
	Resident: 		 No
	Attribute name:		 '$Bad'
	Attribute flags:	 0x0000
	Attribute instance:	 5 (0x5)
	Compression unit:	 0 (0x0)
	Data size:		 20003848192 (0x4a8528000)
	Allocated size:		 20003848192 (0x4a8528000)
	Initialized size:	 0 (0x0)
End of inode reached

ここで重要となるのは Attribute name: '$Bad' を持つ最後の Dumping attribute $DATA (0x80) の部分に含まれる Allocated size: のパラメータである。上記の例では 20003848192 がそれに該当する。


以下未検証。
ntfsclone にある Reseting the bad sectors list after cloning という解説によれば ntfstruncate が利用可能な場合、比較的容易に $BadClus のリセットが可能なようである。
上記の例であれば、$BadClus の inode 番号 8 と Attribute name: '$Bad' を持つ Dumping attribue $DATA (0x80) の Allocated size: 20003848192 を用いて、以下のように Allocated size をリセットしてやる。
# ntfstruncate /dev/sda1 8 0x80 '$Bad' 0
# ntfstruncate /dev/sda1 8 0x80 '$Bad' 20003848192

以上の操作で Windows 上から chkdsk した際にエラーが検出され修正が行われるらしい。
以上、未検証。


なお、2008-10-21 時点において KNOPPIX 5.3.1 には ntfsturancate は含まれていなかった。
Debian の ntfsprogs 2.0.0-1、Ubuntu の 2.0.0-1ubuntu2 も同様の状況である。

ソースパッケージを拾ってくれば 2.0.0 にも ntfstruncate は含まれている。
ただし Automake で EXTRA_PROGRAM として build されるようになっているため make install の対象外である。
ntfsturuncate を build するには make extra する必要がある。
build に成功したら実行ファイルが ntfsprogs/ 以下に生成されるので直接実行すれば良い。

念のためコメントしておくが、現時点では make で install はおろかデフォルトでは build さえ行われないという点から、どういう性格のプログラムであり、どのようなリスクが存在するのかを良く理解して利用する必要があるだろう。少なくとも、この説明の意味が理解できないなら使うべきではないと思われる。

以下、参考までに help を提示しておく。
/tmp/ntfsprogs/ntfsprogs-2.0.0/ntfsprogs/.libs/lt-ntfstruncate v2.0.0 (libntfs 10:0:0)
Copyright (c) 2002-2005 Anton Altaparmakov
Copyright (c) 2003 Richard Russon
Truncate a specified attribute of a specified inode.
Usage: /tmp/ntfsprogs/ntfsprogs-2.0.0/ntfsprogs/.libs/lt-ntfstruncate [options] device inode [attr-type [attr-name]] new-length
    If attr-type is not specified, 0x80 (i.e. $DATA) is assumed.
    If attr-name is not specified, an unnamed attribute is assumed.
    -n    Do not write to disk
    -f    Force execution despite errors
    -q    Quiet execution
    -v    Verbose execution
    -vv   Very verbose execution
    -V    Display version information
    -l    Display licensing information
    -h    Display this help
Developers' email address: linux-ntfs-dev@lists.sf.net
Linux NTFS homepage: http://www.linux-ntfs.org


$BadClus 追跡の例
PBP(Partition Boot Sector) つまり sector 0 を参照し、0x30 からの 8 バイトがMFTが配置されたクラスタ番号を示しているらしい。
従って以下のコマンドでMFTのクラスタ番号が分かる。
# xxd -s 0x30 -l 8 -g 1 /dev/sda1 | awk '{s="0x";for(i=8;1<i;i--)s=s$i;print "cluster address of MFT: "s;}'
0x000000000c0000

ほとんどの NTFS は 1 クラスタが 4k バイト、つまり 0x1000 バイトなので上で得られたクラスタ番号の末尾に 000 を付け加えると MFT が HDD の先頭から何バイト目にあるのか分かる。
MFT は 1 レコードが 1k バイトらしい。
MFT 上の $BadClus のエントリは 0 から数えて 8 番目なので、以下のようにすれば MFT 上にある $BadClus の最初のレコードのダンプが得らる。
# (dev=/dev/sda1; xxd -s $(xxd -s 0x30 -l 8 -g 1 $dev | awk '{s="0x";for(i=8;1<i;i--)s=s$i;print s"000";}') -l 0x2400 $dev | tail -n 64)
c0002000:4649 4c45 3000 0300 1911 0002 0000 0000  FILE0...........
c0002010:0800 0100 3800 0100 9001 0000 0004 0000  ....8...........
c0002020:0000 0000 0000 0000 0600 0000 0800 0000  ................
c0002030:3c00 0000 0000 0000 1000 0000 6000 0000  <...........`...
c0002040:0000 1800 0000 0000 4800 0000 1800 0000  ........H.......
c0002050:0022 933a d9ab c501 0022 933a d9ab c501  .".:.....".:....
c0002060:0022 933a d9ab c501 0022 933a d9ab c501  .".:.....".:....
c0002070:0600 0000 0000 0000 0000 0000 0000 0000  ................
c0002080:0000 0000 0001 0000 0000 0000 0000 0000  ................
c0002090:0000 0000 0000 0000 3000 0000 7000 0000  ........0...p...
c00020a0:0000 1800 0000 0300 5200 0000 1800 0100  ........R.......
c00020b0:0500 0000 0000 0500 0022 933a d9ab c501  .........".:....
c00020c0:0022 933a d9ab c501 0022 933a d9ab c501  .".:.....".:....
c00020d0:0022 933a d9ab c501 0000 0000 0000 0000  .".:............
c00020e0:0000 0000 0000 0000 0600 0000 0000 0000  ................
c00020f0:0803 2400 4200 6100 6400 4300 6c00 7500  ..$.B.a.d.C.l.u.
c0002100:7300 0000 0000 0000 8000 0000 1800 0000  s...............
c0002110:0000 1800 0000 0200 0000 0000 1800 0000  ................
c0002120:8000 0000 6800 0000 0104 4000 0000 0500  ....h.....@.....
c0002130:0000 0000 0000 0000 2785 4a00 0000 0000  ........'.J.....
c0002140:4800 0000 0000 0000 0080 52a8 0400 0000  H.........R.....
c0002150:0080 52a8 0400 0000 0000 0000 0000 0000  ..R.............
c0002160:2400 4200 6100 6400 039b 442b 3101 9b44  $.B.a.d...D+1..D
c0002170:2b01 2f11 0130 03d3 b400 3101 d4b4 0003  +./..0....1.....
c0002180:888b 1e00 0000 0000 ffff ffff 0000 0000  ................
c0002190:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021a0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021b0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021c0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021d0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021e0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021f0:0000 0000 0000 0000 0000 0000 0000 3c00  ..............<.
c0002200:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002210:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002220:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002230:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002240:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002250:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002260:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002270:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002280:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002290:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022a0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022b0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022c0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022d0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022e0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022f0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002300:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002310:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002320:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002330:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002340:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002350:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002360:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002370:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002380:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002390:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023a0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023b0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023c0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023d0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023e0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023f0:0000 0000 0000 0000 0000 0000 0000 3c00  ..............<.

上記の例は、実際に不良クラスタが登録されている HDD のデータである。
この HDD を ntfsresize にかけてみると 3 箇所の不良クラスタが登録されているため -b オプションなしでは以下のようにエラーで処理が中断されてしまう。
# ntfsresize -ivn /dev/sda1
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name        : /dev/sda1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 20003848704 bytes (20004 MB)
Current device size: 20003848704 bytes (20004 MB)
Checking for bad sectors ...
Bad cluster: 0x2b449b - 0x2b449b    (1)
Bad cluster: 0x2b44cb - 0x2b44cb    (1)
Bad cluster: 0x2bf99f - 0x2bf99f    (1)
ERROR: This software has detected that the disk has at least 3 bad sectors.
****************************************************************************
* WARNING: The disk has bad sector. This means physical damage on the disk *
* surface caused by deterioration, manufacturing faults or other reason.   *
* The reliability of the disk may stay stable or degrade fast. We suggest  *
* making a full backup urgently by running 'ntfsclone --rescue ...' then   *
* run 'chkdsk /f /r' on Windows and rebooot it TWICE! Then you can resize  *
* NTFS safely by additionally using the --bad-sectors option of ntfsresize.*
****************************************************************************



上記の不良を有した HDD の NTFS ボリュームを nftsclone --rescue で健康な HDD にクローンしした後 Vista 上で chkdsk に /f /r /b オプションを付けて不良クラスタの再検査を行い、$BadClus から不良クラスタ情報の消去を行った。
この HDD の $BadClus を見てみると以下のようになっていた。
# ntfsinfo -F '$BadClus' /dev/sda1
Dumping Inode 8 (0x8)
Upd. Seq. Array Off.:	 48 (0x30)
Upd. Seq. Array Count:	 3 (0x3)
Upd. Seq. Number:	 60 (0x3c)
LogFile Seq. Number:	 0x2001119
MFT Record Seq. Numb.:	 8 (0x8)
Number of Hard Links:	 1 (0x1)
Attribute Offset:	 56 (0x38)
MFT Record Flags:	 IN_USE 
Bytes Used:		 400 (0x190) bytes
Bytes Allocated:	 1024 (0x400) bytes
Next Attribute Instance: 6 (0x6)
MFT Padding:	00 00 
Dumping attribute $STANDARD_INFORMATION (0x10) from mft record 8 (0x8)
	Resident: 		 Yes
	Attribute flags:	 0x0000
	Attribute instance:	 0 (0x0)
	Data size:		 72 (0x48)
	Resident flags:		 0x00
	File Creation Time:	 Sun Aug 28 23:03:12 2005
	File Altered Time:	 Sun Aug 28 23:03:12 2005
	MFT Changed Time:	 Sun Aug 28 23:03:12 2005
	Last Accessed Time:	 Sun Aug 28 23:03:12 2005
	File attributes:	 HIDDEN SYSTEM (0x00000000)
	Maximum versions:	 0 
	Version number:		 0 
	Class ID:		 0 
	User ID:		 0 (0x0)
	Security ID:		 256 (0x100)
	Quota charged:		 0 (0x0)
	Update Sequence Number:	 0 (0x0)
Dumping attribute $FILE_NAME (0x30) from mft record 8 (0x8)
	Resident: 		 Yes
	Attribute flags:	 0x0000
	Attribute instance:	 3 (0x3)
	Data size:		 82 (0x52)
	Resident flags:		 0x01
	Parent directory:	 5 (0x5)
	File Creation Time:	 Sun Aug 28 23:03:12 2005
	File Altered Time:	 Sun Aug 28 23:03:12 2005
	MFT Changed Time:	 Sun Aug 28 23:03:12 2005
	Last Accessed Time:	 Sun Aug 28 23:03:12 2005
	Allocated Size:		 0 (0x0)
	Data Size:		 0 (0x0)
	Filename Length:	 8 (0x8)
	File attributes:	 HIDDEN SYSTEM (0x00000000)
	Namespace:		 Win32 & DOS
	Filename:		 '$BadClus'
Dumping attribute $DATA (0x80) from mft record 8 (0x8)
	Resident: 		 Yes
	Attribute flags:	 0x0000
	Attribute instance:	 2 (0x2)
	Data size:		 0 (0x0)
	Resident flags:		 0x00
Dumping attribute $DATA (0x80) from mft record 8 (0x8)
	Resident: 		 No
	Attribute name:		 '$Bad'
	Attribute flags:	 0x0000
	Attribute instance:	 5 (0x5)
	Compression unit:	 0 (0x0)
	Data size:		 20003848192 (0x4a8528000)
	Allocated size:		 20003848192 (0x4a8528000)
	Initialized size:	 0 (0x0)
End of inode reached
# (dev=/dev/sda1; xxd -s $(xxd -s 0x30 -l 8 -g 1 $dev | awk '{s="0x";for(i=8;1<i;i--)s=s$i;print s"000";}') -l 0x2400 $dev | tail -n 64)
c0002000:4649 4c45 3000 0300 1911 0002 0000 0000  FILE0...........
c0002010:0800 0100 3800 0100 7801 0000 0004 0000  ....8...x.......
c0002020:0000 0000 0000 0000 0700 0000 0800 0000  ................
c0002030:4000 0000 0000 0000 1000 0000 6000 0000  @...........`...
c0002040:0000 1800 0000 0000 4800 0000 1800 0000  ........H.......
c0002050:0022 933a d9ab c501 0022 933a d9ab c501  .".:.....".:....
c0002060:0022 933a d9ab c501 0022 933a d9ab c501  .".:.....".:....
c0002070:0600 0000 0000 0000 0000 0000 0000 0000  ................
c0002080:0000 0000 0001 0000 0000 0000 0000 0000  ................
c0002090:0000 0000 0000 0000 3000 0000 7000 0000  ........0...p...
c00020a0:0000 1800 0000 0300 5200 0000 1800 0100  ........R.......
c00020b0:0500 0000 0000 0500 0022 933a d9ab c501  .........".:....
c00020c0:0022 933a d9ab c501 0022 933a d9ab c501  .".:.....".:....
c00020d0:0022 933a d9ab c501 0000 0000 0000 0000  .".:............
c00020e0:0000 0000 0000 0000 0600 0000 0000 0000  ................
c00020f0:0803 2400 4200 6100 6400 4300 6c00 7500  ..$.B.a.d.C.l.u.
c0002100:7300 0000 0000 0000 8000 0000 1800 0000  s...............
c0002110:0000 1800 0000 0200 0000 0000 1800 0000  ................
c0002120:8000 0000 5000 0000 0104 4000 0000 0600  ....P.....@.....
c0002130:0000 0000 0000 0000 2785 4a00 0000 0000  ........'.J.....
c0002140:4800 0000 0000 0000 0080 52a8 0400 0000  H.........R.....
c0002150:0080 52a8 0400 0000 0000 0000 0000 0000  ..R.............
c0002160:2400 4200 6100 6400 0328 854a 0000 0000  $.B.a.d..(.J....
c0002170:ffff ffff 0000 0000 0000 0000 0000 0000  ................
c0002180:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002190:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021a0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021b0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021c0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021d0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021e0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00021f0:0000 0000 0000 0000 0000 0000 0000 4000  ..............@.
c0002200:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002210:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002220:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002230:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002240:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002250:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002260:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002270:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002280:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002290:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022a0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022b0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022c0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022d0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022e0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00022f0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002300:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002310:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002320:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002330:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002340:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002350:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002360:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002370:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002380:0000 0000 0000 0000 0000 0000 0000 0000  ................
c0002390:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023a0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023b0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023c0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023d0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023e0:0000 0000 0000 0000 0000 0000 0000 0000  ................
c00023f0:0000 0000 0000 0000 0000 0000 0000 4000  ..............@.

まず ntfsinfo の結果を比較してみる Upd. Seq. Number, Bytes Used, NextAttibute Instance, Attribute instance の数値に変化が見られるがこれはとりあえず無視しても問題なさそうである。

chkdsk 前後の変化で特に興味深いのは MFT ダンプの 0xc002168〜0xc002187 の領域である。
これは $DATA (0x80) の領域で Attribute name: '$Bad' を持つ attribute である。
この部分を切り出して比較すると以下のようになる。

chkdsk 前の
c0002160:2400 4200 6100 6400 039b 442b 3101 9b44  $.B.a.d...D+1..D
c0002170:2b01 2f11 0130 03d3 b400 3101 d4b4 0003  +./..0....1.....
c0002180:888b 1e00 0000 0000 ffff ffff 0000 0000  ................
chkdsk 後
c0002160:2400 4200 6100 6400 0328 854a 0000 0000  $.B.a.d..(.J....
c0002170:ffff ffff 0000 0000 0000 0000 0000 0000  ................
c0002180:0000 0000 0000 0000 0000 0000 0000 0000  ................

$Bad から 0xffffffff(attribute record の終端記号) の間にクラスタチェイン情報らしきものが見える。

Allocated size は 20003848192 (0x4a8528000) であった。
ここで 1 クラスタは 4k(=0x1000) バイトであるから、割り当てられている領域は 0x4a8528 クラスタである。
この数値は chkdsk 後の 0xc0002169〜0xc000216b を見るとリトルエンディアンで 3 バイトだけ格納されていることが確認できる。

では Bad cluster の位置情報と照らし合わせてみよう。
Bad cluster の登録状況は以下の通りであった。
Bad cluster: 0x2b449b - 0x2b449b    (1)
Bad cluster: 0x2b44cb - 0x2b44cb    (1)
Bad cluster: 0x2bf99f - 0x2bf99f    (1)

従って、クラスタのチェインは以下のようになっているはずである。
ディスクの先端
正常な 0x2b449b 個のクラスタ
異常な 0x01     個のクラスタ
正常な 0x2f     個のクラスタ
異常な 0x01     個のクラスタ
正常な 0x00b4d3 個のクラスタ
異常な 0x01     個のクラスタ
正常な 0x1e8b88 個のクラスタ
ディスクの終端

先ほどの chkdsk 前の 0xc002168〜0xc00218B のダンプを整形してみると上記のクラスタチェインの構造が以下のように確認できる。
03   9b 44 2b
31   01        9b 44 2b
01   2f
11   01        30
03   d3 b4 00
31   01        d4 b4 00
03   88 8b 1e
00
00 00 00 00
最後に 0x00 が 4 つあるのは attribute を 8 バイト(64 bit)境界に配置するための padding である。

と、ここで NTFS Documentation とか素晴らしい資料を見つけた。
Example 4 - Sparse, Unfragmented File に Sparse のフォーマットについての解説がある。


コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Wiki内検索

フリーエリア

管理人/副管理人のみ編集できます