Mdadm software raid – cheat sheet

Certainly! Here’s a quick cheat sheet for managing software RAID using mdadm:

View RAID Information:

  1. List all RAID arrays:
    sudo mdadm --detail --scan
  2. Check the status of RAID arrays:
    cat /proc/mdstat

Create and Manage RAID:

  1. Create a new RAID 1 array:
    sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdX1 /dev/sdY1
  2. Add a spare drive to an existing array:
    sudo mdadm /dev/md0 --add /dev/sdZ1
  3. Remove a drive from an array:
    sudo mdadm /dev/md0 --remove /dev/sdX1

Monitor and Manage RAID:

  1. Monitor RAID in real-time:
    watch cat /proc/mdstat
  2. Stop an array:
    sudo mdadm --stop /dev/md0
  3. Assemble an array:
    sudo mdadm --assemble /dev/md0
  4. Fail and remove a device:
    sudo mdadm --manage /dev/md0 --fail /dev/sdX1 --remove /dev/sdX1

Miscellaneous:

  1. Check RAID metadata:
    sudo mdadm --examine /dev/sdX1
  2. Zero out superblock on a device:
    sudo mdadm --zero-superblock /dev/sdX1
  3. Create RAID 0 (striping):
    sudo mdadm --create --verbose /dev/md0 --level=0 --raid-devices=2 /dev/sdX1 /dev/sdY1

Remember to replace /dev/md0, /dev/sdX1, /dev/sdY1, etc., with your actual RAID device and disk names.

Feel free to adapt these commands based on your specific RAID setup and requirements. Always take precautions, backup data, and understand the implications before making changes to your RAID configuration.

You May Also Like
Proxmox commands cheat sheet terminal output
Read More

Proxmox Commands – cheat sheet

Managing Proxmox Virtual Environment (PVE) through the command line can significantly speed up administration tasks, especially when working…
secure ssh configuration changing default ssh port for linux and windows servers
Read More

How to Change the SSH Port

Why Change the Default SSH Port? Changing the default SSH port is a common security practice that helps…