Настроить soft RAID0 в Linux

Дата: 11.02.2019Метки:

Для настройки soft RAID0 в Linux потребуется два раздела одинакового размера. В моем случае уже были подготовлены разделы, в случае их отсутствия вам создать дав одинаковых раздела на двух дисках. Весь процесс создания заключается всего в одной команде:

# mdadm -C /dev/md4 -l raid0 -n 2 /dev/nvme[0-1]n1p4
mdadm: /dev/nvme0n1p4 appears to contain an ext2fs file system
       size=376531904K  mtime=Sun Feb 10 21:31:56 2019
mdadm: /dev/nvme1n1p4 appears to contain an ext2fs file system
       size=376531904K  mtime=Sun Feb 10 21:31:56 2019
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md4 started.

Просмотреть информацию о RAID массиве:

# mdadm -E /dev/nvme[0-1]n1p4
/dev/nvme0n1p4:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : d798bc02:2e3b3241:ef4ac56e:f742e569
           Name : server:4  (local to host server)
  Creation Time : Mon Feb 11 05:08:40 2019
     Raid Level : raid0
   Raid Devices : 2

 Avail Dev Size : 752801792 (358.96 GiB 385.43 GB)
    Data Offset : 262144 sectors
   Super Offset : 8 sectors
   Unused Space : before=262056 sectors, after=0 sectors
          State : clean
    Device UUID : a0a31486:1d80a1ad:16728a55:5e91b47e

    Update Time : Mon Feb 11 05:08:40 2019
  Bad Block Log : 512 entries available at offset 72 sectors
       Checksum : 5e149378 - correct
         Events : 0

     Chunk Size : 512K

   Device Role : Active device 0
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
/dev/nvme1n1p4:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : d798bc02:2e3b3241:ef4ac56e:f742e569
           Name : server:4  (local to host server)
  Creation Time : Mon Feb 11 05:08:40 2019
     Raid Level : raid0
   Raid Devices : 2

 Avail Dev Size : 752801792 (358.96 GiB 385.43 GB)
    Data Offset : 262144 sectors
   Super Offset : 8 sectors
   Unused Space : before=262056 sectors, after=0 sectors
          State : clean
    Device UUID : ec2e8427:f2f506e8:c7895f2e:737b9873

    Update Time : Mon Feb 11 05:08:40 2019
  Bad Block Log : 512 entries available at offset 72 sectors
       Checksum : 7a29660 - correct
         Events : 0

     Chunk Size : 512K

   Device Role : Active device 1
   Array State : AA ('A' == active, '.' == missing, 'R' == replacing)
root@server:~# mdadm --detail /dev/nvme[0-1]n1p4
mdadm: /dev/nvme0n1p4 does not appear to be an md device
mdadm: /dev/nvme1n1p4 does not appear to be an md device
root@server:~# mdadm --detail /dev/md4
/dev/md4:
        Version : 1.2
  Creation Time : Mon Feb 11 05:08:40 2019
     Raid Level : raid0
     Array Size : 752801792 (717.93 GiB 770.87 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent

    Update Time : Mon Feb 11 05:08:40 2019
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

     Chunk Size : 512K

           Name : server:4  (local to host server)
           UUID : d798bc02:2e3b3241:ef4ac56e:f742e569
         Events : 0

    Number   Major   Minor   RaidDevice State
       0     259       10        0      active sync   /dev/nvme0n1p4
       1     259        4        1      active sync   /dev/nvme1n1p4

Создаем файловую систему:

# mkfs.ext4 /dev/md4
mke2fs 1.43.4 (31-Jan-2017)
Discarding device blocks: done
Creating filesystem with 188200448 4k blocks and 47054848 inodes
Filesystem UUID: 8d549021-4994-496d-90a0-ee53133036b1
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000

Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done

Далее монтируем командой:

mount /dev/md4 /home