%%%% Class %%%%
%%%%%%%%%%%%%%%

% Hinweis: Dieses Dokument nutzt KOMA-Script
% ftp://ftp.ctan.org/tex-archive/macros/latex/contrib/koma-script/scrguide.pdf

% Schriftgröße, Layout, Papierformat, Art des Dokumentes
\documentclass[%
	a4paper,%             A4 Papier
	oneside,%             Einseitig
	bibtotocnumbered,%    Literaturverzeichnis nummeriert einfügen
	%idxtotoc,%            Index ins Verzeichnis einfügen
	%halfparskip,%         Europäischer Satz mit Abstand zwischen Absätzen
	%chapterprefix,%       Kapitel anschreiben als Kapitel
	headsepline,%         Linie nach Kopfzeile
	footsepline,%         Linie vor Fusszeile
	12pt%                 Grössere Schrift, besser lesbar am Bildschrim
]{scrartcl}


%%%% Packages und Einstellungen %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Paket für die Indexerstellung
\usepackage{makeidx}

% Times New Roman Font laden
%\usepackage{txfonts}

% Type 1 Fonts für bessere darstellung in PDF verwenden.
% Courier als \ttdefault
%\usepackage{courier}

% Einstellungen der Seitenränder
\usepackage[left=2.5cm,right=2cm,top=3cm,bottom=3cm]{geometry}

% Umlaute ermöglichen
\usepackage[latin1]{inputenc}

% Silbentrennung und neue Rechtschreibung
\usepackage[ngerman]{babel}
\usepackage{ngerman}

% Änderung des Zeilenabstandes auf 1,5-facher Zeilenabstand
%\usepackage{setspace}
%\onehalfspacing

% Fancy headers
\usepackage{fancyhdr}

% Misc. packages
%\usepackage[T1]{fontenc}
\usepackage{verbatim}
\usepackage{fancyvrb}
\usepackage{setspace}
\usepackage{subfigure}
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{boxedminipage}
\usepackage{enumerate}
\usepackage{xspace}

% URLs im PDF darstellen
\usepackage[hyphens]{url}

% Farben im PDF
\usepackage{color}
\definecolor{LinkColor}{rgb}{0,0,0.5}
%\definecolor{LinkColor}{rgb}{0,0,0}
\definecolor{darkgreen}{rgb}{0,0.6,0}
\definecolor{lightgray}{gray}{0.6}

% Links innerhalb des PDFs und PDF Info
\usepackage{hyperref}

\hypersetup{colorlinks=true,%
	linkcolor=LinkColor,%
	citecolor=LinkColor,%
	filecolor=LinkColor,%
	menucolor=LinkColor,%
	urlcolor=LinkColor,%
	%
	pdftitle={DELL PERC5/i Integrated - Emergency Cheat Sheet},
	pdfauthor={Moritz Mertinkat},
	pdfcreator={},
	pdfsubject={},
	pdfkeywords={dell, perc, dell perc, raid, raid controller, dell raid, lsi, lsi logic, megacli, megaraid, sas, sata}
}

% Schriftart setzen
\setkomafont{sectioning}{\normalfont\bfseries}
\setkomafont{captionlabel}{\normalfont\bfseries}
\setkomafont{pagehead}{\normalfont\itshape}
\setkomafont{descriptionlabel}{\normalfont\bfseries}

% Tiefe der Nummerierung im Text
\setcounter{secnumdepth}{3}

% Gliederungstiefe des Inhaltsverzeichnisses
\setcounter{tocdepth}{3}

%Kopf- und Fußzeile
\pagestyle{fancy}
\fancyhf{}

%Kopfzeile mittig
\fancyhead[C]{\nouppercase{\leftmark}}
\fancyhead[C]{DELL PERC5/i Integrated - Emergency Cheat Sheet}

%Kopfzeile rechts bzw. außen
\fancyhead[R]{\thepage}

%Fußzeile links
\fancyfoot[L]{\textcolor{lightgray}{Version 1.3, 2008-05-20}}
\fancyfoot[R]{\textcolor{lightgray}{Moritz Mertinkat}}
%\renewcommand{\footrulewidth}{0.4pt}

\makeindex

%%%% Dokument %%%%
%%%%%%%%%%%%%%%%%%

\begin{document}

\begin{center}
	\Large \textbf{DELL PERC5/i Integrated (LSI Logic MegaRAID)}\\
	\Large -- Emergency Cheat Sheet --\\
	\vskip 1em
	\large Moritz Mertinkat\\
	\texttt{moritz AT mertinkat DOT net}\\
	\vskip 0.8em
	Version 1.3, 2008-05-20\\
	\url{http://tools.rapidsoft.de/perc}\\
\end{center}

\section{Requirements and general information}

DELL's PowerEdge RAID Controller (PERC) is a special LSI Logic SAS/SATA RAID Controller and thus the LSI management utility called \textit{MegaCli} also works for this controller. \textcolor{lightgray}{For older controllers like PERC4 and PERC3 please refer to \hypersetup{urlcolor=lightgray}\url{http://linux.dell.com/storage.shtml}\hypersetup{urlcolor=LinkColor} (keyword DellMgr).}\\
\\
MegaCli is available for Linux, DOS, Windows, Netware and Solaris.\\
You can get it from LSI's website (search for MegaRAID SAS) or  download  it here: \url{http://www.lsi.com/support/downloads/megaraid/miscellaneous/linux/1.01.40_Linux_Cli.zip}.\\
\\
Inside the ZIP file you'll find an RPM archive which contains the \texttt{MegaCli} and \texttt{MegaCli64} binaries (will be installed to \texttt{/opt/MegaRAID/MegaCli}).\\
\\
\textbf{Please note:}\\
This emergency cheat sheet is not exhaustive, but it should be sufficient in most cases. For a complete reference either call \texttt{MegaCli -h} or refer to the manual at: \url{http://www.lsi.com/files/docs/techdocs/storage_stand_prod/sas/mr_sas_sw_ug.pdf} (Chapter 3 -- MegaRAID Command Tool).


\section{MegaCli conventions}

	While there are a lot of different parameters for MegaCli, some of them are always identical. These are described here in short.
	\begin{itemize}

		\item \textbf{Adapter parameter \texttt{-aN}}

			The parameter \texttt{-a\textit{N}} (where \textit{N} is a number starting with zero or the string \textit{ALL}) specifies the PERC5/i adapter ID. If you have only one controller it's safe to use \textit{ALL} instead of a specific ID, but you're encouraged to use the ID for everything that makes changes to your RAID configuration.

		\item \textbf{Physical drive parameter \texttt{-PhysDrv [E:S]}}

			For commands that operate on one or more pysical drives, the \texttt{-PhysDrv [\textit{E}:\textit{S}]} parameter is used, where \textit{E} is the enclosure device ID in which the drive resides and \textit{S} the slot number (starting with zero). You can get the enclosure device ID using "`\texttt{MegaCli -EncInfo -aALL}"'. The \textit{E:S} syntax is also used for specifying the physical drives when creating a new RAID virtual drive (see \hyperref[section:virtual_drive_management]{Virtual drive management}).

		\item \textbf{Virtual drive parameter \texttt{-Lx}}

			The parameter \texttt{-L\textit{x}} is used for specifying the virtual drive (where \textit{x} is a number starting with zero or the string \textit{all}).
	\end{itemize}


\section{Gather information}

	\begin{itemize}

		\item \textbf{Controller information}

			\texttt{MegaCli -AdpAllInfo -aALL}\\
			\texttt{MegaCli -CfgDsply -aALL}\\
			\texttt{MegaCli -AdpEventLog -GetEvents -f events.log -aALL \&\& cat events.log}

		\item \textbf{Enclosure information}

			\texttt{MegaCli -EncInfo -aALL}

		\item \textbf{Virtual drive information}

			\texttt{MegaCli -LDInfo -Lall -aALL}

		\item \textbf{Physical drive information}

			\texttt{MegaCli -PDList -aALL}\\
			\texttt{MegaCli -PDInfo -PhysDrv [E:S] -aALL}

		\item \textbf{Battery backup information}

			\texttt{MegaCli -AdpBbuCmd -aALL}

  \end{itemize}

\section{Controller management}

	\begin{itemize}

		\item \textbf{Silence active alarm}

			\texttt{MegaCli -AdpSetProp AlarmSilence -aALL}

		\item \textbf{Disable alarm}

			\texttt{MegaCli -AdpSetProp AlarmDsbl -aALL}

		\item \textbf{Enable alarm}

			\texttt{MegaCli -AdpSetProp AlarmEnbl -aALL}

  \end{itemize}


\section{Virtual drive management}
\label{section:virtual_drive_management}

	\begin{itemize}

		\item \textbf{Create RAID 0, 1, 5 drive}

			\texttt{MegaCli -CfgLdAdd -r(0|1|5) [E:S, E:S, ...] -aN}

		\item \textbf{Create RAID 10 drive}

			\texttt{MegaCli -CfgSpanAdd -r10 -Array0[E:S,E:S] -Array1[E:S,E:S] -aN}

		\item \textbf{Remove drive}

			\texttt{MegaCli -CfgLdDel -Lx -aN}

  \end{itemize}


\section{Physical drive management}

	\begin{itemize}

		\item \textbf{Set state to offline}

			\texttt{MegaCli -PDOffline -PhysDrv [E:S] -aN}

		\item \textbf{Set state to online}

			\texttt{MegaCli -PDOnline -PhysDrv [E:S] -aN}

		\item \textbf{Mark as missing}

			\texttt{MegaCli -PDMarkMissing -PhysDrv [E:S] -aN}

		\item \textbf{Prepare for removal}

			\texttt{MegaCli -PdPrpRmv -PhysDrv [E:S] -aN}

		\item \textbf{Replace missing drive}

			\texttt{MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN}\\
			The number \textit{N} of the array parameter is the \textit{Span Reference} you get using "`\texttt{MegaCli -CfgDsply -aALL}"' and the number \textit{N} of the row parameter is the \textit{Physical Disk} in that span or array starting with zero (it's \textit{not} the physical disk's slot!).

		\item \textbf{Rebuild drive}

			\texttt{MegaCli -PDRbld -Start -PhysDrv [E:S] -aN}\\
			\texttt{MegaCli -PDRbld -Stop -PhysDrv [E:S] -aN}\\
			\texttt{MegaCli -PDRbld -ShowProg -PhysDrv [E:S] -aN}

		\item \textbf{Clear drive}

			\texttt{MegaCli -PDClear -Start -PhysDrv [E:S] -aN}\\
			\texttt{MegaCli -PDClear -Stop -PhysDrv [E:S] -aN}\\
			\texttt{MegaCli -PDClear -ShowProg -PhysDrv [E:S] -aN}

		\item \textbf{Bad to good}

			\texttt{MegaCli -PDMakeGood -PhysDrv[E:S] -aN}\\
			Changes drive in state \textit{Unconfigured-Bad} to \textit{Unconfigured-Good}.

  \end{itemize}


\section{Hot spare management}

	\begin{itemize}

		\item \textbf{Set global hot spare}

			\texttt{MegaCli -PDHSP -Set -PhysDrv [E:S] -aN}

		\item \textbf{Remove hot spare}

			\texttt{MegaCli -PDHSP -Rmv -PhysDrv [E:S] -aN}

		\item \textbf{Set dedicated hot spare}

			\texttt{MegaCli -PDHSP -Set -Dedicated -ArrayN,M,... -PhysDrv [E:S] -aN}

  \end{itemize}


\section{Walkthrough: Change/replace a drive}

	\begin{enumerate}

		\item \textbf{Set the drive offline, if it is not already offline due to an error}

			\texttt{MegaCli -PDOffline -PhysDrv [E:S] -aN}

		\item \textbf{Mark the drive as missing}

			\texttt{MegaCli -PDMarkMissing -PhysDrv [E:S] -aN}

		\item \textbf{Prepare drive for removal}

			\texttt{MegaCli -PDPrpRmv -PhysDrv [E:S] -aN}

		\item \textbf{Change/replace the drive}

		\item \textbf{If you're using hot spares then the replaced drive should become your new hot spare drive}

			\texttt{MegaCli -PDHSP -Set -PhysDrv [E:S] -aN}

		\item \textbf{In case you're \textit{not} working with hot spares, you must re-add the new drive to your RAID virtual drive and start the rebuilding}

			\texttt{MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN}\\
			\texttt{MegaCli -PDRbld -Start -PhysDrv [E:S] -aN}

  \end{enumerate}

\end{document}