\section{Software RAID Configuration}

\begin{frame}
   {Software RAID Configuration}

   Essential steps in configuring a software \textbf{RAID}
   device:

   \begin{itemize}
      \item Create partitions on each disk (type \verb?fd? in
      \textbf{fdisk})
      \item Create \textbf{RAID} device with \textbf{mdadm}
      \item Format \textbf{RAID} device
      \item Add device to \filelink{/etc/fstab}
      \item Mount \textbf{RAID} device
      \item Capture \textbf{RAID} details to ensure persistence
   \end{itemize}
   The command:
   \begin{cmd}
$ sudo mdadm -S
   \end{cmd}
   can be used to stop \textbf{RAID}.

\end{frame}

\cprotect\note{

   For example, create two partitions of type \texttt{fd} on
   disks \texttt{sdb} and {sdc} (say \filelink{/dev/sdbX}
   and \filelink{/dev/sdcX}) by running \textbf{fdisk} on
   each:
   \begin{cmd}
$ sudo fdisk /dev/sdb
$ sudo fdisk /dev/sdc
   \end{cmd}
   Then set up the array, format it, add to the
   configuration and mount it:
   \begin{cmd}
$ sudo mdadm --create /dev/md0 --level=1 --raid-disks=2  /dev/sdbX /dev/sdcX
$ sudo mkfs.ext4 /dev/md0
$ sudo bash -c "mdadm --detail --scan >> /etc/mdadm.conf"
$ sudo mkdir /myraid
$ sudo mount /dev/md0 /myraid
   \end{cmd}

   Be sure to add a line in \filelink{/etc/fstab} for the mount
   point.
   \begin{cmd}
/dev/md0    /myraid        ext4    defaults 0 2
   \end{cmd}
   You can examine \filelink{/proc/mdstat} to see the
   \textbf{RAID} status as in:
   \begin{cmd}
$ cat /proc/mdstat
 Personalities : [raid1]
 md0 : active raid1 sda8[1] sda7[0]
 ---------- 521984 blocks [2/2]
 unused devices: <none>
   \end{cmd}
   Use \texttt{mdadm -S /dev/md0} to stop the RAID device.
}

\section{Monitoring RAIDs}
\begin{frame}
   {Monitoring RAIDs}

   \begin{itemize}
      \item Monitor RAID devices multiple ways
      \begin{cmd}
$ sudo mdadm --detail /dev/md0
$ cat /proc/mdstat
      \end{cmd}
      \item \textbf{mdmonitor}
      \begin{cmd}
/etc/mdadm.conf
      \end{cmd}
   \end{itemize}
\end{frame}

\cprotect\note{

   You can monitor \textbf{RAID} devices multiple ways as in:
   \begin{cmd}
$ sudo mdadm --detail /dev/md0
$ cat /proc/mdstat
   \end{cmd}
   One can also use \textbf{mdmonitor} which requires
   configuring \filelink{/etc/mdadm.conf}.

   The command:
   \begin{cmd}
$ sudo mdadm --detail /dev/mdX
   \end{cmd}
   will show the current status of the \textbf{RAID}
   device \filelink{/dev/mdX}.  Another way to do this is
   to examine the \filelink{/proc} filesystem:
   \begin{cmd}
$ cat /proc/mdstat
   \end{cmd}
   will show the status of all \textbf{RAID} devices on
   the system.

   You can also use the \textbf{mdmonitor} service by
   editing \filelink{/etc/mdadm.conf} and adding a line
   like:
   \begin{cmd}
MAILADDR eddie@haskell.com
   \end{cmd}
   so that it notifies you with email sent to
   \texttt{eddie@haskell.com} when a problem occurs with a
   \textbf{RAID} device, such as when any of the arrays
   fail to start or fall into a degraded state.  You turn
   it on with:
   \begin{cmd}
$ sudo systemctl start mdmonitor
   \end{cmd}
   and make sure it starts at boot with:
   \begin{cmd}
$ sudo systemctl enable mdmonitor
   \end{cmd}
}

\section{RAID Hot Spares}
\begin{frame}
   {RAID Hot Spares}

   \begin{itemize}
      \item Unused RAID member set aside as a hot spare
      \begin{itemize}
         \item Can be created along with the array
         \item Can be added after-the-fact
      \end{itemize}
      \item Testable
      \begin{cmd}
$ mdadm --fail
$ mdadm --remove
$ mdadm --add
      \end{cmd}
   \end{itemize}
\end{frame}

\cprotect\note{

   One of the important things that \textbf{RAID} provides
   is redundancy.  To help ensure any reduction in that
   redundancy is fixed as quick as possible, a \textbf{hot
      spare} can be used.

   To create a hot spare when creating the \textbf{RAID}
   array:
   \begin{cmd}
$ sudo mdadm --create /dev/md0 -l 5 -n3 -x 1 /dev/sda8 /dev/sda9 /dev/sda10 /dev/sdb2
   \end{cmd}
   The \texttt{-x 1} switch tells \textbf{mdadm} to use
   one spare device.  Note a hot spare can also be added
   at a later time.

   The command:
   \begin{cmd}
$ sudo mdadm --fail /dev/md0 /dev/sdb2
   \end{cmd}
   will test the redundancy and hot spare of your array.

   To restore the tested drive, or a new drive in a
   legitimate failure situation, first remove the
   ``faulty'' member, then add the ``new'' member as in:
   \begin{cmd}
$ sudo mdadm --remove /dev/md0 /dev/sdb2
$ sudo mdadm --add /dev/md0 /dev/sde2
   \end{cmd}

}



