\documentclass{cmlab} \RCS $Revision: 1.1 $ %\usepackage{varioref}% \usepackage{alltt}% \usepackage{key,xr,fixltx2e} \ifx\pdftexversion\undefined \else \usepackage[pdfpagemode=None,pdfauthor={Nick Urbanik}]{hyperref} \fi \newcommand*{\labTitle}{Solving Problems with Booting} \providecommand*{\fn}{\normalfont\tt} \externaldocument[ltr-]{../workshop-notes/build/masterfile} \begin{document} \section{Aim} \label{sec:aim} A number of students made some mistakes when installing Linux. This is intended to be a quick guide to people to solve these problems. \section{Background} \label{sec:background} Booting depends on LILO. You can read the user manual for LILO (in Red Hat 7) by typing: \begin{alltt} xdvi /usr/share/doc/lilo-21.4.4/doc/user & \end{alltt} or \begin{alltt} gv /usr/share/doc/lilo-21.4.4/doc/User_Guide.ps & \end{alltt} There are a number of reasons why Linux didn't start for a few students. Here are some of these reasons: \begin{itemize} \item LILO was installed in the boot partition instead of in the master boot record. Esily fixed. \item Linux partitions have been deleted. Hmm,\ldots reinstall! \item You entered \texttt{/root} instead of \texttt{/boot} as the mountpoint for \texttt{/dev/hda7}. This is not so simple, but I'll describe a solution here. \item I can boot, but I forgot my root password! (Blush with shame). Okay, that's easily fixed. Boot into single user mode and type \texttt{passwd}, enter a new password. Remember it! \item I can boot, but I forgot my normal account password. Easy. Log in as root, and type \texttt{passwd \emph{username}} \item I can boot, but I didn't make a non-root account for myself. Easy. Log in as root, and type \texttt{useradd \emph{username}} Then type \texttt{passwd \emph{username}} \end{itemize} \section{Procedure} \label{sec:procedure} \subsection{Determining the cause of the problem} \label{sec:identify-cause} \begin{enumerate} \item Boot the machine into Linux from the boot disk you created as the last step of the installation process. \begin{explanation} What? You mean you didn't make one? Oh, dear, well, borrow a boot disk from someone who did make one. This is \emph{not} the network installation boot disk, but is the emergency boot disk created at the last stage of installation. \end{explanation} \item If it doesn't boot, then use the procedure you used to run \texttt{fdisk} in the first class to examine the partition table. If the Linux partitions are not there, tough! You need to reinstall. Otherwise, you can ask Nick to have a look if he is around. \item After logging in as root, type \texttt{emacs /etc/lilo.conf} \end{enumerate} \subsection{Put boot loader in the right place (MBR)} \label{sec:useMBR} This is the easiest to fix. \begin{enumerate} \item The top line of \texttt{/etc/lilo.conf} should read: \begin{verbatim} boot=/dev/hda \end{verbatim} and \emph{not} \begin{verbatim} boot=/dev/hda7 \end{verbatim} If you see \texttt{boot=/dev/hda7}, change that to \texttt{boot=/dev/hda} \item Save the file \texttt{lilo.conf} by pressing \key{Control-x}\,\allowbreak\key{Control-s} within \textsf{emacs}. \item Exit from \textsf{emacs} by typing \key{Control-x}\,\allowbreak\key{Control-c}. \item As root, type: \begin{verbatim} /sbin/lilo \end{verbatim} \item If you see no error messages, then the problem is solved, and you can boot in future without the floppy disk. \item To check that all is well, remove the boot disk, reboot the computer, and when it restarts, log in to your own (non-root) account. \item In future, always log in using your own account; do not log in as root. \end{enumerate} \subsection{I think I typed \texttt{/root} instead of \texttt{/boot}} \label{sec:/root-/boot} Hmm, it still doesn't boot? Let's check another possibility. There are two disk partitions used to hold data in our Linux system: \texttt{hda7} and \texttt{hda9}. Linux does not have a \texttt{C:} dirve, a \texttt{D:} drive, an \texttt{E:} drive,\ldots, but it puts all the partitions under one \emph{root} directory called `\texttt{/}'. The problem described here is that the student selected that the small 8 or 16\,MB partition \texttt{hda7} be mounted on \texttt{/root}, instead of \texttt{/boot}. This means that the boot files are not below the disk cylinder 1024. This prevents the operating system from being started by the \BIOS. To solve this, we need to perform the following steps (described in detail further below in section~\vref{sec:howrecognise/boot-/root-problem} \begin{itemize} \item edit the \textbf{\underline{f}}ile \textbf{\underline{s}}ystem \textbf{\underline{tab}}le to always mount \texttt{hda7} on \texttt{/boot} in the future. \item change to single user mode (like Windows' safe mode) \item unmount \texttt{/root} and mount it on \texttt{/mnt} \item copy all files from \texttt{/mnt} to \texttt{/root}, inlcuding those ``hidden'' files that begin with a dot \item move all files from \texttt{/boot} to \texttt{/mnt} \item unmount the partition \texttt{hda7} from \texttt{/mnt}, and mount it where it was supposed to be, on \texttt{/boot}. \item run lilo. \end{itemize} Note that \texttt{/root} is the home directory for the root user. The \texttt{/boot} partition contains the essential files required to boot the operating system, including the operating system \emph{kernel}. This procedure uses methods that you will learn about later. I do not expect you to understand a great deal of it yet (you \emph{will} understand it in its entirely later). If you feel nervous about doing this, you could ask Patrick, our helpful and capable technician to do it. Show him this document. \subsubsection{How to diagnose the \texttt{/boot} $\Leftrightarrow$ \texttt{/root} problem} \label{sec:howrecognise/boot-/root-problem} \begin{enumerate} \item Log in as root \item Type \texttt{emacs /etc/fstab} \begin{explanation} This is the \textbf{\underline{f}}ile \textbf{\underline{s}}ystem \textbf{\underline{tab}}le. It is a very important configuration file in Linux\@. It is described in the current \emph{Linux Training Materials Project} document at \linuxTrainingNotes{} in sections~\ref{ltr-sec:filesystem-structure}, \ref{ltr-sec:fstab-example}, and \ref{ltr-sec:mount}. \end{explanation} \item There are two lines in this file that mount the hard disk partitions containing Linux file partitions; they \emph{should} look something like this (from memory): \begin{verbatim} LABEL=/ / ext2 defaults 1 1 LABEL=/boot /boot ext2 defaults 1 2 \end{verbatim} If instead, they look something like this: \begin{verbatim} LABEL=/ / ext2 defaults 1 1 LABEL=/root /root ext2 defaults 1 2 \end{verbatim} then you have the problem that the next section shows you how to fix. \end{enumerate} \subsubsection{How to fix the \texttt{/boot} $\Leftrightarrow$ \texttt{/root} problem} \label{sec:howFix/boot-/root-problem} Here we assume that you are logged in as root, and that you are editing \texttt{/etc/fstab} in \textsf{emacs}. \begin{enumerate} \item Change the line that looks like this: \begin{verbatim} LABEL=ROOT /root ext2 defaults 1 2 \end{verbatim} to this: \begin{verbatim} /dev/hda7 /boot ext2 defaults 1 2 \end{verbatim} \item Save the file by typing \key{Control-x}\,\key{Control-s}, then exit emacs by typing \key{Control-x}\,\allowbreak\key{Control-c}. \item Change to \emph{single user mode} by typing at the command prompt: \texttt{telinit 1} \begin{explanation} The screen will change to text mode. \end{explanation} \item Unmount the \texttt{hda7} partition by typing \texttt{umount /root} \item Mount it temporarily on the directory \texttt{/mnt} by typing: \begin{verbatim} mount /dev/hda7 /mnt \end{verbatim} \item Move all the files from \texttt{/mnt} to \texttt{/root}, except for the directory `\texttt{.}' and the directory `\texttt{..}'. This is a bit tricky, since most files will be ``hidden'', that is, their file name begins with a dot `\texttt{.}'. To move the files: \begin{enumerate} \item type \texttt{ls -a} \item For each file \texttt{file} listed, type: \texttt{mv \emph{file} /root} \item Do \emph{\textbf{not}} try to move the current directory `\texttt{.}' or the parent directory `\texttt{..}', or you may be sorry! \end{enumerate} \item Set the correct permissions on the \texttt{/root} directory by typing \mbox{\texttt{chmod 700 /root}} \item Now move all the files from the \texttt{/boot} directory to the small \texttt{hda7} partition by typing: \begin{verbatim} cd /boot mv * /mnt \end{verbatim} \item Unmount \texttt{hda7} from the directory \texttt{/mnt} by typing: \begin{verbatim} umount /mnt \end{verbatim} \item Mount \texttt{hda7} on \texttt{/boot} (the proper place it would have been if you didn't make the mistake!) by typing: \begin{verbatim} mount /dev/hda7 /boot \end{verbatim} \item Run lilo (this step actually puts the boot loader into the master boot record \texttt{/dev/hda}): \begin{verbatim} lilo \end{verbatim} \item If you see no error messages, remove the boot disk and reboot the computer by either typing \key{Alt}\,\key{Control}\,\key{Delete} or by typing \begin{verbatim} shutdown -r now \end{verbatim} \item If you see error messages when you typed \texttt{lilo} above, then talk with Nick if he is nearby. \item Your computer should reboot successfully; if not, talk with Nick. \end{enumerate} \subsection{Always log in as your own personal account} Always log in as your own personal account from now on. Do not log in as root in the future; otherwise two things will inevitably happen: \begin{itemize} \item I will look upon you with great scorn. \item One day you will make a typing mistake and destroy some important files (or maybe delete all of your files on the entire hard disk!) \end{itemize} \end{document}