Solaris10にUSB-HDDを接続し、ZFSで利用する方法
Solaris10マシンに、USB-HDDを接続し、ZFSで利用する方法を書いておく。
googleで調べたところ、いくつかブログに記載があった。自分があえて書く必要性はないのだが、備忘録、ということで。
環境は、、、
Solaris10 10/09 32bit(PentiumMマシンのため)
CD/DVDドライブ以外のリムーバブルメディアは使用しないため、smserverやvolfsサービスは停止。
基本的にはこのUSB-HDDを抜かない。(故障した時などを除く。)そして、ファイルサーバ用のファイルシステムとして使用。
セキュリティというよりはメモリ/CPUの負荷を低減するため、インストール時に不要なサービスは停止させている(netservices limited同等)。また、サーバ機としてしようするので、デスクトップ関連のサービスも停止させている。
なお、ZFSまわりは結構、リリース毎に機能向上や仕様変更などあるので、リリースによっては(10/09以外では)手順が異なるかもしれない。
USB-HDD接続
USB-HDDを物理的に接続する。以下のコマンドで、Solarisが認識しているか確認する。
# rmformat[ENTER]
デバイスを探しています...
1. Logical Node: /dev/rdsk/c2t0d0p0
Physical Node: /pci@0,0/pci10cf,11ab@1d,7/hub@3/storage@2/disk@0,0
Connected Device: BUFFALO USB-SATA Bridge 0100
Device Type: Removable
Logical Nodeに着目。/dev/rdsk/c2t0d0p0として認識されている。なぜか、c2t0d0ではなく、c2t0d0p0(パーティション0)?である理由はわからない。しかし、このデバイス名でないと以下の作業ができなかった。
パーティション設定
fdiskを使用する。全ディスクをZFSプールとして利用する。元々Linux ext3で全領域を使用していたので、これを削除し、Solarisで認識できるパーティションにする。
# fdisk /dev/rdsk/c2t0d0p0[ENTER]
Total disk size is 30401 cylinders
Cylinder size is 16065 (512 byte) blocksCylinders
Partition Status Type Start End Length %
========= ====== ============ ===== === ====== ===
1 Linux native 1 30400 30400 100
SELECT ONE OF THE FOLLOWING:
1. Create a partition
2. Specify the active partition
3. Delete a partition
4. Change between Solaris and Solaris2 Partition IDs
5. Exit (update disk configuration and exit)
6. Cancel (exit without updating disk configuration)
Enter Selection: 3[ENTER]
以下のようになるので、パーティション1を指定。
Specify the partition number to delete (or enter 0 to exit): 1[ENTER]
すると、確認されるので、yを入力する。
Are you sure you want to delete partition 1? This will make all files and
programs in this partition inaccessible (type "y" or "n").y[ENTER]
パーティションが削除されたことが表示される。
Partition 1 has been deleted.
Enter Selection: 1[ENTER]
パーティションタイプの選択を求められるので、SOLARIS2を選ぶ。
Select the partition type to create:
1=SOLARIS2 2=UNIX 3=PCIXOS 4=Other
5=DOS12 6=DOS16 7=DOSEXT 8=DOSBIG
9=DOS16LBA A=x86 Boot B=Diagnostic C=FAT32
D=FAT32LBA E=DOSEXTLBA F=EFI 0=Exit? 1[ENTER]
ディスクの容量のうち、どのくらいをこのパーティションで使用するか、%(パーセンテージ)で入力する。今回は全部使用するので、100でよい。(個人的には全部を使用しない時は、GBとかで指定できると嬉しいのだが、指定できるかどうか調べていない。。。)
Specify the percentage of disk to use for this partition
(or type "c" to specify the size in cylinders). 100[ENTER]
次に、そのパーティションをアクティブにするかどうか尋ねられる。まぁ、アクティブにしておく。
Should this become the active partition? If yes, it will be activated
each time the computer is reset or turned on.
Please type "y" or "n". y[ENTER]
作成できた。更新して終了するため、5を入力する。
Total disk size is 30401 cylinders
Cylinder size is 16065 (512 byte) blocksCylinders
Partition Status Type Start End Length %
========= ====== ============ ===== === ====== ===
1 Active Solaris2 1 30400 30400 100
SELECT ONE OF THE FOLLOWING:
1. Create a partition
2. Specify the active partition
3. Delete a partition
4. Change between Solaris and Solaris2 Partition IDs
5. Exit (update disk configuration and exit)
6. Cancel (exit without updating disk configuration)
Enter Selection: 5[ENTER]
Partition 1 is now the active partition.
#
ZFSのファイルシステム作成
まずはpoolを作成する。なお、私はブートディスクもZFSにしているのだが、USB-HDDは独立して管理させたいため、プールも独立したものを作成した。
# zpool create spool c2t0d0p0[ENTER]
# zpool list[ENTER]
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
spool 232G 116K 232G 0% ONLINE -
rpool 111G 5.48G 106G 4% ONLINE -
spoolなるプールができた。このプール上に、ZFSのファイルシステムを作成する。マウントポイントは、/shareにする。(/exportはデフォルトでrpool上で使用されているため。)
# zfs create -o mountpoint=/share spool/share[ENTER]
# zfs list[ENTER]
NAME USED AVAIL REFER MOUNTPOINT
spool 111K 228G 21K /spool
spool/share 21K 228G 21K /share
rpool 6.22G 103G 33K /rpool
rpool/ROOT 4.29G 103G 21K legacy
rpool/ROOT/s10x_u8wos_08a 4.29G 103G 4.29G /
rpool/export 4.29G 103G 21K /export
rpool/export/home 4.29G 103G 21K /export/home
rpool/dump 1.00G 103G 1.00G -
rpool/swap 763M 104G 16K -
とりあえず、でけた。
nfsやsambaで共有するのに、zfsファイルシステムへのオプションで制御できそうなのだが、これについてはまた別途書くことにしよう。