\begin{exe} {Creating a RAID Device}

   Normally when creating a \textbf{RAID} device we would
   use partitions on separate disks.  However, for this
   exercise we probably don't have such hardware available.
   Thus we will need to have two partitions on the same disk.

   The process will be the same whether the partitions
   are on one drive or several (Although there is obviously little
   reason to actually create a \textbf{RAID} on a single device).

   \begin{enumerate}
      \item
      Create  two 200 MB partitions of type raid (\verb?fd?)
      either on your hard disk using \textbf{fdisk}, or using
      \textbf{LVM}.
      \item

      Create a \textbf{RAID 1} device named \filelink{/dev/md0}
      using the two partitions.
      \item
      Format the \textbf{RAID} device as an
      \textbf{ext4} filesystem.  Then mount it at
      \filelink{/myraid} and make the mount persistent.

      \item
      Place the information about \filelink{/dev/md0} in
      \filelink{/etc/mdadm.conf}, using \textbf{mdadm}.
      (Depending on your distribution, this file may not
      previously exist.)
      \item
      Examine \filelink{/proc/mdstat} to see the status
      of your \textbf{RAID} device.
   \end{enumerate}

   \begin{sol}

      \begin{enumerate}
         \item
         If you need to create new partitions do:
         \begin{cmd}
$ sudo fdisk /dev/sda
         \end{cmd}
         and create the partitions as we have done before.
         For purposes of being definite, we will call them
         \file{/dev/sdaX} and \file{/dev/sdaY}.
         You will need to run \textbf{partprobe} or \textbf{kpartx}
         or reboot after you are done to make sure the system
         is properly aware of the new partitions.

         \item

         \begin{cmd}
$ sudo mdadm -C /dev/md0 --level=1 --raid-disks=2 /dev/sdaX /dev/sdaY
         \end{cmd}
         \item
         \begin{cmd}
$ sudo mkfs.ext4 /dev/md0
$ sudo mkdir /myraid
$ sudo mount /dev/md0 /myraid
         \end{cmd}
         and add to \filelink{/etc/fstab}
         \begin{configlst}[in \texttt{/etc/fstab}]
/dev/md0  /myraid    ext4    defaults  0 0
         \end{configlst}
         \item
         \begin{cmd}
$ sudo bash -c "mdadm --detail --scan >> /etc/mdadm.conf"
         \end{cmd}
         \item
         \begin{cmd}
$ cat /proc/mdstat
         \end{cmd}
         \begin{response}
Personalities : [raid1]
md0 : active raid1 dm-14[1] dm-13[0]
      204736 blocks [2/2] [UU]

unused devices: <none>
         \end{response}
      \end{enumerate}
      \begin{info}
         You should probably verify that with a reboot, the
         \textbf{RAID} volume is mounted automatically.
         When you are done, you probably will want to clean
         up by removing the line from \filelink{/etc/fstab},
         and then getting rid of the partitions.
      \end{info}
   \end{sol}
\end{exe}


