Skip to main content
Back to Category

RAID Configuration and Disk Health Monitoring: smartctl Guide

RAID levels overview (0/1/5/10), software RAID with mdadm, disk health checks with smartctl, monitoring with smartd, and interpreting SMART data.

Read time: 14 min Server Management
raidmdadmsmartctldisk healthsmartsoftware raidlinux

Table of Contents

RAID Configuration and Disk Health Monitoring: smartctl Guide

Disk failures are inevitable in server environments. RAID (Redundant Array of Independent Disks) technology combines multiple disks to improve data safety and/or performance. This guide covers RAID levels, software RAID setup on Linux, and disk health monitoring with smartctl.

RAID Levels

RAID 0 — Striping

Data is distributed equally across disks.

  • Minimum disks: 2
  • Capacity: Sum of all disks
  • Performance: High read/write speed
  • Reliability: Zero — if one disk fails, all data is lost
  • Use case: Temporary data, high-performance applications

RAID 1 — Mirroring

Data is written to all disks simultaneously.

  • Minimum disks: 2
  • Capacity: Smallest disk capacity
  • Performance: Read speed increases, write speed unchanged
  • Reliability: High — if one disk fails, the other continues
  • Use case: OS disks, critical data

RAID 5 — Distributed Parity

Data and parity information are distributed across all disks.

  • Minimum disks: 3
  • Capacity: (N-1) × disk capacity
  • Performance: Good read, moderate write
  • Reliability: Tolerates 1 disk failure
  • Use case: File servers, general-purpose storage

RAID 10 — Mirroring + Striping

Combination of RAID 1 and RAID 0.

  • Minimum disks: 4
  • Capacity: Half of total capacity
  • Performance: Very high
  • Reliability: Tolerates 1 disk failure per pair
  • Use case: Databases, high performance + reliability

RAID Comparison Table

FeatureRAID 0RAID 1RAID 5RAID 10
Min. disks2234
Capacity100%50%(N-1)/N%50%
Read speedVery highHighHighVery high
Write speedVery highNormalModerateHigh
Fault tolerance0 disks1 disk1 disk1/pair
Data safetyNoneHighHighVery high

REXE physical servers may have a hardware RAID controller. Software RAID is managed by the Linux kernel as an alternative to hardware RAID.

Software RAID Setup with mdadm

Installing mdadm

hljs bash
# Ubuntu/Debian
sudo apt update
sudo apt install mdadm -y

# CentOS/AlmaLinux
sudo dnf install mdadm -y

Preparing Disks

hljs bash
# List existing disks
lsblk
fdisk -l

# View disk information
sudo fdisk -l /dev/sdb
sudo fdisk -l /dev/sdc

# Clear existing RAID signatures if present
sudo mdadm --zero-superblock /dev/sdb
sudo mdadm --zero-superblock /dev/sdc

Creating RAID 1

hljs bash
# Create RAID 1 array
sudo mdadm --create /dev/md0 \
  --level=1 \
  --raid-devices=2 \
  /dev/sdb /dev/sdc

# Confirm creation (type yes)
# Monitor RAID status
watch cat /proc/mdstat

# Check completion status
cat /proc/mdstat

Creating RAID 5

hljs bash
# Create RAID 5 array (3 disks)
sudo mdadm --create /dev/md0 \
  --level=5 \
  --raid-devices=3 \
  /dev/sdb /dev/sdc /dev/sdd

# Add a hot spare disk
sudo mdadm --create /dev/md0 \
  --level=5 \
  --raid-devices=3 \
  --spare-devices=1 \
  /dev/sdb /dev/sdc /dev/sdd /dev/sde

Saving RAID Configuration

hljs bash
# Update mdadm.conf
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf

# Update initramfs
sudo update-initramfs -u

# View RAID status
sudo mdadm --detail /dev/md0

Creating a Filesystem on RAID

hljs bash
# Create ext4 filesystem
sudo mkfs.ext4 /dev/md0

# Create mount point
sudo mkdir /mnt/raid

# Mount
sudo mount /dev/md0 /mnt/raid

# Add to /etc/fstab for persistent mounting
echo '/dev/md0 /mnt/raid ext4 defaults 0 0' | sudo tee -a /etc/fstab

RAID Management

hljs bash
# View RAID status
sudo mdadm --detail /dev/md0

# List all RAID arrays
cat /proc/mdstat

# Mark a disk as failed
sudo mdadm /dev/md0 --fail /dev/sdb

# Remove failed disk
sudo mdadm /dev/md0 --remove /dev/sdb

# Add new disk
sudo mdadm /dev/md0 --add /dev/sdb

# Stop RAID
sudo mdadm --stop /dev/md0

# Start RAID
sudo mdadm --assemble /dev/md0

Disk Health Checks with smartctl

smartctl reads S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) data from disks.

Installing smartmontools

hljs bash
# Ubuntu/Debian
sudo apt install smartmontools -y

# CentOS/AlmaLinux
sudo dnf install smartmontools -y

Basic smartctl Commands

hljs bash
# View disk information
sudo smartctl -i /dev/sda

# Check SMART status
sudo smartctl -H /dev/sda
# Output: SMART overall-health self-assessment test result: PASSED

# View all SMART data
sudo smartctl -a /dev/sda

# Short summary
sudo smartctl -s on -a /dev/sda

Running SMART Tests

hljs bash
# Short test (1-2 minutes)
sudo smartctl -t short /dev/sda

# Long test (several hours)
sudo smartctl -t long /dev/sda

# View test results
sudo smartctl -l selftest /dev/sda

# Check test progress
sudo smartctl -a /dev/sda | grep -i "test"

Interpreting SMART Data

Important SMART attributes:

hljs bash
# View attributes
sudo smartctl -A /dev/sda
IDAttributeDescriptionCritical Value
1Raw_Read_Error_RateRaw read error rateShould be 0
5Reallocated_Sector_CtReallocated sector countShould be 0
9Power_On_HoursTotal operating hoursInformational
10Spin_Retry_CountSpin retry countShould be 0
187Reported_UncorrectUncorrectable error countShould be 0
188Command_TimeoutCommand timeout countShould be 0
197Current_Pending_SectorPending sector countShould be 0
198Offline_UncorrectableOffline uncorrectableShould be 0
199UDMA_CRC_Error_CountCRC error countShould be 0

If ID 5 (Reallocated_Sector_Ct), 197 (Current_Pending_Sector), or 198 (Offline_Uncorrectable) values are greater than 0, the disk may be near failure. Back up your data immediately!

NVMe Disk Checks

hljs bash
# NVMe disk information
sudo smartctl -i /dev/nvme0

# NVMe SMART data
sudo smartctl -a /dev/nvme0

# NVMe health status
sudo smartctl -H /dev/nvme0

Automated Monitoring with smartd

smartd runs in the background, continuously monitoring disk health and sending notifications when issues are detected.

Configuring smartd

hljs bash
# Edit configuration file
sudo nano /etc/smartd.conf
# Monitor all disks, send email on issues
DEFAULTS -a -o on -S on -n standby,q -s (S/../.././02|L/../../6/03) -m admin@rexe.tr -M exec /usr/share/smartmontools/smartd-runner

# Monitor specific disks
/dev/sda -a -o on -S on -m admin@rexe.tr
/dev/sdb -a -o on -S on -m admin@rexe.tr

# Auto-detect all disks
DEVICESCAN -a -o on -S on -m admin@rexe.tr
hljs bash
# Enable smartd service
sudo systemctl enable --now smartd

# Check status
sudo systemctl status smartd

# Test configuration
sudo smartd -q onecheck

smartd Options

OptionDescription
-aMonitor all SMART attributes
-o onEnable offline tests
-S onEnable attribute saving
-s S/../.././02Run short test daily at 02:00
-s L/../../6/03Run long test every Saturday at 03:00
-m emailNotification email
-n standby,qDon't wake standby disks

Disk Health Monitoring Commands

hljs bash
# Quick health check for all disks
for disk in /dev/sd[a-z]; do
  echo "=== $disk ==="
  sudo smartctl -H $disk 2>/dev/null | grep -E "PASSED|FAILED|result"
done

# Check disk temperature
sudo smartctl -A /dev/sda | grep -i temperature

# Check disk operating hours
sudo smartctl -A /dev/sda | grep Power_On_Hours

# View error logs
sudo smartctl -l error /dev/sda

# Get disk info in JSON format
sudo smartctl -j -a /dev/sda

RAID + SMART Integration

hljs bash
# Check SMART status of disks in RAID array
sudo mdadm --detail /dev/md0 | grep -E "State|Active|Failed"

# Check health of each disk in RAID
for disk in /dev/sdb /dev/sdc /dev/sdd; do
  echo "=== $disk ==="
  sudo smartctl -H $disk
done

# Monitor RAID events
sudo mdadm --monitor --scan --daemonise

# RAID email notification
sudo nano /etc/mdadm/mdadm.conf
# Add line: MAILADDR admin@rexe.tr

Use RAID and SMART monitoring together. SMART predicts disk failure in advance while RAID prevents data loss when failure occurs. Together they form a comprehensive disk safety strategy.

Conclusion

RAID and disk health monitoring are fundamental components of data safety on REXE servers. RAID 1 or RAID 10 provides high reliability for critical data, while smartctl and smartd let you detect disk failures before they happen. Regular SMART tests and RAID status checks are the most effective way to prevent unexpected data loss.