Reset Existing RAID 0 & Create RAID 10 Array with mdadm on RHEL9
Source: Dev.to
Introduction
Linux’s software RAID can be managed with the mdadm utility. This guide shows how to:
- Reset an existing RAID 0 array on a RHEL 9 system.
- Create a new RAID 10 array using four devices.
You need SSH access to the RHEL 9 server with root or sudo privileges and the required storage devices (2 + for RAID 0, 4 for RAID 10).
Resetting an Existing RAID 0 Array
1. Identify the active array
cat /proc/mdstat
Sample output
Personalities : [raid0]
md0 : active raid0 sdc[1] sdb[0]
10475520 blocks super 1.2 512k chunks
unused devices:
2. Unmount the filesystem
umount /dev/md0
3. Stop and remove the array
mdadm --stop /dev/md0
4. Locate the component devices
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
Sample output
NAME SIZE FSTYPE TYPE MOUNTPOINT
sda 50G disk
├─sda1 1G xfs part /boot
├─sda2 600M vfat part /boot/efi
└─sda3 48.4G LVM2_member part
└─rootVG-rootLV 4G xfs lvm /
sdb 5G linux_raid_member disk
sdc 5G linux_raid_member disk
5. Zero the superblocks
mdadm --zero-superblock /dev/sdb
mdadm --zero-superblock /dev/sdc
6. Clean configuration files
Remove or comment any RAID‑related entries in:
/etc/fstab/etc/mdadm/mdadm.conf
7. Rebuild the initramfs
dracut -f
Reboot the server (optional) before creating a new array.
Building a RAID 10 Array
1. Verify the devices to be used
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT
Sample output
NAME SIZE FSTYPE TYPE MOUNTPOINT
sda 50G disk
├─sda1 1G xfs part /boot
├─sda2 600M vfat part /boot/efi
└─sda3 48.4G LVM2_member part
└─rootVG-rootLV 4G xfs lvm /
sdb 5G disk
sdc 5G disk
sdd 5G disk
sde 5G disk
2. Create the RAID 10 array
Note: Omitting
--layoutdefaults to the near layout.
mdadm --create --verbose /dev/md0 \
--level=10 \
--raid-devices=4 \
/dev/sdb /dev/sdc /dev/sdd /dev/sde
Sample interaction
To optimalize recovery speed, it is recommended to enable write‑intent bitmap, do you want to enable it now? [y/N]? y
mdadm: chunk size defaults to 512K
mdadm: size set to 5237760K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
3. Verify the new array
cat /proc/mdstat
Sample output
Personalities : [raid4] [raid5] [raid6] [raid10]
md0 : active raid10 sde[3] sdd[2] sdc[1] sdb[0]
6983680 blocks super 1.2 512K chunks 3 offset-copies [4/4] [UUUU]
[===>.................] resync = 18.2% (1271808/6983680) finish=0.8min speed=115618K/sec
bitmap: 1/1 pages [4KB], 65536KB chunk
unused devices:
4. Create a filesystem
mkfs.xfs /dev/md0
5. Mount the filesystem
mkdir -p /mnt/md0
mount /dev/md0 /mnt/md0
6. Verify the mount
df -h
Sample output
Filesystem Size Used Avail Use% Mounted on
/dev/md0 6.6G 80M 6.6G 2% /mnt/md0
...
7. Enable automatic assembly at boot
mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
8. Add the mount point to /etc/fstab
echo '/dev/md0 /mnt/md0 xfs defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab
Completion
The RAID 10 array is now built, formatted, and configured to assemble and mount automatically on subsequent reboots. Reboot the server and confirm the array’s status with cat /proc/mdstat and df -h.