Window7のBootCampパーティションがMacOSXから読めない問題がなおったあ

以前記事を書いた、Windows7インストール後に、Mac OS XからBootCampパーティションが読めなくなる問題がついに解決。やっぱパーティション情報がおかしくなってたみたいです。前回はParallelsインストールしたら読めなくなったと書いたのですが、昨日Window7再インストールしたら、再起動しただけですでにMacからWindows7パーティションは読めませんでした。Parallelsはシロでした。すんません。

解決の参考記事は↓のURLの8月2日の投稿。

http://forums.macrumors.com/showthread.php?t=979951

上の記事はあまりにも簡素なので、以下に僕がやった作業をメモとして記事にのこしておきます。
【注意】環境によってgdiskコマンドで設定する値は全く異なりますので、この記事はあくまで僕の環境での操作メモということで。全く同じ操作をすると普通にハードディスク壊して終わりになりますので、意味が分からない方は絶対同じ操作をしないでください。

作業メモ

まず、rEFItってツールをダウンロードします。ダウンロードしたdmgを開くとPartition Inspectorってアイコンがあるので、それを起動します。Analyzeボタンを押して、管理者パスワードを入力すると、↓のような表示が出ます。

Current GPT partition table:
 #      Start LBA      End LBA  Type
 1             40       409639  EFI System (FAT)
 2         409640    981876775  Mac OS X HFS+
 3      982140928   1953523711  Basic Data

Current MBR partition table:
 # A    Start LBA      End LBA  Type
 1              1       409639  ee  EFI Protective
 2         409640    981876775  af  Mac OS X HFS+
 3 *    981878784    982083583  07  NTFS/HPFS
 4      982083584   1953521663  07  NTFS/HPFS

最初のGPT partition tableがMacOSXが参照するパーティション情報で、MBR partition tableがWindowsが参照するパーティション情報です。最初の2つのパーティション情報はGPTもMBRも一致しています。しかし残りの領域(Window7がインストールされている領域)については、GPTの方ではパーティションが1個なのに、MBRの方ではパーティションが2個になってます。GPTのパーティション情報がMBRの情報と食い違ってしまっています。これがMac側でWindows7パーティションがマウントできなくなっている理由です。

この問題を修正するには、GPT partition tableを直接いじってMBRと一致するように修正します。↑の例だと、パーティション3を消して、3,4を作り直します。修正後のGPTは↓のようになってほしい。

Current GPT partition table:
 #      Start LBA      End LBA  Type
 1             40       409639  EFI System (FAT)
 2         409640    981876775  Mac OS X HFS+
 3     981878784    982083583  07  Basic Data
 4     982083584   1953521663  07  Basic Data

GPTを修正するにはGPT fdiskを使います。GPT fdiskをインストールしたら、コマンドラインからsudo gdisk で起動。

Brezza-no-iMac:~ brezza$ sudo gdisk
Password:
GPT fdisk (gdisk) version 0.6.10

Type device filename, or press  to exit:

ハードディスクのデバイス名を聞かれるので、デバイス名を入力。以下の例では/dev/disk0と入力しますが、システム複数台ディスクがつながってるときは別のデバイス名(/dev/disk1とか/dev/disk2とか)になるので注意。起動すると、コマンドラインが出ます。

Type device filename, or press  to exit: /dev/disk0

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): 

?でとりあえずヘルプ確認。

Command (? for help): ?
b	back up GPT data to a file
c	change a partition's name
d	delete a partition
i	show detailed information on a partition
l	list known partition types
n	add a new partition
o	create a new empty GUID partition table (GPT)
p	print the partition table
q	quit without saving changes
r	recovery and transformation options (experts only)
s	sort partitions
t	change a partition's type code
v	verify disk
w	write table to disk and exit
x	extra functionality (experts only)
?	print this menu

Command (? for help):

なんか操作を間違ったらqコマンドで脱出すれば助かります。

とりあえずiコマンドでパーティション情報を確認。

Command (? for help): i
Partition number (1-3): 3
Partition GUID code: EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (Linux/Windows data)
Partition unique GUID: C1C1F160-D6AA-478B-96BD-E00282FAD6CC
First sector: 982140928 (at 468.3 GiB)
Last sector: 1953523711 (at 931.5 GiB)
Partition size: 971382784 sectors (463.2 GiB)
Attribute flags: 0000000000000000
Partition name: BOOTCAMP

Command (? for help):

dコマンドで、パーティション情報を消します。

Command (? for help): d
Partition number (1-3): 3

Command (? for help):

nコマンドで、1個目のパーティション情報を作成。 先程Partition Inspectorで確認した、MBR parition tableの情報に基づき、First sector, Last sectorの値をStart LBA, End LBAの値に正確に合わせてパーティションを作ります。

Command (? for help): n
Partition number (3-128, default 3):
First sector (34-1953525134, default = 981876776) or {+-}size{KMGT}: 981878784
Last sector (981878784-1953525134, default = 1953525134) or {+-}size{KMGT}: 982083583
Current type is 'Linux/Windows data'
Hex code (L to show codes, 0 to enter raw code, Enter = 0700): 
Changed type of partition to 'Linux/Windows data'

Command (? for help): 

さらにnコマンドで、2個目のパーティションも作成。

Command (? for help): n
Partition number (4-128, default 4): 
First sector (34-1953525134, default = 982083584) or {+-}size{KMGT}: 982083584
Last sector (982083584-1953525134, default = 1953525134) or {+-}size{KMGT}: 1953521663
Current type is 'Linux/Windows data'
Hex code (L to show codes, 0 to enter raw code, Enter = 0700): 
Changed type of partition to 'Linux/Windows data'

Command (? for help): 

最後にwコマンドで書き込んで終了。間違った設定で書き込むとディスクの中身全滅もありえますので、覚悟のうえ、自己責任で。

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed, possibly destroying your data? (Y/N): y
OK; writing new GUID partition table (GPT).
Warning: The kernel may continue to use old or deleted partitions.
You should reboot or remove the drive.
The operation has completed successfully.

以上で、無事BootCamp領域のディスクがマウントできるようになりました。