ユーザ用ツール

サイト用ツール


01_linux:99_その他:ソフトウェアraid復旧手順

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
01_linux:99_その他:ソフトウェアraid復旧手順 [2017/12/22 04:34] matsui01_linux:99_その他:ソフトウェアraid復旧手順 [2017/12/22 04:35] (現在) matsui
行 1: 行 1:
 +====== ソフトウェアraid復旧手順 ======
  
 +===== どちらのディスクが障害か調べる =====
 +<box 60% left round orange>
 +$ cat /proc/mdstat \\
 +Personalities : [raid1] \\
 +md0 : active raid1 sdb2[2](F) sda2[0] \\
 +  2096384 blocks [2/1] [U_] \\
 +\\
 +md1 : active raid1 sdb1[2](F) sda1[0]\\
 +  154191744 blocks [2/1] [U_]\\
 +</box>
 +
 +
 +===== 新しく追加したディスクにパーティションを作成 =====
 +<box 60% left round orange|生きているディスクのパーティションをメモしておく >
 +# fdisk -l /dev/sda\\
 +\\
 +Disk /dev/sda: 160.0 GB, 160041885696 bytes\\
 +255 heads, 63 sectors/track, 19457 cylinders\\
 +Units = cylinders of 16065 * 512 = 8225280 bytes\\
 +\\
 + Device Boot      Start         End      Blocks   Id  System\\
 +/dev/sda1                   19196   154191838+  fd  Linux raid autodetect\\
 +/dev/sda2           19197       19457     2096482+  fd  Linux raid autodetect\\
 +</box>
 +
 +<box 60% left round orange|正常なディスクと同じようにパーティションを作成>
 +# fdisk /dev/sdb
 +Command (m for help): n (を入力)\\
 +Command action\\
 + e  extended\\
 + p  primary partition(1-4)\\
 +p (を入力)\\
 +Partition number(1-4): 1(を入力)\\
 +First Cylinder (1-19457, default 1): 1 (を入力)\\
 +Last Cylinder or +size or +sizeM or +sizeK (1-19457, default 19457):  19196(を入力)\\
 +\\
 +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)\\
 +\\
 +Command (m for help): a\\
 +Partition number(1-4): 1\\
 +</box>
 +
 +
 +=== セクターで指定 ====
 +
 +下記のような表示になる場合、シリンダーで指定するとぴったりにならない
 +<code>
 +   Device Boot      Start         End      Blocks   Id  System
 +/dev/sdb1                      32      256000   fd  Linux raid autodetect
 +Partition 1 does not end on cylinder boundary.
 +/dev/sdb2              32       60802   488129536   fd  Linux raid autodetect
 +</code>
 +
 +この場合、セクターで指定してあげる
 +<code>
 +# fdisk -ul /dev/sda
 +   Device Boot      Start         End      Blocks   Id  System
 +/dev/sda1          2048      514047      256000   fd  Linux raid autodetect
 +Partition 1 does not end on cylinder boundary.
 +/dev/sda2          514048   976773119   488129536   fd  Linux raid autodetect
 +
 +# fdisk -u /dev/sdb
 +</code>
 +
 +
 +===== 新しく追加したディスクをRaid1に追加 =====
 +<box 60% left round orange>
 +<code console>
 +  mdadm /dev/md0 --add /dev/sdb2
 +  mdadm /dev/md1 --add /dev/sdb1
 +</code>
 +</box>
 +
 +
 +===== mdadmコマンド =====
 +<box 60% left round orange|状態の表示>
 +<code console>
 +  # cat /proc/mdstat
 +  # mdadm --detail --scan
 +  # mdadm --detail /dev/md1
 +</code>
 +</box>
 +
 +<box 60% left round orange|RAIDからデバイスを切り離し(非アクティブに)>
 +<code console>
 +  # mdadm --fail /dev/md1 /dev/sda1
 +</code>
 +</box>
 +
 +<box 60% left round orange|RAIDからデバイスを取り除く>
 +<code console>
 +  # mdadm --remove /dev/md1 /dev/sda1
 +</code>
 +</box>
 +
 +<box 60% left round orange|RAIDにデバイスを加える>
 +<code console>
 +  # mdadm --add /dev/md1 /dev/sdb1
 +</code>
 +</box>
 +
 +
 +===== 再度ディスク壊れた時の為に、grug-install =====
 +
 +<code>
 +ここを確認し、違っている場合、あわせてあげる
 +# cat /boot/grub/device.map 
 +(hd0)     /dev/sdb
 +(hd1)     /dev/sdc
 +  ↓
 +(hd0)     /dev/sda
 +(hd1)     /dev/sdb
 +
 +# grub-install /dev/md0
 +</code>
 +
 +
 +===== ホットスワップのディスク =====
 +ホットスワップのディスクの場合は\\
 +一度--failで切り離し、--removeした状態でディスクに書き込みを行うと、\\
 +どちらのディスクが使用されているか確認できる。
 +
 +===== Device or resource busy エラー =====
 +  mdadm: cannot open device /dev/sdb2: Device or resource busy
 +
 +下記のコマンドで確認すると、何か掴んでいる
 +  # dmsetup ls
 +  hda1 (253:0) 
 +  hdb1 (253:1)
 +表示されているものを削除すると正常にmdadmできる。
 +  dmsetup remove hda1
 +  dmsetup remove hdb1
 +
 +{{tag>raild}}