User Login      + Register  

Table_of_Contents

1      Install RAID Disk

1.1                Prerequisites

1.3                Separate System and Data Disks

1.4                Common System and Data Disks

1.4.1      Replace SecureOffice System Disk

1.5                Configure and Install RAID

1.6                Verify RAID Status

1.7                Verify Email Notifications

1.8                Controlling RAID

1.9                Replace Failed RAID Disk

1      Install RAID Disk

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.

An overview of RAID is available at WikiPedia.

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.

1.1                Prerequisites

  • SecureOffice installed and configured for a single disk (default installation).
  • Subscription to SecureOffice custom package repository, which includes access to custom, including RAID installation scripts.
  • Credentials for an email server to send RAID status notifications.
  • Do not use USB, SD or TF disks for RAID, performance penalty.
  • Choose desired RAID disk size. 128GB should be adequate for two virtual machines. 64GB is enough for one. Any extra RAID storage requirements should be factored in.

1.2    Backup Target Disk 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):

  • From a SecureOffice SSH session change to the root directory of the mounted target partition. Example: "cd /home/data/".
  • Enter "tar --exclude=home_data.tar.gz -zcvf home_data.tar.gz".
  • Use WinScp (or other file transfer method) to copy home_data.tar.gz to another PC.
  • The home_data.tar.gz filename is a matter of preference.


Restore Procedure(assumes RAID partition is mounted at /home/data):

  • From a SecureOffice SSH session change to the root directory of the mounted RAID partition. Example: "cd /home/data/".
  • Use WinScp (or other file transfer method) to copy home_data.tar.gz from PC to "/home/data".
  • Enter "tar -zxvf home_data.tar.gz; rm home_data.tar.gz" to restore your data and delete the archive.

1.3                Separate System and Data Disks

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).

Requirements:

  • Two more SATA hard or SSD disks, sized to meet desired RAID array size plus swap partition size.
  • Two free SATA ports on motherboard.
  • Room and enough power for extra disks in PC enclosure.
  • With the SecureOffice PC unpowered, physically install two identical SATA hard or SSD disks.
  • Boot SecureOffice to detect the new hard disks.

Skip to Section 1.5.

1.4                Common System and Data Disks

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.

  • Additional SATA hard or SSD disk.
  • One free SATA port on motherboard
  • Room and enough power for extra disk in PC enclosure.
  • No data yet installed to boot disk data partition (/dev/sda4). If so, backup data to another disk, to be restored to RAID later.
  • The size of the SecureOffice boot disk data partition (/dev/sda4) is large enough for the desired RAID disk size. If not, replace the system disk with a larger one (next section).
  • Size of the additional disk is at least size of the SecureOffice data partition (/dev/sda4) plus 12GB (if backing up SecureOffice system partitions else plus 4G. The secondary disk can be larger than this, resulting in extra space that can be partitioned for other purposes.
  • It is recommended that the size and contents of partitions 1 to 3 of both disks be made identical. This will provide a failsafe boot should one disk fail. The RAID install script will prompt to backup partitions 1 to 3 (from boot disk) to partitions 1 to 3 of the secondary disk.
  • The size of the RAID disk will be equal to the size of the SecureOffice boot disk data partition (/dev/sda4).
  • Recommendation: Use equal size SecureOffice boot and RAID disks.
  • If the system / boot disk is too small to support the desired RAID size and separate system / data disks is not possible, replace the system disk with a larger one (next section, optional).

1.4.1      Replace SecureOffice System Disk

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:

  • Re-install SecureOffice and restore configuration from backup. This is discussed elsewhere in Install SecureOffice to Boot Media and backup and restore.
  • Copy smaller system disk partitions to new, larger disk. It is assumed that the original disk with current partitions is available.

To copy SecureOffice to a new disk:

  • Power off, install new disk, reboot
  • Save any important data from the boot disk data partition (/dev/sda4) elsewhere such as removable media.
  • Identify the boot disk (to be replaced) and new disk (replacement) by following these identify disk instructions.
  • Enter (command prompt) "dd if=/dev/sdX of=/dev/sdY bs=10M" where sdX is the existing boot disk and sdY is the new disk. This will copy all partitions from the old to new system disk.
  • Power down SecureOffice, remove the old system disk, power on. It may be necessary to reconfigure the boot device if boot fails.

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:

  • "fdisk /dev/sda"
  • "p" to display partitions
  • "d" to delete partition
  • "4" to select partition 4
  • "n" to create new partition
  • "p" to select primary partition
  • "4" to select partition 4
  • "enter" twice to select default start and end sectors (end of partition 3 to end of disk)
  • "w" to save settings and exit fdisk

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.

1.5                Configure and Install RAID

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:

  • New swap partitions will be created on /dev/sdc3 and /dev/sdd3.
  • New RAID partitions will be /dev/sdc4, /dev/sdd4.

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.

  • Partitions 1 to 3 of both disks will be identical.
  • Partition 4 of boot / system disk will be first RAID member.
  • Partition 4 of secondary disk will be second RAID member.

Choosing to not backup partitions 1 to 3 of the boot /system disk to the secondary disk will result in following partition layout:

  • Partition 4 of boot / system disk will be first RAID member.
  • Partition 3 of secondary disk will be swap.
  • Partition 4 of secondary disk will be second RAID member.

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).

  • DRIVE1="The first RAID disk identified above. Eg: /dev/sda"
  • DRIVE2="The second RAID disk identified above. Eg: /dev/sdb"
  • RAID_MOUNT="The mount point for RAID disk. Default: /home/data
  • EMAIL_HOST="Your send email server IP or URL"
  • EMAIL_PORT="Your send email server port"
  • EMAIL_USER="Your user ID for email server"
  • EMAIL_PASSWORD="Your password for email server"
  • EMAIL_FROM="Email address where emails are alleged to be from. Does not have to be real. Example:SecureOffice@yourdomain.com"
  • EMAIL_TO="Email address to send notifications to. Example: you@gmail.com"

Enter the following command to execute the script to install and configure RAID:

"./do_raid.sh"

Answer script prompts / questions as follows:

Separate system and RAID data disks:

  • Have you set the configuration values at the beginning of this script? [Y/n] y
  • Disk partition DRIVE1(4) and entire disk DRIVE2 will be erased. Are you certain? [y/N] y
  • Is your SecureOffice installation on DRIVE1? [Y/n] n
  • If message "mdadm: Note: this array has metadata at the start, etc" Continue creating array? (y/n). Answer "y"

Common system and RAID data disk member:

  • Have you set the configuration values at the beginning of this script? [Y/n] y
  • Disk partition DRIVE1(4) and entire disk DRIVE2 will be erased. Are you certain? [y/N] y
  • Is your SecureOffice installation on DRIVE1? [Y/n] y (to backup DRIVE1 partitions 1 to 3 to DRIVE2)
  • OR: Is your SecureOffice installation on DRIVE1? [Y/n] n (no backup)
  • If "y" to previous question: Do you want to backup your SecureOffice installation from DRIVE1 to DRIVE2? May take some time. [Y/n] y (or "n")
  • If message "mdadm: Note: this array has metadata at the start, etc" Continue creating array? (y/n). Answer "y"

Follow the prompts and fix any errors (such as RAID device already exists) until installation is successful. At the end of RAID installation, result is:

  • /etc/config/fstab (what to mount at boot) has been replaced (old one saved: /etc/config/fstab_pre_raid) to use swap from DRIVE2 and mount the RAID disk at RAID_MOUNT. If there are other devices to be mounted, merge the other mounts / configuration from /etc/config/fstab_pre_raid to /etc/config/fstab.
  • RAID disk (/dev/md0), formatted as ext4 should be mounted (at RAID_MOUNT) and configured to automatically start and mount at boot.
  • Two RAID status emails should be received.

Any errors can be diagnosed from the script output and log (/var/log/do_raid.sh).

1.6                Verify RAID Status

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.

1.7                Verify Email Notifications

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.

1.8                Controlling RAID

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.

  • To enable RAID start at boot: enter "/etc/init.d/mdadm enable" (already done)
  • To disable RAID start at boot: enter "/etc/init.d/mdadm disable"
  • To stop and unmount the RAID array: enter "/etc/init.d/mdadm stop"
  • To start and mount the RAID array: enter "/etc/init.d/mdadm start"
  • To change the RAID array mount point, create the mount point directory and edit "/etc/init.d/mdadm" to specify the new mount point.


If changes to email notifications are desired, consult the msmtp manual and edit configuration file "/etc/msmtprc".

1.9                Replace Failed RAID Disk

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):

  • You will have to boot using the backup partition you hopefully chose to create at RAID creation. Otherwise, you will have to boot a USB recovery disk.
  • The system partitions will have to be re-created on the replacement disk (Section 1.4.1) and partition 4 on the replacement disk must be created of the same size of partition 4 of the good RAID disk.

Follow these instructions to replace the failed disk and restore it to the RAID array. Should the previous link changed, google " linux replace failed RAID disk.

 

Technologies Used:

Design by: XOOPS UI/UX Team