Setting up a RAID 1 Array using mdadm on Debian
To set up a RAID 1 array on Debian, you need to follow these steps:
- Install the required packages:
mdadmandsmartmontools
# apt-get update && apt-get install mdadm smartmontools
- Create two identical partitions on separate drives
# fdisk /dev/sda
# fdisk /dev/sdb
Create a RAID 1 array using the mdadm command with the following syntax:
# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
Format the new RAID array to a filesystem:
# mkfs.ext4 /dev/md0
Mount the new RAID array:
# mount /dev/md0 /mnt/raid
Enabling mdadm Email Monitoring using MSMTP
To enable mdadm email monitoring on Debian, you can follow the documentation from the MSMTP website (https://marlam.de/msmtp/msmtp.html#Examples). Here are the steps:
- Install the required packages:
msmtpandmailutils
# apt-get update && apt-get install msmtp mailutils
- Configure MSMTP by editing the
/etc/msmtprcfile:
# nano /etc/msmtprc
Add the following configuration:
account default
host smtp.gmail.com
port 587
auth on
user [email protected]
password your-password
from [email protected]
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account your-secondary-email
host smtp.your-domain.com
port 25
auth on
user your-secondary-email-username
password your-secondary-email-password
from [email protected]
tls on
tls_starttls off
Configure mdadm by editing the /etc/mdadm/mdadm.conf file:
# nano /etc/mdadm/mdadm.conf
Add the following line:
MAILADDR [email protected]
- Test the email notification feature by forcing a degraded state:
# mdadm --manage /dev/md0 --fail /dev/sda1
Wait for the email notification and check your inbox.
- mdadm - software RAID management tool
- smartmontools - utility to monitor and control SMART
- MSMTP - simple, secure, and lightweight SMTP client
- mailutils - various utilities for handling electronic mail