0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

RAIDZ2からのディスク切り離し

Last updated at Posted at 2024-06-26

概要

自宅検証サーバでは、4台のHDDをRAIDZ2によりストレージプールを構成しています。
4本のHDDのうち1台を別用途で使うために、切り離してみました。
RAIDZ2(ZFSのRAID-Z2)では、2つのディスクまでの障害に対してデータ保護が提供されます。したがって、1つのディスクを切り離してもサービスに影響を及ぼすことはありません。
以下に作業手順を記載します。

RAIDZ2からディスクを切り離す手順

1.ストレージプールの確認

zpool status コマンドを使って、現在のストレージプールの状態を確認します。

root@pve:~# zpool status
  pool: zpool
 state: ONLINE
status: Some supported and requested features are not enabled on the pool.
        The pool can still be used, but some features are unavailable.
action: Enable all features using 'zpool upgrade'. Once this is done,
        the pool may no longer be accessible by software that does not support
        the features. See zpool-features(7) for details.
  scan: scrub repaired 0B in 08:24:09 with 0 errors on Sun Jun  9 08:48:11 2024
config:

        NAME        STATE     READ WRITE CKSUM
        zpool       ONLINE       0     0     0
          raidz2-0  ONLINE       0     0     0
            sda     ONLINE       0     0     0
            sdc     ONLINE       0     0     0
            sdd2    ONLINE       0     0     0
            sdb     ONLINE       0     0     0
errors: No known data errors

2.ディスクの識別

切り離したいディスクを特定します。smartctl コマンドを使って、ディスクのIDを確認します。
今回は、6TBのディスクを取り外すため、/dev/sddであることが分かります。

root@pve:~# smartctl -a /dev/sda | egrep "Device Model|Serial Number|User Capacity"
Device Model:     WDC WD40EZRZ-00GXCB
Serial Number:    WD-WCC7K5XXXXXX
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
root@pve:~# smartctl -a /dev/sdb | egrep "Device Model|Serial Number|User Capacity"
Device Model:     WDC WD40EZRZ-00GXCB0
Serial Number:    WD-WCC7K4XXXXXX
User Capacity:    4,000,787,030,016 bytes [4.00 TB]
root@pve:~# smartctl -a /dev/sdc | egrep "Device Model|Serial Number|User Capacity"
Device Model:     WDC WD30EZRX-00D8PB0
Serial Number:    WD-WCC4NCXXXXXX
User Capacity:    3,000,592,982,016 bytes [3.00 TB]
root@pve:~# smartctl -a /dev/sdd | egrep "Device Model|Serial Number|User Capacity"
Device Model:     WDC WD60EZAZ-00SF3B0
Serial Number:    WD-WX12DBXXXXXX
User Capacity:    6,001,175,126,016 bytes [6.00 TB]

3.ディスクのオフライン化

ディスクをオフラインにすることで、ストレージプールから安全に切り離す準備をします。以下のコマンドを実行します。

root@pve:~# zpool offline zpool sdd2

4.プールの状態確認

ディスクをオフラインにした後、プールの状態を再確認します。zpool status を再度実行し、ディスクがオフラインであることを確認します。

root@pve:~# zpool status
  pool: zpool
 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: scrub repaired 0B in 08:24:09 with 0 errors on Sun Jun  9 08:48:11 2024
config:

        NAME        STATE     READ WRITE CKSUM
        zpool       DEGRADED     0     0     0
          raidz2-0  DEGRADED     0     0     0
            sda     ONLINE       0     0     0
            sdc     ONLINE       0     0     0
            sdd2    OFFLINE      0     0     0
            sdb     ONLINE       0     0     0

errors: No known data errors

5.ディスクの取り外し

サーバをシャットダウンして、物理的にディスクを取り外します。
その後起動します。

6.プールの状態確認

プールの状態を再確認します。zpool status を再度実行し、ディスクがオフラインであることを確認します。

root@pve:~# zpool status
  pool: zpool
 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: scrub repaired 0B in 08:24:09 with 0 errors on Sun Jun  9 08:48:11 2024
config:

        NAME        STATE     READ WRITE CKSUM
        zpool       DEGRADED     0     0     0
          raidz2-0  DEGRADED     0     0     0
            sda     ONLINE       0     0     0
            sdc     ONLINE       0     0     0
            sdd2    OFFLINE      0     0     0
            sdb     ONLINE       0     0     0

errors: No known data errors

7.ディスクの交換(オプション)

切り離したディスクを別の用途で利用する場合、新しいディスクを追加してプールをリビルドすることもできます。新しいディスクを挿入し、以下のコマンドでプールに追加します。

zpool replace zpool <オフラインにしたディスクID> <新しいディスクID>

例:

zpool replace mypool sdd2 /dev/sdg

8.リビルドの進行状況の確認

新しいディスクが追加されたら、リビルドの進行状況を確認します。zpool status コマンドを定期的に実行して進行状況を監視します。

zpool status

注意事項

  • RAIDZ2は2つのディスクの障害に耐えることができますが、切り離し後は1つのディスクの障害にしか対応できなくなります。
  • ディスクの切り離しや追加の際には、重要なデータのバックアップを取っておくことが重要です。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?