ZFSのミラーディスク交換
FreeBSDのファイルシステムにZFSを使っています。MirrorしたHDDを2セット連結して、大きなpool(次の図のupool)を作っています。

1. ディスク故障〜交換
DEGRADED
なのですが、mirror-0の1つの片側のHDDが壊れてしまいました。UNAVAILとなっています。
# zpool status pool: rpool state: ONLINE status: The pool is formatted using a legacy on-disk format. The pool can still be used, but some features are unavailable. action: Upgrade the pool using 'zpool upgrade'. Once this is done, the pool will no longer be accessible on software that does not support feature flags. scan: scrub repaired 0 in 0h0m with 0 errors on Sat Feb 22 08:51:43 2014 config: NAME STATE READ WRITE CKSUM rpool ONLINE 0 0 0 gpt/zroot ONLINE 0 0 0 errors: No known data errors pool: upool state: DEGRADED status: One or more devices could not be opened. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Attach the missing device and online it using 'zpool online'. see: http://illumos.org/msg/ZFS-8000-2Q scan: resilvered 599M in 0h1m with 0 errors on Sat Apr 22 00:51:30 2017 config: NAME STATE READ WRITE CKSUM upool DEGRADED 0 0 0 mirror-0 DEGRADED 0 0 0 gpt/disk4 ONLINE 0 0 0 block size: 512B configured, 4096B native 10158680820546133657 UNAVAIL 0 0 0 was /dev/gpt/disk2 mirror-1 ONLINE 0 0 0 gpt/disk3 ONLINE 0 0 0 gpt/disk5 ONLINE 0 0 0 block size: 512B configured, 4096B native logs gpt/zil ONLINE 0 0 0 cache gpt/l2arc ONLINE 0 0 0 errors: No known data errors pool: ypool state: ONLINE scan: resilvered 42.8M in 0h0m with 0 errors on Sat Apr 22 01:15:54 2017 config: NAME STATE READ WRITE CKSUM ypool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 gpt/disk0 ONLINE 0 0 0 gpt/disk1 ONLINE 0 0 0 errors: No known data errors
ディスク交換
まずいです。データが失われてしまいます。壊れたディスクを外して、新しいディスクを取り付けました。
[amazonjs asin="B01M0E8TRQ" locale="JP"]使っているのは、2.5インチの2TBです。これは、15mm厚なので、通常のNotePCには入らないと思います。
gpart showで、状態を確認します。新しいディスクは、ada2につながっています。新しいといっても、実験で使っていたので、捨てても構わないデータが入っています。
# gpart show
=> 34 2930277101 ada0 GPT (1.4T)
34 2930277101 1 freebsd-zfs (1.4T)
=> 34 2930277101 ada1 GPT (1.4T)
34 2930277101 1 freebsd-zfs (1.4T)
=> 34 2930277101 ada3 GPT (1.4T)
34 2930277101 1 freebsd-zfs (1.4T)
=> 34 62533229 ada4 GPT (30G)
34 128 1 freebsd-boot (64K)
162 16777216 2 freebsd-zfs (8.0G)
16777378 33554432 3 freebsd-zfs (16G)
50331810 12201453 4 freebsd-zfs (5.8G)
=> 34 3907029101 ada5 GPT (1.8T)
34 6 - free - (3.0K)
40 3907029088 1 freebsd-zfs (1.8T)
3907029128 7 - free - (3.5K)
=> 34 3907029101 ada6 GPT (1.8T)
34 6 - free - (3.0K)
40 3907029088 1 freebsd-zfs (1.8T)
3907029128 7 - free - (3.5K)
=> 1 3907029167 ada2 MBR (1.8T)
1 39 - free - (20K)
40 1060250 1 linux-data (518M)
1060290 6 - free - (3.0K)
1060296 1060284 2 linux-data (518M)
2120580 4 - free - (2.0K)
2120584 3903891386 3 linux-data (1.8T)
3906011970 6 - free - (3.0K)
3906011976 996024 4 linux-data (486M)
3907008000 21168 - free - (10M)
=> 1 3907029167 diskid/DISK-84IJPY67T MBR (1.8T)
1 39 - free - (20K)
40 1060250 1 linux-data (518M)
1060290 6 - free - (3.0K)
1060296 1060284 2 linux-data (518M)
2120580 4 - free - (2.0K)
2120584 3903891386 3 linux-data (1.8T)
3906011970 6 - free - (3.0K)
3906011976 996024 4 linux-data (486M)
3907008000 21168 - free - (10M)
2. GPTにパーティションを切り直す
ディスク初期化
GPTディスクの準備は、以前やりました。基本的に、同じ方法でできます。
ZFSで既存ディスクをミラー化する
まずは、初期化です。使いかけのディスクだったので、-Fオプションをつけて強制消去します。
# gpart destroy ada2 gpart: Device busy # gpart destroy -F ada2 ada2 destroyed
GPTパーティション作成
# gpart create -s gpt ada2
ada2 created
# gpart show
=> 34 2930277101 ada0 GPT (1.4T)
34 2930277101 1 freebsd-zfs (1.4T)
=> 34 2930277101 ada1 GPT (1.4T)
34 2930277101 1 freebsd-zfs (1.4T)
=> 34 2930277101 ada3 GPT (1.4T)
34 2930277101 1 freebsd-zfs (1.4T)
=> 34 62533229 ada4 GPT (30G)
34 128 1 freebsd-boot (64K)
162 16777216 2 freebsd-zfs (8.0G)
16777378 33554432 3 freebsd-zfs (16G)
50331810 12201453 4 freebsd-zfs (5.8G)
=> 34 3907029101 ada5 GPT (1.8T)
34 6 - free - (3.0K)
40 3907029088 1 freebsd-zfs (1.8T)
3907029128 7 - free - (3.5K)
=> 34 3907029101 ada6 GPT (1.8T)
34 6 - free - (3.0K)
40 3907029088 1 freebsd-zfs (1.8T)
3907029128 7 - free - (3.5K)
=> 34 3907029101 ada2 GPT (1.8T)
34 3907029101 - free - (1.8T)
=> 34 3907029101 diskid/DISK-84IJPY67T GPT (1.8T)
34 3907029101 - free - (1.8T)
3. ZFSとしてフォーマットし、ラベルを付ける
“disk6″と言う名前をつけました。
# gpart add -t freebsd-zfs -l disk6 ada2
ada2p1 added
root@freebsd:~ # gpart show
=> 34 2930277101 ada0 GPT (1.4T)
34 2930277101 1 freebsd-zfs (1.4T)
=> 34 2930277101 ada1 GPT (1.4T)
34 2930277101 1 freebsd-zfs (1.4T)
=> 34 2930277101 ada3 GPT (1.4T)
34 2930277101 1 freebsd-zfs (1.4T)
=> 34 62533229 ada4 GPT (30G)
34 128 1 freebsd-boot (64K)
162 16777216 2 freebsd-zfs (8.0G)
16777378 33554432 3 freebsd-zfs (16G)
50331810 12201453 4 freebsd-zfs (5.8G)
=> 34 3907029101 ada5 GPT (1.8T)
34 6 - free - (3.0K)
40 3907029088 1 freebsd-zfs (1.8T)
3907029128 7 - free - (3.5K)
=> 34 3907029101 ada6 GPT (1.8T)
34 6 - free - (3.0K)
40 3907029088 1 freebsd-zfs (1.8T)
3907029128 7 - free - (3.5K)
=> 34 3907029101 ada2 GPT (1.8T)
34 6 - free - (3.0K)
40 3907029088 1 freebsd-zfs (1.8T)
3907029128 7 - free - (3.5K)
=> 34 3907029101 diskid/DISK-84IJPY67T GPT (1.8T)
34 6 - free - (3.0K)
40 3907029088 1 freebsd-zfs (1.8T)
3907029128 7 - free - (3.5K)
ディスクの切断と接続
次のウェブページに記載されています。ZFSを使う人は、必ずお世話になるページだと思います。
既存ディスクをdetach
detachします。
# zpool detach upool 10158680820546133657 root@freebsd:~ # zpool status pool: rpool state: ONLINE status: The pool is formatted using a legacy on-disk format. The pool can still be used, but some features are unavailable. action: Upgrade the pool using 'zpool upgrade'. Once this is done, the pool will no longer be accessible on software that does not support feature flags. scan: scrub repaired 0 in 0h0m with 0 errors on Sat Feb 22 08:51:43 2014 config: NAME STATE READ WRITE CKSUM rpool ONLINE 0 0 0 gpt/zroot ONLINE 0 0 0 errors: No known data errors pool: upool state: ONLINE status: One or more devices are configured to use a non-native block size. Expect reduced performance. action: Replace affected devices with devices that support the configured block size, or migrate data to a properly configured pool. scan: resilvered 599M in 0h1m with 0 errors on Sat Apr 22 00:51:30 2017 config: NAME STATE READ WRITE CKSUM upool ONLINE 0 0 0 gpt/disk4 ONLINE 0 0 0 block size: 512B configured, 4096B native mirror-1 ONLINE 0 0 0 gpt/disk3 ONLINE 0 0 0 gpt/disk5 ONLINE 0 0 0 block size: 512B configured, 4096B native logs gpt/zil ONLINE 0 0 0 cache gpt/l2arc ONLINE 0 0 0 errors: No known data errors pool: ypool state: ONLINE scan: resilvered 42.8M in 0h0m with 0 errors on Sat Apr 22 01:15:54 2017 config: NAME STATE READ WRITE CKSUM ypool ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 gpt/disk0 ONLINE 0 0 0 gpt/disk1 ONLINE 0 0 0 errors: No known data errors
既存ディスクにattachして、ミラー化
# zpool attach upool gpt/disk4 gpt/disk6
root@freebsd:~ # zpool status
pool: rpool
state: ONLINE
status: The pool is formatted using a legacy on-disk format. The pool can
still be used, but some features are unavailable.
action: Upgrade the pool using 'zpool upgrade'. Once this is done, the
pool will no longer be accessible on software that does not support feature
flags.
scan: scrub repaired 0 in 0h0m with 0 errors on Sat Feb 22 08:51:43 2014
config:
NAME STATE READ WRITE CKSUM
rpool ONLINE 0 0 0
gpt/zroot ONLINE 0 0 0
errors: No known data errors
pool: upool
state: ONLINE
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 Fri Apr 28 05:35:40 2017
6.23M scanned out of 2.18T at 532K/s, (scan is slow, no estimated time)
3.16M resilvered, 0.00% done
config:
NAME STATE READ WRITE CKSUM
upool ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
gpt/disk4 ONLINE 0 0 0 block size: 512B configured, 4096B native
gpt/disk6 ONLINE 0 0 0 block size: 512B configured, 4096B native (resilvering)
mirror-1 ONLINE 0 0 0
gpt/disk3 ONLINE 0 0 0
gpt/disk5 ONLINE 0 0 0 block size: 512B configured, 4096B native
logs
gpt/zil ONLINE 0 0 0
cache
gpt/l2arc ONLINE 0 0 0
errors: No known data errors
pool: ypool
state: ONLINE
scan: resilvered 42.8M in 0h0m with 0 errors on Sat Apr 22 01:15:54 2017
config:
NAME STATE READ WRITE CKSUM
ypool ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
gpt/disk0 ONLINE 0 0 0
gpt/disk1 ONLINE 0 0 0
errors: No known data errors
コピーが始まりました。後は終了を待つだけです。
今になってきなったんだけれど、最初に入っていたデータって、なんだったんだろう。












ディスカッション
コメント一覧
まだ、コメントがありません