2012/03/11

裸族の二世帯住宅を OSX Lion で初期化する方法

fdiskを使ってマスターブートレコードを初期化することもできたので追記。pdiskを使った場合はAppleパーティションマップでのパーティション管理になるんだけど、この場合、linuxマシンで認識できないことがあった。マスターブートレコードにしておけばその心配がないっぽい。
[2012/3/12 追記]

裸族の二世帯住宅とは、センチュリーからかつて販売されていたRAIDできるHDDケース。使いやすいケースなんだけど、RAID0やRAID1で設定している場合にディスクユーティリティで初期化できない、というOSXユーザにとっては厄介な問題がある。ここなどによると、OSX 10.5以降のディスクユーティリティで起きるらしい。

というわけで、裸族の二世帯住宅を OSX Lion (10.7.x) で初期化(パーティションの切り直し&フォーマット)する方法を備忘録。
※お決まりですが、、、
あくまで自分用の備忘録です。もし参考にやってみようという方がいたら自己責任でどうぞ〜



[方法A] マスターブートレコード方式 (fdisk を使用)

(1) ターミナルから fdisk でマスターブートレコードを初期化

※例えば、HDDケースが /dev/disk1 として認識されている場合
$ fdisk -i /dev/disk1
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory

-----------------------------------------------------
------ ATTENTION - UPDATING MASTER BOOT RECORD ------
-----------------------------------------------------

Do you wish to write new MBR and partition table? [n] y[enter]

(2) 続いて fdisk でパーティションを定義

※単一のパーティションで良ければ auto [style] が便利
$ fdisk -e /dev/disk1
fdisk: could not open MBR file /usr/standalone/i386/boot0: No such file or directory
Enter 'help' for information
fdisk: 1> auto hfs[enter]
fdisk:*1> p[enter]
Disk: /dev/disk1 geometry: 121601/255/63 [1953525169 sectors]
Offset: 0 Signature: 0xAA55
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
------------------------------------------------------------------------
*1: AF 0 1 1 - 1023 254 63 [ 63 - 1953525106] HFS+
2: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
3: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
4: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
fdisk:*1> w[enter]
Writing MBR at offset 0.
fdisk: 1> q[enter]

(3) ディスクユーティリティか newfs_hfs/dev/disk1s1 を初期化



[方法B] Appleパーティションマップ方式(pdisk を使用)

(1) ターミナルから pdisk でパーティションマップを初期化

※例えば、HDDケースが /dev/disk2 として認識されている場合
$ pdisk /dev/disk2
Edit /dev/disk2 -
Command (? for help): i[enter]
map already exists
do you want to reinit? [n/y]: y[enter]
A physical block is 512 bytes: 2048[enter]
A logical block is 512 bytes: [enter]
size of 'device' is 1953525168 blocks (512 byte blocks): [enter]
new size of 'device' is 1953525168 blocks (512 byte blocks)
Command (? for help): p[enter]

Partition map (with 512 byte blocks) on '/dev/disk2'
#: type name length base ( size )
1: Apple_partition_map Apple 63 @ 1
2: Apple_Free Extra 1953525104 @ 64 (931.5G)

Device block size=2048, Number of Blocks=488381292 (931.5G)
DeviceType=0x0, DeviceId=0x0

Command (? for help): c[enter]
First block: 64[enter]
Length in blocks: 1953525104[enter]
Name of partition: Extra[enter]
Command (? for help): p[enter]

Partition map (with 512 byte blocks) on '/dev/disk2'
#: type name length base ( size )
1: Apple_partition_map Apple 63 @ 1
2: Apple_HFS Extra 1953525104 @ 64 (931.5G)

Device block size=2048, Number of Blocks=488381292 (931.5G)
DeviceType=0x0, DeviceId=0x0

Command (? for help): w[enter]
Writing the map destroys what was there before. Is that okay? [n/y]: y[enter]
The partition table has been altered!

Command (? for help): q[enter]

(2) ディスクユーティリティか newfs_hfs/dev/disk2s2 を初期化