CONTENTS
#contents
----
Lastmodified &lastmod;
----
[[SMART error (CurrentPendingSector) detected on host ZFS編]]

*ZFS HDD交換 [#ef89c686]

FreeBSD 11.0-CURRENT #0 r287930 いわゆるAFT(Advanced Format Technology)なWestern DigitalのWD30EZRX 3基のrandz1

インストーラでデフォルト設定(SWAP:のみ2Gから4GにUP:必要なかったのが発覚w)

http://www.wdc.com/global/products/specs/?driveID=927&language=6

http://blogs.yahoo.co.jp/alpha3166/10334103.html

http://hirotomium.com/memories/2011/11/zfsreplace.php


FreeBSD 11 Current のインストーラで出来たHDD3基によるZFSは、こんな風になっています。
 root@blackhole:~ # zpool status
   pool: zroot
  state: ONLINE
   scan: none requested
 config:
 
         NAME        STATE     READ WRITE CKSUM
         zroot       ONLINE       0     0     0
           raidz1-0  ONLINE       0     0     0
             ada0p3  ONLINE       0     0     0
             ada1p3  ONLINE       0     0     0
             ada2p3  ONLINE       0     0     0
 
 errors: No known data errors

ゴミ掃除

 root@blackhole:~ # zpool clear zroot


**HDD(ada0)の交換をしてみます。 [#i0ed067f]

***ada0のシリアル番号を確認します。 [#m78d5f86]

 root@blackhole:~ # camcontrol identify ada0

**HDDを外す準備をします。 [#e02be7c7]

 root@blackhole:~ # zpool offline zroot ada0
 cannot offline ada0: no such device in pool
 root@blackhole:~ # zpool offline zroot ada0p3

partitionまで指示しないとだめなようです。


 root@blackhole:~ # zpool status
   pool: zroot
  state: DEGRADED
 status: One or more devices has been taken offline by the administrator.
         Sufficient replicas exist for the pool to continue functioning in a
         degraded state.
 action: Online the device using 'zpool online' or replace the device with
         'zpool replace'.
   scan: none requested
 config:
 
         NAME                     STATE     READ WRITE CKSUM
         zroot                    DEGRADED     0     0     0
           raidz1-0               DEGRADED     0     0     0
             8999288693416647168  OFFLINE      0     0     0  was /dev/ada0p3
             ada1p3               ONLINE       0     0     0
             ada2p3               ONLINE       0     0     0
 
 errors: No known data errors

**シャットダウンして、新しいHDDに交換します。 [#z071abaa]

真っ新なHDDの状態で、Online the device using 'zpool online' or replace the device with 'zpool replace' とかやっても、交換できません。

 root@blackhole:~ # zpool replace zroot /dev/ada0p3
 cannot open '/dev/ada0p3': No such file or directory

** ada0 に p3を作る [#x4cebbfc]

ada1の状態を見てみる。

 root@blackhole:~ # gpart show ada1
 =>        40  5860533088  ada1  GPT  (2.7T)
           40        1024     1  freebsd-boot  (512K)
         1064         984        - free -  (492K)
         2048     8388608     2  freebsd-swap  (4.0G)
      8390656  5852141568     3  freebsd-zfs  (2.7T)
   5860532224         904        - free -  (452K)

まず、gpart create -s GPT ada0

 root@blackhole:~ # gpart create -s GPT ada0
 ada0 created
 root@blackhole:~ # gpart show ada0
 =>        40  5860533088  ada0  GPT  (2.7T)
           40  5860533088        - free -  (2.7T)

 root@blackhole:~ # gpart bootcode -b /boot/pmbr ada0
 bootcode written to ada0
 root@blackhole:~ # gpart show ada0
 =>        40  5860533088  ada0  GPT  (2.7T)
          40  5860533088        - free -  (2.7T)

 root@blackhole:~ # gpart bootcode -p /boot/gptzfsboot -i 1 ada0
 gpart: invalid partition index


 root@blackhole:~ # gpart add -b 40 -s 1024 -t freebsd-boot ada0
 ada0p1 added

 root@blackhole:~ # gpart show ada0
 =>        40  5860533088  ada0  GPT  (2.7T)
           40        1024     1  freebsd-boot  (512K)
         1064  5860532064        - free -  (2.7T)



 root@blackhole:~ # gpart add -b 1064 -s 8388608 -t freebsd-swap ada0
 ada0p2 added
 root@blackhole:~ # gpart show ada0
 =>        40  5860533088  ada0  GPT  (2.7T)
           40        1024     1  freebsd-boot  (512K)
         1064     8388608     2  freebsd-swap  (4.0G)
      8389672  5852143456        - free -  (2.7T)

SWAPの場所を間違えたので、修正。

 root@blackhole:~ # gpart delete freebsd-swap ada0
 gpart: Option 'i' not specified.
 root@blackhole:~ # gpart delete -i 2 ada0
 ada0p2 deleted
 root@blackhole:~ # gpart show ada0
 =>        40  5860533088  ada0  GPT  (2.7T)
          40        1024     1  freebsd-boot  (512K)
        1064  5860532064        - free -  (2.7T)

消せましたので、もう一度SWAPを置きます。

実は、インストーラでWSAPが2Gとなっていて、4Gに変更したのですが、HDDあたり4Gだったんですね・・・。

 root@blackhole:~ # gpart add -b 2048 -s 8388608 -t freebsd-swap ada0
 ada0p2 added


 root@blackhole:~ # gpart show ada0
 =>        40  5860533088  ada0  GPT  (2.7T)
           40        1024     1  freebsd-boot  (512K)
         1064         984        - free -  (492K)
         2048     8388608     2  freebsd-swap  (4.0G)
      8390656  5852142472        - free -  (2.7T)

治りました。

 root@blackhole:~ # gpart add -b 8390656 -s 5852141568 -t freebsd-zfs ada0
 ada0p3 added
 root@blackhole:~ # gpart show ada0
 =>        40  5860533088  ada0  GPT  (2.7T)
           40        1024     1  freebsd-boot  (512K)
         1064         984        - free -  (492K)
         2048     8388608     2  freebsd-swap  (4.0G)
      8390656  5852141568     3  freebsd-zfs  (2.7T)
   5860532224         904        - free -  (452K)

出来かがったようです。




**リプレースコマンドを打ちます [#i0f914ad]
 root@blackhole:~ # zpool replace zroot ada0p3
 Make sure to wait until resilver is done before rebooting.
 
 If you boot from pool 'zroot', you may need to update
 boot code on newly attached disk 'ada0p3'.
 
 Assuming you use GPT partitioning and 'da0' is your new boot disk
 you may use the following command:
 
         gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0

ということなので、

 root@blackhole:~ # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
 bootcode written to ada0

 root@blackhole:~ # zpool status
   pool: zroot
  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.
   scan: resilver in progress since Wed Sep 23 15:12:39 2015
         17.1G scanned out of 507G at 166M/s, 0h50m to go
         5.65G resilvered, 3.36% done
 config:
 
         NAME                       STATE     READ WRITE CKSUM
         zroot                      DEGRADED     0     0     0
           raidz1-0                 DEGRADED     0     0     0
             replacing-0            UNAVAIL      0     0     0
               8999288693416647168  UNAVAIL      0     0     0  was /dev/ada0p3/old
               ada0p3               ONLINE       0     0     0  (resilvering)
             ada1p3                 ONLINE       0     0     0
             ada2p3                 ONLINE       0     0     0
 
 errors: No known data errors

500GBほどのデータであれば、おおよそ1時間で再構築。案外、早い?

   pool: zroot
  state: ONLINE
   scan: resilvered 168G in 0h52m with 0 errors on Wed Sep 23 16:04:49 2015
 config:
 
         NAME        STATE     READ WRITE CKSUM
         zroot       ONLINE       0     0     0
           raidz1-0  ONLINE       0     0     0
             ada0p3  ONLINE       0     0     0
             ada1p3  ONLINE       0     0     0
             ada2p3  ONLINE       0     0     0
 
 errors: No known data errors

*作業まとめ [#u6c7fa94]

交換するHDDは、ada0 とします。

 状況確認
 # zpool status
 # zpool clear zroot
 交換するHDDのシリアルNoを確認する
 # camcontrol identify ada0
 交換準備
 # zpool offline zroot ada0p3
 # zpool status

シャットダウンして、新しいHDDに交換します。 
 
 # gpart show ada1 の結果を参考にしてpartitionを作る
 
 =>        40  5860533088  ada1  GPT  (2.7T)
           40        1024     1  freebsd-boot  (512K)
         1064         984        - free -  (492K)
         2048     8388608     2  freebsd-swap  (4.0G)
      8390656  5852141568     3  freebsd-zfs  (2.7T)
   5860532224         904        - free -  (452K)
 
 # gpart create -s GPT ada0
 ada0 created
 # gpart add -b 40 -s 1024 -t freebsd-boot ada0
 ada0p1 added
 # gpart add -b 2048 -s 8388608 -t freebsd-swap ada0
 ada0p2 added
 # gpart add -b 8390656 -s 5852141568 -t freebsd-zfs ada0
 ada0p3 added
 # gpart show ada0
 # gpart show ada0  確認

新しいHDDをプールに投入

 # zpool replace zroot ada0p3
 Make sure to wait until resilver is done before rebooting.
 
 If you boot from pool 'zroot', you may need to update
 boot code on newly attached disk 'ada0p3'.
 
 Assuming you use GPT partitioning and 'da0' is your new boot disk
 you may use the following command:
 
         gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0
         
 # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada0
 bootcode written to ada0
 
 # zpool status



http://www.wirednoize.net/freebsd/index.php?zfs%20mirror%20HDD%20%E4%BA%A4%E6%8F%9B


----
Total access &counter(total);:本日 &counter(today);:昨日 &counter(yesterday);
#counter([total|today|yesterday]);

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS