同じ HDD を2台搭載したマシンで、Software RAID 1 (ミラーリング) 設定をしていて、
片方の HDD に障害が発生した際の復旧手順について紹介します。
※ RAID (レイド)
複数の HDD をまとめて 1 台の HDD として扱う仕組みです。
※ ソフトウェア RAID
ハードウェアを追加することなく、OS の機能だけを使って RAID を実現します。
※ RAID-1 ミラーリング
複数の HDD に同じ内容を書き込む仕組みです。
1 台の HDD が故障した場合には、他の HDD が代わりに機能するため、
データを失うことがありません。
※ここでは、元からある HDD を sdb、交換した HDD を sda とします。
[root@linux ~]# fdisk -l /dev/sdb Device Boot Start End Block Id System /dev/sdb1 * 1 13 104391 fd Linux raid autodetect /dev/sdb2 14 274 2096482+ fd Linux raid autodetect /dev/sdb3 275 1566 10377990 fd Linux raid autodetect
パーティション名、Start、End の数字を記録します。
[root@linux ~]# fdisk /dev/sda
n (新規パーティション作成) → p (基本パーティション)
→ 1 → 1 (開始シリンダ) → 13 (終了シリンダ)
n (新規パーティション作成) → p (基本パーティション)
→ 2 → 14 (開始シリンダ) → 274 (終了シリンダ)
n (新規パーティション作成) → p (基本パーティション)
→ 3 → 275 (開始シリンダ) → 1566 (終了シリンダ)
※入力画面は以下のようになります。
Command (m for help): n (を入力) Command action e extended p primary partition(1-4) p (を入力) Partition number(1-4): 1(を入力) First Cylinder (1-1566, default 1): 1 (を入力) Last Cylinder or +size or +sizeM or +sizeK (1-1566, default 1566): 13 (を入力)
t (パーティションID変更) → 1 (パーティション番号) → fd (Software RAID用ID)
t (パーティションID変更) → 2 (パーティション番号) → fd (Software RAID用ID)
t (パーティションID変更) → 3 (パーティション番号) → fd (Software RAID用ID)
※入力画面は以下のようになります。
Command (m for help): t Partition number(1-4): 1 Hex code (type L to list codes): fd Changed System type of partition 1 to fd (Linux raid autodetect)
a (起動フラグ設定) → 1 (パーティション番号)
※入力画面は以下のようになります。
Command (m for help): a Partition number(1-4): 1
w (ディスクに書き込んでfdiskを終了)
※書き込みを実行するまでは変更したパーティション情報が有効にならない
ので注意してください。
[root@linux ~]# mdadm /dev/md0 --add /dev/sda1 [root@linux ~]# mdadm /dev/md1 --add /dev/sda2 [root@linux ~]# mdadm /dev/md2 --add /dev/sda3
[root@linux ~]# mdadm --detail /dev/md0
[root@linux ~]# mdadm --detail /dev/md1
[root@linux ~]# mdadm --detail /dev/md2
確認のため、以下のコマンドを実行します。
[root@linux ~]# mdadm --detail /dev/md0 [root@linux ~]# mdadm --detail /dev/md2
[root@linux ~]# grub grub> root (hd0,0) grub> setup (hd0) grub> root (hd1,0) grub> setup (hd1) grub> quit