Recent site activity

OpenSolaris‎ > ‎

zfsにUSBディスクを追加

USBハードディスクをOpenSolarisに追加しました。その記録です。
ミラー化や連結も一瞬でできます。ZFSは素晴らしい。

1)認識したHDDのIDを調べる
/var/adm/messgaesのログからUSB storageを検索し、デバイスIDを見つける。

takumi@opensolaris:~$ grep storage /var/adm/messages
Dec 30 05:46:49 opensolaris usba: [ID 912658 kern.info] USB 2.0 device (usb7f7,120) operating at hi speed (USB 2.x) on USB 2.0 root hub: storage@1, scsa2usb1 at bus address 2
Dec 30 05:46:49 opensolaris genunix: [ID 936769 kern.info] scsa2usb1 is /pci@0,0/pci1043,81ef@13,5/storage@1
Dec 30 05:46:49 opensolaris genunix: [ID 408114 kern.info] /pci@0,0/pci1043,81ef@13,5/storage@1 (scsa2usb1) online
Dec 30 05:46:49 opensolaris genunix: [ID 936769 kern.info] sd2 is /pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0
Dec 30 05:46:49 opensolaris genunix: [ID 408114 kern.info] /pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0 (sd2) online
Dec 30 05:46:49 opensolaris genunix: [ID 936769 kern.info] sd3 is /pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1
Dec 30 05:46:49 opensolaris genunix: [ID 408114 kern.info] /pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1 (sd3) online
takumi@opensolaris:~$


2)認識したデバイス名と突き合わせzpoolでのデバイス名を確定する
/dev/rdskから1)で見つけたデバイスIDへリンクしたデバイス名を見つける。
$ cd /dev/rdsk
$ ls -l | grep "storage@1" > ~/Desktop/grep-storage.txt
$ cat ~/Desktop/grep-storage.txt
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0p0 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:q,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0p1 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:r,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0p2 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:s,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0p3 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:t,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0p4 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:u,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s0 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:a,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s1 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:b,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s10 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:k,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s11 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:l,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s12 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:m,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s13 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:n,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s14 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:o,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s15 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:p,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s2 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:c,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s3 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:d,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s4 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:e,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s5 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:f,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s6 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:g,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s7 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:h,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s8 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:i,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d0s9 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,0:j,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1p0 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:q,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1p1 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:r,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1p2 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:s,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1p3 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:t,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1p4 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:u,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s0 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:a,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s1 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:b,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s10 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:k,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s11 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:l,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s12 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:m,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s13 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:n,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s14 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:o,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s15 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:p,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s2 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:c,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s3 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:d,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s4 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:e,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s5 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:f,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s6 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:g,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s7 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:h,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s8 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:i,raw
lrwxrwxrwx 1 root root 64 2008-12-29 16:51 c6t0d1s9 -> ../../devices/pci@0,0/pci1043,81ef@13,5/storage@1/disk@0,1:j,raw

 c6t0d0p0  c6t0d1p0

で確定。

3)zpoolを構成する

takumi@opensolaris:~$ su -
Password:
Sun Microsystems Inc.    SunOS 5.11    snv_101b    November 2008
You have new mail.

ディスクを連結して大きなディスクにする
root@opensolaris:~# zpool create dpool c6t0d0p0 c6t0d1p0

zfsを作成マウントする
root@opensolaris:~# zfs create dpool/home
root@opensolaris:~# zpool list
NAME    SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
dpool   744G   102K   744G     0%  ONLINE  -
rpool  37.8G  32.3G  5.49G    85%  ONLINE  -

ミラー化したいので一旦ディスクを外す。ディスクのデータは失われる。
root@opensolaris:~# zpool destroy dpool
root@opensolaris:~# zpool list
NAME    SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
rpool  37.8G  32.3G  5.49G    85%  ONLINE  -

ディスクをミラー化して冗長性を高める
root@opensolaris:~# zpool create dpool mirror c6t0d0p0 c6t0d1p0

root@opensolaris:~# zpool list
NAME    SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
dpool   372G    75K   372G     0%  ONLINE  -
rpool  37.8G  32.3G  5.49G    85%  ONLINE  -

再度zfsを作成マウントする
root@opensolaris:~# zfs create dpool/home
root@opensolaris:~# zfs list
NAME                       USED  AVAIL  REFER  MOUNTPOINT
dpool                       99K   366G    18K  /dpool
dpool/home                  18K   366G    18K  /dpool/home
rpool                     34.2G  2.97G  75.5K  /rpool
rpool/ROOT                3.34G  2.97G    18K  legacy
rpool/ROOT/opensolaris     273M  2.97G  2.70G  /
rpool/ROOT/opensolaris-1  3.08G  2.97G  2.80G  /
rpool/dump                1.94G  2.97G  1.94G  -
rpool/export              27.0G  2.97G    19K  /export
rpool/export/home         27.0G  2.97G    19K  /export/home
rpool/export/home/takumi  27.0G  2.97G  27.0G  /export/home/takumi
rpool/swap                1.94G  4.90G    16K  -
root@opensolaris:~#