ZFSでリハウス

地デジ録画なんてやってたら、1TBx2のZFS mirrorなんかあっという間に埋まっちゃうわけで。
ここのところ空きが50GB前後をうろうろして、そろそろいかんなーと思ってたところが、WD20EARS 2TBが10k円を切ってたので、ふらふらっと2台お買い上げ。これが例の4kセクターってやつですよ、えぇ。
入れ替え前にぐぐってみたけど、ZFSのセクターサイズってどうやって指定するのかわからん。recordsizeのこと?デフォルトで128kだったりするようだが。
というわけで、mirrorの片方ずつ置き換えて同期させていく作戦の備忘録。

稼働中のサーバをshutdown

止める前に、片方切り離す。

# zpool offline pool1 ad6p2
# zpool status
  pool: pool1
 state: DEGRADED
status: One of more devices has experienced an unrecoverable error.  An
        attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
        using 'zpool clear' or replace the device with 'zpool replace'.
   see: http://www.sun.com/msg/ZFS-8000-9P
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        pool1       DEGRADED     0     0     0
          mirror    DEGRADED     0     0     0
            ad6p2   OFFLINE      0   248     0
            ad4p2   ONLINE       0     0     0

errors: No known data errors
# shutdown -p now

ad6を置き換えてboot

ZFSroot化して以来、片肺で起動するのは初めてだったのでどきどきしたが、loaderメニューが出たので一安心。single user modeで起動して、以降たんたんと。
シリアルコンソールなんかないので、以降のsingle user modeの実行例は目視と手打ちです。つづり間違っているところがあるかもしれませんが、無保証ということで。

ad6にGPTを切る

4kセクターということで、ad6p1の開始を8の倍数に切り上げて、40からとした。
8-currentの時は、LOADER_ZFS_SUPPORT=YESでmake worldしとかないとgptzfsbootが存在しなかったはずだけど、8-stableでもそうなのかどうかは知らない。9-currentは使ったことないけど、4kセクター対応が進んでいるとか何とかいう噂。

# gpart create -s GPT ad6
ad6 created
# gpart show ad6
=>        34  3907029101 ad6 GPT (1.8T)
          34  3907029101     - free - (1.8T)

# gpart add -b 40 -s 128 -t freebsd-boot ad6
ad6p1 added
# gpart show ad6
=>        34  3907029101 ad6 GPT (1.8T)
	  34  6              - free - (3.0K)
	  40  128          1 freebsd-boot (64K)
          168 3907020967     - free - (1.8T)

# gpart add -b 168 -s 3907020967 -t freebsd-zfs ad6
ad6p2 added
# gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ad6
ad6 has bootcode

mirrorをリビルド

resilverって、どう読むんだろうか。

# zpool replace pool1 ad6p2
# zpool status
  pool: pool1
 state: DEGRADED
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
 scrub: resilver in progress for 0h8m, 0.06% done, 233h23m to go
config:

        NAME             STATE     READ WRITE CKSUM
        pool1            DEGRADED     0     0     0
          mirror         DEGRADED     0     0     0
            replacing    DEGRADED     0     0     0
              ad6p2/old  OFFLINE      0 3.48K     0
              ad6p2      ONLINE       0     0     0  537M resilvered
            ad6p2        ONLINE       0     0     0  69.9M resilvered

errors: No known data errors

233時間かかるって。。。