RAID (redundant array of independent disks) is a data storage virtualization technology that combines multiple physical disk components into a single logical unit for the purposes of data redundancy (reliability), performance improvements, or both.
This script creates a RAID disk (type 1) from two equal size disk partitions and installs / configures email notifications providing RAID status whenever anything (such as disk errors / failure) changes. Combined with regular backups, RAID guarantees that no data will be lost, or, if so, it is easily replaced.
RAID is desirable for mission critical applications where a disk failure does not result in loss of data / services and time is available to replace a failed disk with no loss of data.
(Optional) If either of the RAID target partitions / disks contains important data, it needs to be backed up to another PC and restored to the RAID array once RAID installation is complete. If you have multiple partitions to backup / restore, repeat this procedure for each partition.
Backup Procedure (assumes partition is mounted):
Restore Procedure(assumes RAID partition is mounted at /home/data):
In this configuration, SecureOffice boot and system partitions are on a separate device such as mSATA. Bulk data storage (for virtual machines, websites, file servers, data, etc) use two additional SATA disks configured for RAID. Each SATA disk will have two partitions: swap (partition 3) and RAID (partition 4). The size of the RAID partition (both disks) will be the size of the smaller disk less the size of the swap partition (default: 4GB).
Skip to Section 1.5.
In this configuration, SecureOffice boot and system partitions are on the same disk as bulk data storage (for virtual machines, websites, file server data, etc) using partition 4 the boot disk configured as a RAID disk component.
This is an optional step, required if the SecureOffice system / boot disk data partition is not large enough to support desired RAID size and it is undesirable / not possible to add two new SATA disks for RAID. Alternatively, the system disk has failed and needs to be replaced. There are two options:
To copy SecureOffice to a new disk:
It will be necessary to delete and add the boot disk data partition (assumed to be first RAID member) back, due to disk size increase:
Note: this constitutes a hardware change and trial licensing (cannot change hardware) will fail. Fully (paid) licenses can be refreshed (System->Licensing->Manage Licenses), "Register", "Install" for each licensed product.
In subsequent instructions, DRIVE1 and DRIVE2 will be the disks containing the RAID disk components / partitions. They need to be identified for the RAID installation script.
If using separate system and data disks (you added two SATA disks for RAID), DRIVE1 will be the lower (b less than c) new disk. DRIVE2 will be the higher (c greater than b) new disk. Assuming the two new disks were detected as /dev/sdc and /dev/sdd:
If using common system and data disks (you added one SATA disk for RAID), DRIVE1 will be the existing boot / system disk and DRIVE2 will be the new disk. Assuming your boot disk is /dev/sda and your new disk is /dev/sdb, DRIVE1 will be /dev/sda and DRIVE2 will be /dev/sdb.
Using the data partition (4) of the boot / system disk as a RAID member provides the option (raid script will ask) of backing up the system partitions (1 to 3) to the secondary disk. This will provide the ability (failsafe boot) of booting with the secondary disk should the primary disk become corrupt. To use this option, DRIVE1 value (below) must be the boot / system disk. This will result in partitions 1 to 3 (boot, rootfs, swap) of both disks being identical, with partition 4 of both disks being RAID members. Note that the system partitions of the secondary disk will not be updated (configuration, packages) as the system partitions of the primary disk change. This is the recommended configuration.
Choosing to not backup partitions 1 to 3 of the boot /system disk to the secondary disk will result in following partition layout:
The disks (DRIVE1, DRIVE2) corresponding to the two disks to be used for RAID need to be identified, by following these identify disk instructions.
SecureOffice must be connected to the internet from your registered domain. To test this, enter "ping <www.your domain>". The result should be the WAN IP address of SecureOffice (WAN Topology) or main router (LAN Topology). If not, DDNS is not working and needs to be configured or checked
Enter the following (one line) at a SecureOffice command prompt to download the RAID installation script:
"cd /tmp; sget Files/do_raid.sh; chmod +x do_raid.sh" ("sget" is not a typo)
The following values within this script must be changed to adapt to your installation (nano /tmp/do_raid.sh).
Enter the following command to execute the script to install and configure RAID:
Answer script prompts / questions as follows:
Separate system and RAID data disks:
Common system and RAID data disk member:
Any errors can be diagnosed from the script output and log (/var/log/do_raid.sh).
Enter the following commands:
"mount" You should see "/dev/md0 on" the value specified for "RAID_MOUNT" above.
If ."/dev/md0" is not mounted, enter "logread | grep md" for diagnostic information and fix any problems.
After your next reboot, repeat the "mount" command above to confirm that the RAID disk auto mounts at startup and the swap partition from DRIVE2 is active. If not, repeat the "logread" command for diagnostic information and fix any problems.
After installation, you should have received two status emails (may be delayed by servers). If not, your send email server may need additional configuration.
The first thing to do is send a test email with debug enabled by entering the following command:
echo -e "From: $EMAIL_FROM\nSubject: Raid Status\n\n Raid Installed!" | msmtp --debug --timeout=10 -t $EMAIL_TO
Replacing $EMAIL_FROM and $EMAIL_TO with the script configuration values entered above. The debug information from the above command should provide clues regarding problems.
If not, do an internet search "msmtp your email provider" to determine any additional configuration required.
Once required configuration additions / changes are identified, edit ("nano /etc/msmtprc") to enter any changes required.
Further information regarding msmtp email configuration / debugging is available on the Arch Wiki.
The RAID installation script creates a standard initscript (/etc/init.d/mdadm) for controlling the RAID array which also specifies the mount point (default: /home/data) for the RAID disk (/dev/md0).
After RAID is installed, the RAID disk is active and mounted (default: /home/data, or config value RAID_MOUNT) and configured to auto mount at boot.
If changes to email notifications are desired, consult the msmtp manual and edit configuration file "/etc/msmtprc".
Every time a significant RAID event such as SecureOffice boot (RAID mounted) or RAID disk failure occurs, an email will be received containing details.
When a RAID disk member fails, the RAID array will continue to run using the redundant (good) RAID disk member. This allows time to replace the faulty disk without losing data (the whole point of RAID).
If the failed disk is the boot / system disk with RAID in partition 4 (Common system and data disks):