Solaris オペレーティングシステムの「format」ユーティリティー執筆者: Greg (shoe) Schuweiler (2004 年 11 月) 多くの人にとって、ハードディスクは「ブラックボックス」であり、データ、プログラム、オペレーティングシステムなどを何らかの方法で格納する小さなデバイスとみなされています。もちろん、それ以外のことに関心を持たないですむかぎり、このアプローチで何の問題もありません。しかし、システム管理者であれば、主な関心事の 1 つはデータの保護であるはずです。もう 1 つ、優先順位の高い関心事として、メモリーと物理ディスク間における効率的なデータ移動があるはずです。この記事では、Solaris OS で利用可能な基本ユーティリティーの 1 つである、
ディスク上のスライスの管理に使用される
もう 1 点、警告しておきたいことがあります。破壊的でないコマンドは破壊的な結果をもたらさないはずですが、実際のシステム上でそれらを実行するかどうかは、読者各自の判断に委ねられています。破壊的なコマンドはディスク上のデータを破壊します。これらのコマンドを実行するのは、その意味を理解できていると確信が持てる場合だけにしてください。 この記事で使用するコマンドは次のとおりです。 ディスクラベル: 欠陥領域リスト: パーティションテーブル: この記事を読み進める際には次の点に注意してください。
この記事を対話形式にするために、テスト可能なディスクが搭載されたシステムを用意することをお勧めします。まず、使用するディスクを r_gps@holstein: format Searching for disks...done AVAILABLE DISK SELECTIONS: 0.c0t0d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> boot /pci@1f,4000/scsi@3/sd@0,0 1.c0t1d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> home /pci@1f,4000/scsi@3/sd@1,0 2.c2t1d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> trashme /pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0 Specify disk (enter its number): 「quit」と入力すれば、終了するか 1 つ前のメニューに戻ることができ、Ctrl+D キーを押せば、 « 警告: echo "adios data" | dd of=/dev/dsk/c2t1d0s2 bs=1 count=512 » ここで、
r_gps@holstein: format
Searching for disks...done
c2t1d0: configured with capacity of 33.92GB
AVAILABLE DISK SELECTIONS:
0. c0t0d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> boot
/pci@1f,4000/scsi@3/sd@0,0
1. c0t1d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107> home
/pci@1f,4000/scsi@3/sd@1,0
2. c2t1d0 <SUN36G cyl 24620 alt 2 hd 27 sec 107>
/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0
Specify disk (enter its number): 2
selecting c2t1d0
[disk formatted]
Disk not labeled. Label it now?
ここで、ディスクにラベルを付ける場合は「y」と入力します。そうすると、このディスクが Solaris OS から使用可能になるため、好都合です。その後、 r_gps@holstein: prtvtoc /dev/dsk/c2t1d0s2 * /dev/dsk/c2t1d0s2 partition map * * Dimensions: * 512 bytes/sector * 107 sectors/track * 27 tracks/cylinder * 2889 sectors/cylinder * 24622 cylinders * 24620 accessible cylinders * * Flags: * 1: unmountable * 10: read-only * * First Sector Last * Partition Tag Flags Sector Count Sector Mount Directory 0 2 00 0 262899 262898 1 3 01 262899 262899 525797 2 5 01 0 71127180 71127179 6 4 00 525798 70601382 71127179 これと同じ情報の一部は r_gps@holstein: format /dev/rdsk/c2t1d0s2
Current partition table (original): Total disk cylinders available: 24620 + 2 (reserved cylinders) Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 90 128.37MB (91/0/0) 262899 1 swap wu 91 - 181 128.37MB (91/0/0) 262899 2 backup wu 0 - 24619 33.92GB (24620/0/0) 71127180 3 unassigned wm 0 0 (0/0/0) 0 4 unassigned wm 0 0 (0/0/0) 0 5 unassigned wm 0 0 (0/0/0) 0 6 usr wm 182 - 24619 33.67GB (24438/0/0) 70601382 7 unassigned wm 0 0 (0/0/0) 0 partition>
r_gps@holstein: dd if=/dev/dsk/c2t1d0s2 of=wart.bin bs=512 count=1 1+0 records in 1+0 records out
これによりバイナリファイルが得られますが、このファイルに対して r_gps@holstein: od -x wart.bin 0000000 5355 4e33 3647 2063 796c 2032 3436 3230 0000020 2061 6c74 2032 2068 6420 3237 2073 6563 0000040 2031 3037 0000 0000 0000 0000 0000 0000 0000060 0000 0000 0000 0000 0000 0000 0000 0000 * 0000200 0000 0001 0000 0000 0000 0000 0008 0002 0000220 0000 0003 0001 0005 0001 0000 0000 0000 0000240 0000 0000 0000 0004 0000 0000 0000 0000 0000260 0000 0000 0000 0000 0000 0000 600d deee 0000300 0000 0000 0000 0000 0000 0000 0000 0000 * 0000640 0000 0000 2729 602e 0000 0000 0000 0001 0000660 602c 0002 001b 006b 0000 0000 0000 0000 0000700 0004 02f3 0000 005b 0004 02f3 0000 0000 0000720 043d 508c 0000 0000 0000 0000 0000 0000 0000740 0000 0000 0000 0000 0000 0000 0000 00b6 0000760 0435 4aa6 0000 0000 0000 0000 dabe 4297 0001000
このバイナリダンプには多くの情報が含まれていますが、それについては Sun による非常に優れたドキュメントが存在するため、その情報をここで繰り返すつもりはありません。SunSolve でドキュメント ID 74087 を検索してください。一言だけ注意しておくと、
r_gps@holstein: format /dev/rdsk/c2t1d0s2
selecting /dev/rdsk/c2t1d0s2
[disk formatted]
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd> - execute <cmd>, then return
quit
format>
筆者は必ず、各ディスクにボリューム名を付けるようにしています。なぜなら、そうするとシステムがより親しみやすくなるからです。また、高可用性クラスタ内では同じディスクドライブを複数のシステムが参照することが起こりえますが、これはそうした場合にも非常に便利です。筆者は、1 対の RAID エンジンによって提供された 120 個を超えるディスクのすべてが、VERITAS クラスタ内の 15 台のシステムから可視になっているケースに出会ったことがあります。各ディスクにボリューム名を付けると、すでに使用されているディスクを特定しやすくなります。ボリューム名の付いていないディスクは未使用です。次の例のようにして format> volname Enter 8-character volume name (remember quotes)[""]:"pigsnot" Ready to label disk, continue? y format>
format> disk
AVAILABLE DISK SELECTIONS:
0. /dev/rdsk/c2t1d0s2 <SUN36G cyl 24620 alt 2 hd 27 sec 107> pigsnot
/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0
Specify disk (enter its number)[0]:
Current Disk = c2t1d0: pigsnot <SUN36G cyl 24620 alt 2 hd 27 sec 107> /pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0
r_gps@holstein: ls /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0* /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:a /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:a,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:b /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:b,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:c /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:c,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:d /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:d,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:e /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:e,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:f /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:f,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:g /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:g,raw /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:h /devices/pci@1f,4000/pci@5/SUNW,isptwo@4/sd@1,0:h,raw 単語「raw」の付いた物理デバイス名は文字デバイスであり、その他はブロックデバイスです。文字「a」はパーティション 0、文字「b」はパーティション 1、といった具合になります。
format> verify Primary label contents: Volume name = < pigsnot> ASCII name = <SUN36G cyl 24620 alt 2 hd 27 sec 107> pcyl = 24622 ncyl = 24620 acyl = 2 nhead = 27 nsect = 107 Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 90 128.37MB (91/0/0) 262899 1 swap wu 91 - 181 128.37MB (91/0/0) 262899 2 backup wu 0 - 24619 33.92GB (24620/0/0) 71127180 3 unassigned wm 0 0 (0/0/0) 0 4 unassigned wm 0 0 (0/0/0) 0 5 unassigned wm 0 0 (0/0/0) 0 6 usr wm 182 - 24619 33.67GB (24438/0/0) 70601382 7 unassigned wm 0 0 (0/0/0) 0
#
# New disk/partition type saved on Fri Aug 6 06:34:05 2004
#
disk_type = "SUN36G" \
: ctlr = SCSI : ncyl = 24620 : acyl = 2 : pcyl = 24622 \
: nhead = 27 : nsect = 107 : rpm = 10025
...
そして、ディスク上の情報を収集するためのオプションのなかで最後に紹介するのは、 format> inq Vendor: FUJITSU Product: MAN3367M SUN36G Revision: 1502 format> ここで注意すべき情報は、リビジョンのレベルです。ファームウェアの更新は、ディスクドライブに対して行われます。このオプションを使えば、使用中のディスクのリビジョンのレベルと、ディスクベンダーから入手可能なリビジョンのレベルとを比較できます。筆者は大規模 RAID アレイ上のディスクのドライブファームウェアをベンダーに更新してもらったことがありますが、彼らはそれをすぐに行いました。筆者はかなり昔に一度か二度、SCSI ディスクのファームウェアを更新したことがあります。その後、そうした面倒な作業は行わなくなりました。その最大のネックは、昨今の環境に含まれるディスクの数と、必要とされる停止時間の長さです。それに、「壊れていないものは直すな」という古い格言が当てはまる場合もあるからです。筆者の場合、システムを停止しないでアップグレードする方法をまだ編み出せていません。
defect both dump /disks/c2t1d0-defect.dat r_gps@holstein: format -f c2t1d0.cmd /dev/rdsk/c2t1d0s2
ただし、
警告:
r_gps@holstein: format /dev/rdsk/c2t1d0s2
selecting /dev/rdsk/c2t1d0s2
[disk formatted]
FORMAT MENU:
disk - select a disk
type - select (define) a disk type
partition - select (define) a partition table
current - describe the current disk
format - format and analyze the disk
repair - repair a defective sector
label - write label to the disk
analyze - surface analysis
defect - defect list management
backup - search for backup labels
verify - read and display labels
save - save new disk/partition definitions
inquiry - show vendor, product and revision
volname - set 8-character volume name
!<cmd> - execute <cmd>, then return
quit
format>
今までにこの設定を行う必要のあったドライブは、IPI ドライブおよび SMD ドライブでした。興味を持った読者は、Google で「ipi smd disk drive」で検索してみてください。その若干の歴史を学べるほか、どこでこれらのタイプのドライブを今でも購入できるかを知ることができます。
さて、ここから、筆者と Sun の見解が大きく異なる分野の話に入ります。たとえば、Sun や筆者が知る Sun のシステムエンジニア (SE) は最近、システムディスクでは、1 つのルートパーティションと、その他すべてで使用するためにもう 1 つのパーティションを作成するように勧めています。これはナンセンスな考えです。ディスク上の各スライスは、OS からは個別のディスクとみなされます。したがって、我々のテストディスクをスライスに分割する前に、筆者がこの点について Sun に同意できない理由を説明しておきましょう。読者も筆者に同意する必要はありませんが、その場合はむしろ、自身で別の記事を書いてください。
あるアプリケーションが暴走して オペレーティングシステムは、各パーティションをそれぞれ個別のファイルシステムとみなします。これは、キャッシュとバッファーがこれらのファイルシステムごとに作成されることを意味します。追加のキャッシュやバッファーによって入出力の負荷がわずかに分散されます。もちろん、バックアップ、相互接続速度、およびディスクコントローラによる制限は受けます。しかし、高入出力負荷時の問題の発生確率が低くなります。 さて、このあたりで筆者の持論を述べるのは終わりにし、partition メニューの説明に移りましょう。これを選択すると、次のような別のメニューが開かれます。
PARTITION MENU:
0 - change `0' partition
1 - change `1' partition
2 - change `2' partition
3 - change `3' partition
4 - change `4' partition
5 - change `5' partition
6 - change `6' partition
7 - change `7' partition
select - select a predefined table
modify - modify a predefined partition table
name - name the current table
print - display the current table
label - write partition map and label to the disk
!<cmd> - execute <cmd>, then return
quit
筆者が発見したもっとも簡単なパーティション分割の方法は、次のとおりです。partition メニューに入ったらすぐに、 Current partition table (original): Total disk cylinders available: 24620 + 2 (reserved cylinders) Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 90 128.37MB (91/0/0) 262899 1 swap wu 91 - 181 128.37MB (91/0/0) 262899 2 backup wu 0 - 24619 33.92GB (24620/0/0) 71127180 3 unassigned wm 0 0 (0/0/0) 0 4 unassigned wm 0 0 (0/0/0) 0 5 unassigned wm 0 0 (0/0/0) 0 6 usr wm 182 - 24619 33.67GB (24438/0/0) 70601382 7 unassigned wm 0 0 (0/0/0) 0
これはデフォルトのパーティションテーブルであり、どのパーティションも決してオーバーラップしないように注意しながら変更する必要があります。パーティションを変更するためのもっとも安全な方法は、
partition> modify
Select partitioning base:
0. Current partition table (original)
1. All Free Hog
Choose base (enter number) [0]?
デフォルトでは現在のパーティションを変更することになりますが、それで問題ありません。実際、結果にさほどの違いは生じません。「Current partition table」を選択した場合、
partition> 0 Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 90 128.37MB (91/0/0) 262899 Enter partition id tag[root]: Enter partition permission flags[wm]: Enter new starting cyl[0]: Enter partition size [262899b, 91c, 90e, 128.37mb, 0.13gb]: 256mb パーティション ID タグとアクセス権フラグの質問には「?」を入力することもできますが、その場合、使用可能な応答が表示されます。「P」キーを再度押すと、解決すべき問題が発生していることがわかります。 Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 181 256.74MB (182/0/0) 525798 1 swap wu 91 - 181 128.37MB (91/0/0) 262899 ...パーティション 0 とパーティション 1 がオーバーラップしています。パーティションを作成する際には、作成するパーティションがどれもオーバーラップしていないことを必ず確認してください。作成するパーティションの個数やサイズは実際のところ、読者のサイトやニーズ、経験などに依存します。筆者の場合、作業完了後に次のようになりました。 Current partition table (original): Total disk cylinders available: 24620 + 2 (reserved cylinders) Part Tag Flag Cylinders Size Blocks 0 root wm 0 - 181 56.74MB (182/0/0) 525798 1 swap wu 182 - 272 128.37MB (1452/0/0) 4194828 2 backup wu 0 - 24619 33.92GB (24620/0/0) 71127180 3 unassigned wm 3540 - 4265 1.00GB (726/0/0) 2097414 4 unassigned wm 0 0 (0/0/0) 0 5 unassigned wm 4266 - 4991 1.00GB (726/0/0) 2097414 6 usr wm 273 - 2087 2.50GB (1815/0/0) 5243535 7 var wm 2088 - 3539 2.00GB (1452/0/0) 4194828
さらにパーティションテーブルを書き込む必要があります。それを行うのは簡単で、
Sun からディスクを購入した場合、
さて、いかがだったでしょうか。数個のディスクのパーティションをフォーマットして設定する場合には何の問題もありません。若干の入力作業が必要になりますが、我慢できるレベルです。一方、読者が大規模な RAID アレイの管理を任され、10 個どころか 200 個ものディスクを同様に構成する必要に迫られた場合はどうすればよいでしょうか。筆者は、ある大規模イメージ処理プロジェクトでそうした作業を行う必要に迫られた友人を知っています。彼女は、
いつものように、 * Partition Tag Flag First Sector Sector Count 0 2 00 4194828 1048707 1 7 00 5243535 4145715 2 5 00 0 71127180 3 3 01 0 4194828 4 0 00 9389250 2097414 5 0 00 11486664 8389656 6 4 00 19876320 6292242
したがって、最良の方法は、必要な構成に対するディスクの 1 つで fmthard -i -n "" /dev/rdsk/c2t1d0s2 > ./mypartition.dat
このコマンドは、 « fmthard -s mypartition.dat -n "volumename" /dev/rdsk/cxtydzs2 »
さて、
-e Enable SCSI expert menu. Note this option is not
recommended for casual use.
読者がどうかは分かりませんが、筆者はこのオプションを試す必要に迫られたことがあります。 scsi - independent SCSI mode selects cache - enable, disable or query SCSI disk cache
次に cache オプションですが、これを選択すると、ディスクの読み取りおよび書き込みキャッシュのメニューが表示されます。すべての SCSI ディスクがキャッシュを備えているとはかぎりませんし、キャッシュを備えているディスクのすべてでキャッシュオプションの変更が可能かどうかもわかりません。このキャッシュはディスク上に存在する少量のメモリーであり、システムのメモリーとは何の関係もありません。つまり、各ディスクは少しずつ異なっている可能性があり、これらの設定を変更するとディスク間で動作が多少変わる可能性がある、ということです。筆者の経験上、読み取りキャッシュは通常有効になっていますが、これは妥当です。なぜなら、読み取り処理中に電源が切れても何も失われないからです。データは依然として、ディスク上に存在しているはずです。同様に、筆者の経験上、書き込みキャッシュは常に無効になっています。電源が切れると書き込みキャッシュ内のデータはすべて失われてしまうため、これは妥当です。筆者がこれを有効にし、IOzone を使って入出力負荷を比較してみたところ、書き込み処理が、ほとんど改善しないものから大幅な改善があったものまで幅がありました。この改善率は、ディスクのモデルやベンダーによって変化します。
ここでは、 format> label [0] SMI Label [1] EFI Label Specify Label type[0]:
筆者は、SMI は Sun Microsystems を意味していると信じています。これがデフォルトのオプションですが、このオプションは、 EFI (Extensible Firmware Interface) ラベルを選択すると、次のように別のパーティションが表示されます。 ascii name = <FUJITSU MAN3367M SUN36G 1502 43d671f> bytes/sector = 512 sectors = 71132958 accessible sectors = 71132925 Part Tag Flag First Sector Size Last Sector 0 root wm 34 128.35MB 262898 1 swap wu 262899 128.37MB 525797 2 unassigned wm 0 0 0 3 unassigned wm 0 0 0 4 unassigned wm 0 0 0 5 unassigned wm 0 0 0 6 usr wm 525798 33.66GB 71116540 7 unassigned wm 0 0 0 8 reserved wm 71116541 8.00MB 71132924 format> EFI の詳細は、Intel の Web サイトの Extensible Firmware Interface ページを参照してください。
さて、いかがだったでしょうか。読者が 執筆者紹介 Greg (shoe) Schuweiler はこの 20 年間、フレンドリーな米国中西部で、コンサルタント、組み込みソフトウェア設計者、Oracle DBA、およびその他のさまざまな変わった役職として働いてきました。彼はこの 8 年間、UNIX SA という高貴な仕事に就いています。連絡先は gshoe@xadd.org です。
Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License. |
BigAdmin SubscriptionsBigAdmin Areas
BigAdmin Sun Center
BigAdmin Topics | ||||||