====== ソフトウェアraid復旧手順 ====== ===== どちらのディスクが障害か調べる ===== $ 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_]\\ ===== 新しく追加したディスクにパーティションを作成 ===== # 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 * 1 19196 154191838+ fd Linux raid autodetect\\ /dev/sda2 19197 19457 2096482+ fd Linux raid autodetect\\ # 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\\ === セクターで指定 ==== 下記のような表示になる場合、シリンダーで指定するとぴったりにならない Device Boot Start End Blocks Id System /dev/sdb1 * 1 32 256000 fd Linux raid autodetect Partition 1 does not end on cylinder boundary. /dev/sdb2 32 60802 488129536 fd Linux raid autodetect この場合、セクターで指定してあげる # 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 ===== 新しく追加したディスクをRaid1に追加 ===== mdadm /dev/md0 --add /dev/sdb2 mdadm /dev/md1 --add /dev/sdb1 ===== mdadmコマンド ===== # cat /proc/mdstat # mdadm --detail --scan # mdadm --detail /dev/md1 # mdadm --fail /dev/md1 /dev/sda1 # mdadm --remove /dev/md1 /dev/sda1 # mdadm --add /dev/md1 /dev/sdb1 ===== 再度ディスク壊れた時の為に、grug-install ===== ここを確認し、違っている場合、あわせてあげる # cat /boot/grub/device.map (hd0) /dev/sdb (hd1) /dev/sdc ↓ (hd0) /dev/sda (hd1) /dev/sdb # grub-install /dev/md0 ===== ホットスワップのディスク ===== ホットスワップのディスクの場合は\\ 一度--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}}