1. Create a new RAID array
Create (mdadm —create) is used to create a new array:
1
|
|
or using the compact notation:
1
|
|
/etc/mdadm.conf or /etc/mdadm/mdadm.conf (on debian) is the main configuration file for mdadm. After we create our RAID arrays we add them to this file using:
1
|
|
or on debian
1
|
|
We can’t remove a disk directly from the array, unless it is failed, so we first have to fail it (if the drive it is failed this is normally already in failed state and this step is not needed):
1
|
|
and now we can remove it:
1
|
|
This can be done in a single step using:
1
|
|
We can add a new disk to an array (replacing a failed one probably):
1
|
|
We can check the status of the arrays on the system with:
1
|
|
or
1
|
|
The output of this command will look like:
1 2 3 4 5 6 7 8 9 10 |
|
here we can see both drives are used and working fine – U. A failed drive will show as F, while a degraded array will miss the second disk –
Note: while monitoring the status of a RAID rebuild operation using watch can be useful:
1
|
|
If we want to completely remove a raid array we have to stop if first and then remove it:
1 2 |
|
and finally we can even delete the superblock from the individual drives:
1
|
|
Finally in using RAID1 arrays, where we create identical partitions on both drives this can be useful to copy the partitions from sda to sdb:
1
|
|
(this will dump the partition table of sda, removing completely the existing partitions on sdb, so be sure you want this before running this command, as it will not warn you at all).