\section{System Rescue and Recovery}

\begin{frame}
   {System Rescue and Recovery}

   \begin{itemize}
      \item
      System rescue media come in multiple forms
      \item
      They enable you to enter \textbf{emergency mode} and perform useful
      operations
      \item
      It is also useful to know how to enter \textbf{single
         user mode}, which differs from \textbf{emergency mode}.
   \end{itemize}

\end{frame}

\cprotect\note{

   Sooner or later a system is likely to undergo a
   significant failure, such as failing to boot properly, to
   mount filesystems, initiate a desktop display, etc.
   \textbf{System Rescue} media in the form of optical disks
   or portable \textbf{USB} drives can be used to fix the
   situation.  Booting into either \textbf{emergency} or
   \textbf{single user} mode can enable using the full suite
   of \textbf{Linux} tools to repair the system back to
   normal function.

}

\section{Emergency Boot Media}
\begin{frame}
   {Emergency Boot Media}

   \begin{itemize}
      \item
      \textbf{CD}
      \item
      \textbf{DVD}
      \item
      \textbf{USB}
      \item
      Can be stand-alone rescue/recovery tool, a
      distribution installation disk, and/or a \textbf{Live
         Linux Distribution} with rescue/recovery
      capabilities
   \end{itemize}

\end{frame}

\cprotect\note {

   Emergency boot media are useful when your system will not
   boot due to some issue such as missing, misconfigured,
   or corrupted files or a misconfigured service.

   Rescue media may also be useful if the root password is
   somehow lost or scrambled and needs to be reset.

   Most \textbf{Linux} distributions permit the install
   media (\textbf{CD}, \textbf{DVD}, \textbf{USB}) and/or
   \textbf{Live} media to serve a double purpose as a
   rescue disk, which is very convenient.  There are also
   special-purpose rescue disks available.

   Live media (in any format) provide a complete and
   bootable operating system which runs in memory, rather
   than loading from disk. Users can experience and
   evaluate an operating system and/or \textbf{Linux}
   distribution without actually installing it, or making
   any changes to the existing operating system on the
   computer.

   Live removable media are unique in that they can run on
   a computer lacking secondary storage, such as a hard
   disk drive, or with a corrupted hard disk drive or
   filesystem, allowing users to rescue data.

}

\section{Using Rescue Media}
\begin{frame}
   {Using Rescue Media}

   \begin{itemize}

      \item
      Virtually all \textbf{Linux} distributions have
      a rescue image as a choice on the \textbf{GRUB} menu.
      If your system has gotten this far and the rescue
      option works, you should try it before mounting rescue
      media.
      \item
      When system boots you will either have to pick a menu
      choice for \texttt{rescue} or type something like
      \begin{kcode}
Linux rescue
      \end{kcode}
      at the \texttt{boot:} prompt
      \item
      You may be asked questions about language and other
      choices, such as whether to initiate the network.
      \item
      You will probably also be asked which filesystems to
      mount etc.
   \end{itemize}

\end{frame}

\cprotect\note {

   Whether you are using \textbf{Live}, install or rescue
   media, the procedures for entering into a special operating
   system for rescue and recovery are the same, and as we have
   pointed out one medium serves all three purposes.

   The rescue/recovery mode can be accessed from an option on
   the boot menu when the system starts from the removable
   media. In many cases you may have to type \texttt{rescue} on a
   line like:
   \begin{kcode}
boot: Linux rescue
   \end{kcode}
   We cannot tell you all the possibilities as each distribution has
   somewhat different, but easy to ascertain procedures.

   Next, you can expect to be asked some questions such as which
   language to continue in, as well as make some
   distribution-dependent choices.
   Then you will be prompted to select where a valid rescue
   image is located: \textbf{CD/DVD}, \textbf{Hard Drive},
   \textbf{NFS}, \textbf{FTP}, or \textbf{HTTP}.

   The selected location must contain a valid installation
   tree, and the installation tree must be for the same
   \textbf{Linux} version as the rescue disk, and if you are
   using removable media the installation tree must be the same
   as the one from which the media was created. If you are
   using a \texttt{boot.iso} image downloaded from the vendor,
   then you will also need a network-based install tree.

   Additional questions are asked about mounting your
   filesystems.  If they can be found, they are mounted under
   \filelink{/mnt/sysimage}.  You will then be given a shell
   prompt and access to various utilities to make the
   appropriate fixes to your system.

   \textbf{chroot} can be used to better access
   your root (\filelink{/}) filesystem.

}


\begin{frame}
   {Rescue USB Key}
   \begin{itemize}
      \item
      \textbf{USB} install/live/rescue disk images are made available
      by all modern distributions.
      \item
      In most cases can be transferred to \textbf{USB} drive with:
      \begin{cmd}
$ dd if=boot.iso of=/dev/sdX
      \end{cmd}
      if \filelink{/dev/sdX} is your removable drive
      \item
      Make sure your \textbf{BIOS} is set to boot off a
      \textbf{USB} drive.
      \item
      Tools such as \textbf{livecd-tools} and
      \textbf{liveusb-creator} can make this process
      much easier and can also customize the disk.
   \end{itemize}

\end{frame}

\cprotect\note{

   Many distributions provide a \texttt{boot.iso} image file
   for download (the name may differ).  You can use
   \textbf{dd} to place this on a \textbf{USB} key drive as
   in:
   \begin{cmd}
$ dd if=boot.iso of=/dev/sdX
   \end{cmd}
   assuming your system recognizes the removable drive as
   \filelink{/dev/sdX}. Be aware this will obliterate the
   previously existing contents on the drive!

   Assuming your system has the capability of booting from
   \textbf{USB} media and the \textbf{BIOS} is configured
   for it, you can then boot from this \textbf{USB} drive.
   It will then function in the same fashion as a rescue
   \textbf{CD} or \textbf{DVD}.  However, note the install
   tree will not be present on the \textbf{USB} drive;
   therefore this method requires a network-based install
   tree if one is needed.

   Helpful utilities such as \textbf{livecd-tools} and
   \textbf{liveusb-creator} allow specification of either a
   local drive or the Internet as the location for
   obtaining an install image, and then do all the hard
   work of constructing a bootable image and burning it on
   the removable drive.  This is extremely convenient and
   works for virtually all \textbf{Linux} distributions.

}


\section{Emergency Mode}
\begin{frame}
   {Emergency Mode}

   \begin{itemize}
      \item \textbf{emergency mode} boots into the most minimal environment.
      \item Root filesystem in read-only
      \item \textbf{init} scripts not run, very little setup done
      \item Useful when \textbf{init} is failing
      \item Filesystems are still mounted, helps to recover data
      \item Must interact with \textbf{GRUB} interactive menu
      to select emergency mode.
      \item Will be asked for root password before getting a command prompt
      \item System will sometimes automatically enter emergency mode
      during a failed boot, like due to corrupted filesystem
   \end{itemize}

\end{frame}

\cprotect\note{

   In \textbf{emergency mode} you are booted into the most
   minimal environment possible. The root filesystem is
   mounted read-only, no init scripts are run and almost
   nothing is set up.

   The main advantage of emergency mode over single-user
   mode (to be described next) is that if \textbf{init} is
   corrupted or not working, you can still mount
   filesystems to recover data that might be lost during a
   re-installation.

   To enter emergency mode you need to select an entry from
   the \textbf{GRUB} boot menu and then hit \texttt{e} for
   edit.  Then add the word \texttt{emergency} to the
   kernel command line before telling the system to
   boot. You will be asked for the root password before
   getting a shell prompt.

   Note you may also enter emergency mode when a boot fails
   for a variety of reasons, including a corrupted
   filesystem.

}

\section{Single User Mode}
\begin{frame}
   {Single User Mode}

   \begin{itemize}
      \item Used when system boots but disallows login.
      \item System boots to runlevel 1
      \begin{itemize}
         \item \textbf{init} is started.
         \item Services are not started.
         \item Network is not activated.
         \item All possible filesystems are mounted.
         \item root access is granted without a password.
         \item A system maintenance command line shell is launched.
      \end{itemize}
   \end{itemize}

\end{frame}

\cprotect\note{

   If your system boots, but does not allow you to log in
   when it has completed booting, try \textbf{single user
      mode}.

   In this mode your system boots to \textbf{runlevel} 1 (in
   \textbf{SysVinit} language).  Because single user mode
   automatically tries to mount your filesystem, you can not
   use it when your root filesystem cannot be mounted
   successfully, or if the \textbf{init} configuration is
   corrupted.

   To boot into single user mode, you use the same method as
   described for emergency mode with one exception, replace
   the keyword \texttt{emergency} with the keyword
   \texttt{single}.

}


