mdadm コマンド
mdadm - manage MD devices aka Linux Software RAID
コマンド
mdadm --detail <md デバイス>
mdadm will display a detailed description of the array.
$ sudo mdadm --detail /dev/md0p1
/dev/md0p1:
Version : 1.2
Creation Time : Fri Jul 26 20:43:32 2019
Raid Level : raid1
Array Size : 7325608 (6.99 GiB 7.50 GB)
Used Dev Size : 8381440 (7.99 GiB 8.58 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Fri Jul 26 21:52:05 2019
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Consistency Policy : resync
Name : chamomile:0 (local to host chamomile)
UUID : ea8eedfd:7d4c0967:05f5bdda:bf863138
Events : 611
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
mdadm --fail <md デバイス> <HDD デバイス>
<HDD デバイス> に障害を起こす.
mdadm --add <md デバイス> <HDD デバイス>
<HDD デバイス> を <md デバイス> に追加.
mdadm --remove <md デバイス> <HDD デバイス>
<HDD デバイス> を <md デバイス> から外す.
お試し
1 台目のハードディスク /dev/sda に障害を発生させる
$ sudo mdadm --fail /dev/md0p1 /dev/sda1
mdadm: set /dev/sda1 faulty in /dev/md0p1
$ sudo mdadm --detail /dev/md0p1
/dev/md0p1:
Version : 1.2
Creation Time : Fri Jul 26 20:43:32 2019
Raid Level : raid1
Array Size : 7325608 (6.99 GiB 7.50 GB)
Used Dev Size : 8381440 (7.99 GiB 8.58 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Fri Jul 26 21:55:04 2019
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 1
Spare Devices : 0
Consistency Policy : resync
Name : chamomile:0 (local to host chamomile)
UUID : ea8eedfd:7d4c0967:05f5bdda:bf863138
Events : 621
Number Major Minor RaidDevice State
- 0 0 0 removed
1 8 17 1 active sync /dev/sdb1
0 8 1 - faulty /dev/sda1
確かに /dev/sda1 に障害が起こったことになったらしい.
reboot してみる.
$ sudo reboot
立ち上がる. RAID の状態を確認すると,
$ sudo mdadm --detail /dev/md0p1
/dev/md0p1:
Version : 1.2
Creation Time : Fri Jul 26 20:43:32 2019
Raid Level : raid1
Array Size : 7325608 (6.99 GiB 7.50 GB)
Used Dev Size : 8381440 (7.99 GiB 8.58 GB)
Raid Devices : 2
Total Devices : 1
Persistence : Superblock is persistent
Update Time : Fri Jul 26 21:57:35 2019
State : active, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0
Consistency Policy : resync
Name : chamomile:0 (local to host chamomile)
UUID : ea8eedfd:7d4c0967:05f5bdda:bf863138
Events : 662
Number Major Minor RaidDevice State
- 0 0 0 removed
1 8 17 1 active sync /dev/sdb1
/dev/sdb1 のみで動いている. /dev/sda1 は外されているらしい.
なお, 再起動しなくても,
$ sudo mdadm --remove /dev/md0p1 /dev/sda1
で /dev/sda1 を外せる.
RAIDデバイスにハードディスク /dev/sda1 を追加する
$ sudo mdadm --add /dev/md0p1 /dev/sda1
$ sudo mdadm --detail /dev/md0p1
/dev/md0p1:
Version : 1.2
Creation Time : Fri Jul 26 20:43:32 2019
Raid Level : raid1
Array Size : 7325608 (6.99 GiB 7.50 GB)
Used Dev Size : 8381440 (7.99 GiB 8.58 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Fri Jul 26 21:59:14 2019
State : clean, degraded, recovering
Active Devices : 1
Working Devices : 2
Failed Devices : 0
Spare Devices : 1
Consistency Policy : resync
Rebuild Status : 8% complete
Name : chamomile:0 (local to host chamomile)
UUID : ea8eedfd:7d4c0967:05f5bdda:bf863138
Events : 678
Number Major Minor RaidDevice State
2 8 1 0 spare rebuilding /dev/sda1
1 8 17 1 active sync /dev/sdb1
スペアとして導入された. リビルド中 (8% complete).
もう一度確認すると,
$ sudo mdadm --detail /dev/md0p1
/dev/md0p1:
Version : 1.2
Creation Time : Fri Jul 26 20:43:32 2019
Raid Level : raid1
Array Size : 7325608 (6.99 GiB 7.50 GB)
Used Dev Size : 8381440 (7.99 GiB 8.58 GB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Fri Jul 26 21:59:54 2019
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Consistency Policy : resync
Name : chamomile:0 (local to host chamomile)
UUID : ea8eedfd:7d4c0967:05f5bdda:bf863138
Events : 699
Number Major Minor RaidDevice State
2 8 1 0 active sync /dev/sda1
1 8 17 1 active sync /dev/sdb1
/dev/sda1 は RAID に組み込まれた.