1. MagicESP
  2. Ubuntu Server 22.04
  3. Ubuntu Server Software RAID

Ubuntu Server Software RAID

Install mdadm

sudo apt install mdadm

List Disks

lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT

example output

NAME    SIZE FSTYPE TYPE MOUNTPOINT
xvda      8G        disk
└─xvda1   8G ext4   part /
xvdf      3G        disk
xvdg      3G        disk
xvdh      3G        disk
xvdi      3G        disk
xvdj      3G        disk
xvdk      3G        disk
xvdl      3G        disk
xvdm      3G        disk

List RAID

cat /proc/mdstat

example output (no RAID)

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
unused devices: <none>

Create RAID 0

sudo mdadm --create --verbose {{ raid_device.value }} --level=0 {{ option_raid_devices }}

verify

cat /proc/mdstat

example output (RAID0)

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid0 xvdm[7] xvdl[6] xvdk[5] xvdj[4] xvdi[3] xvdh[2] xvdg[1] xvdf[0]
      25149440 blocks super 1.2 512k chunks

unused devices: <none>

verify again

sudo mdadm --detail {{ raid_device.value }}

example output (RAID0)

/dev/md0:
        Version : 1.2
  Creation Time : Wed Nov 30 15:26:47 2016
     Raid Level : raid0
     Array Size : 25149440 (23.98 GiB 25.75 GB)
   Raid Devices : 8
  Total Devices : 8
    Persistence : Superblock is persistent

    Update Time : Wed Nov 30 15:26:47 2016
          State : clean
 Active Devices : 8
Working Devices : 8
 Failed Devices : 0
  Spare Devices : 0

     Chunk Size : 512K

           Name : ip-10-0-0-33:0  (local to host ip-10-0-0-33)
           UUID : 496c2a3c:65257670:0224b312:07e34442
         Events : 0

    Number   Major   Minor   RaidDevice State
       0     202       80        0      active sync   /dev/xvdf
       1     202       96        1      active sync   /dev/xvdg
       2     202      112        2      active sync   /dev/xvdh
       3     202      128        3      active sync   /dev/xvdi
       4     202      144        4      active sync   /dev/xvdj
       5     202      160        5      active sync   /dev/xvdk
       6     202      176        6      active sync   /dev/xvdl
       7     202      192        7      active sync   /dev/xvdm

Save the RAID Array Layout

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
sudo update-initramfs -u

# manual edit
sudo {{ texteditor.value }} /etc/mdadm/mdadm.conf

Format and Mount RAID

sudo mkfs.ext4 -i 2048 {{ raid_device.value }}

and continue to Ubuntu Server Format Disk and Mount Disk

Remove RAID

sudo mdadm --stop {{ raid_device.value }}
sudo mdadm --remove {{ raid_device.value }}
sudo mdadm --misc --zero-superblock /dev/sdc
sudo mdadm --misc --zero-superblock /dev/sdd
sudo {{ texteditor.value }} /etc/mdadm/mdadm.conf

Reference