\section{SysVinit Startup **}

\begin{frame}
   {The slow fade out of SysVinit}

   \begin{itemize}
      \item
      No longer the method of system startup and shutdown,
      and managing services on any major \textbf{Linux}
      distribution
      \item
      Compatibility layers exist to use \textbf{SysVinit}
      methods and commands, so occasionally some need to learn them
      \item
      Some third party software still may not have adapted
      to use \textbf{systemd}
      \item
      Wrappers handle:
      \begin{itemize}
         \item \textbf{SysVinit} scripts
         \item \textbf{chkconfig} command
         \item \textbf{service} command
      \end{itemize}
      \item
      Eventually will be able to drop discussion of
      \textbf{SysVinit} as well as \textbf{Upstart}
   \end{itemize}
\end{frame}

\cprotect\note {

   \textbf{SysVinit}was the standard method for starting and
   shutting down systems, and for managing services for many
   years.

   However, it has been replaced on all major \textbf{Linux}
   distributions by \textbf{systemd}.  There is still some value in
   covering how it works as it is being replaced, as
   compatibility layers have been put into place to ensure the
   older methods can still be used.

   Furthermore, sometimes third party software has not been
   updated to use the \textbf{systemctl} methods of
   \textbf{systemd}.

   Besides discussion of run levels, and other ingredients, the
   \textbf{chkconfig} and \textbf{service} commands will also
   be explained.

}

\begin{frame}
   {SysVinit Runlevels}

   \begin{itemize}
      \item System state configurations used by \textbf{SysVinit}
      \item Emulated by \textbf{systemd} and \textbf{Upstart}
      \item Control which portions of the system are
      initialized
   \end{itemize}
   \smallskip

   \begin{table}[H]
      \caption{SysVinit Runlevels}
      \vspace{-15pt}
   \end{table}

   \small{\begin{tcolorbox}[tabularx={p{0.25\textwidth}|X}]
         \textbf{Runlevel}
         &
         \textbf{Meaning}
         \\ \hline
         \hline
         S, s
         &
         Same as 1
         \\ \hline
         0
         &
         Shutdown system and turn power off
         \\ \hline
         1
         &
         Single User Mode
         \\ \hline
         2
         &
         Multiple user, no \textbf{NFS}, only text login
         \\ \hline
         3
         &
         Multiple user, with \textbf{NFS} and network, only text login
         \\ \hline
         4
         &
         Not used
         \\ \hline
         5
         &
         Multiple User, \textbf{NFS}, network, graphical login with
         \textbf{X}
         \\ \hline
         6
         &
         Reboot
      \end{tcolorbox}}

\end{frame}

\cprotect\note{

   As a \textbf{SysVinit} system starts is passes through
   a sequence of \textbf{runlevels} which define different
   system states; they are numbered from 0 to 6.

   While \textbf{systemd} works with \textbf{targets}, not
   runlevels, many experienced users and administrators are
   accustomed to the nomenclature, and \textbf{systemd}
   often can accommodate equivalent backward compatible
   language.

   Runlevel 0 is reserved for the \textbf{system halt}
   state, runlevel 1 for \textbf{single-user mode}, and
   runlevel 6 for \textbf{system reboot}.  The other
   runlevels are used to define what services are running
   for a normal system and different distributions define
   them somewhat differently.  For example, on \textbf{Red
      Hat}-based systems, runlevel 2 is defined as a
   running system without networking or \textbf{X},
   runlevel 3 includes networking, and runlevel 5 includes
   networking and \textbf{X}.

   The current runlevel can be simply displayed with the
   \textbf{runlevel} command as in:
   \begin{cmd}
$ runlevel
   \end{cmd}
   \begin{response}
  N 5
   \end{response}
   where the first character is the previous level;
   \texttt{N}  means unknown.

   \textbf{telinit} can be used to change the runlevel of
   the system.  For example, to go from runlevel 3 to
   runlevel 5, type:
   \begin{cmd}
$ sudo /sbin/telinit 5
   \end{cmd}

}

\begin{frame}
   {SysVinit Startup Scripts}

   \begin{itemize}
      \item All the actual scripts are in
      \filelink{/etc/init.d}: each runlevel directory
      (\filelink{/etc/rcX.d}) just links back to them.
      \item \textbf{Start} scripts start with \texttt{S}
      \item \textbf{Kill} scripts start with \texttt{K}
   \end{itemize}

\end{frame}

\cprotect\note{

The traditional method is to first run the
\texttt{rc.sysinit} script, which performs numerous
functions, such as starting \textbf{LVM}, mounting
filesystems, etc.  This script resides in the
\filelink{/etc} directory but more likely is in
\filelink{/etc/rc.d} with a symbolic link to
\filelink{/etc}.

Next the \texttt{rc} script (in the same directory) is run
with the desired runlevel as an argument.  This causes the
system to go to the \texttt{rc.d/rc[0-6].d} directory and
run all the scripts in there:
\begin{cmd}
$ ls -lF /etc/rc.d/rc5.d
  \end{cmd}
\begin{response}
total 0
lrwxrwxrwx. 1 root root 14 Sep  3 10:05 K05pmcd -> ../init.d/pmcd*
lrwxrwxrwx. 1 root root 14 Sep  3 10:05 K05pmie -> ../init.d/pmie*
....
lrwxrwxrwx. 1 root root 17 Sep  3 09:39 S10network -> ../init.d/network*
lrwxrwxrwx  1 root root 16 Sep  6 08:50 S19vmware -> ../init.d/vmware*
   \end{response}

The number following the \texttt{K} or \texttt{S} in
each script's name determines the order in which the
scripts are invoked.  The script name is also the name
of the \textbf{service}.

The \texttt{rc.local} script may be used to start
system-specific applications.

The existence or non-existence of a script's symbolic
link in a runlevel directory determines whether or not
the script is executed at that runlevel.

Controlling which initialization scripts are run on
entry to each runlevel involves managing the symbolic
links.  While it is possible to manage these links
manually, there are utilities such as
\textbf{chkconfig} which are designed to do this
consistently and more easily.

}

