创建磁盘阵列

第一步 创建并格式化分区
例如设备 /dev/sda 创建分区 /dev/sda1 格式化为 ext4 格式,这样可以清除磁盘中存在的 zfsxfs 等旧的分区信息。

第二步 创建 raid1

~$ sudo mdadm --create md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm: /dev/sda1 appears to contain an ext2fs file system
       size=976761560K  mtime=Thu Jan  1 08:00:00 1970
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: /dev/sdb1 appears to contain an ext2fs file system
       size=976761560K  mtime=Thu Jan  1 08:00:00 1970
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md/md0 started.

查看阵列信息
参数可以使用 --detail-D

~$ sudo mdadm --detail /dev/md/md0 
/dev/md/md0:
        Version : 1.2
  Creation Time : Sun May 13 19:56:07 2018
     Raid Level : raid1
     Array Size : 976630464 (931.39 GiB 1000.07 GB)
  Used Dev Size : 976630464 (931.39 GiB 1000.07 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

  Intent Bitmap : Internal

    Update Time : Sun May 13 19:57:23 2018
          State : clean, resyncing 
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

  Resync Status : 1% complete

           Name : HOMENAS:md0  (local to host HOMENAS)
           UUID : e155aca8:d68b1e12:bcfe467f:3f212b49
         Events : 15

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1

删除磁盘阵列

第一步 停止阵列设备
参数 --stop-S

~ $ sudo mdadm --stop /dev/md127

第二部 删除设备元数据

~ $ sudo mdadm --zero-superblock /dev/sda1