⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user.tex

📁 linux 的引导程序源码The Microsoft&reg Windows&reg Software Development Kit (SDK) provides the documentation
💻 TEX
📖 第 1 页 / 共 5 页
字号:
  \item[The kernel] is loaded and started by the boot loader. Kernels    typically reside in the root directory or in \path{/boot}.\end{description}Note that many of the files \LILO\ needs at boot time have to be accessiblewith the BIOS. This creates certain restrictions, see section \ref{broken}.\newpage\section{Introduction}The following sections describe how PCsboot in general and what has to be known when booting Linux and using\LILO\ in particular.\subsection{Disk organization}\label{diskorg}When designing a boot concept, it is important to understand some of thesubtleties of how PCs typically organize disks. The most simple case arefloppy disks. They consist of a boot sector, some administrativedata (FAT or super block, etc.) and the data area. Because thatadministrative data is irrelevant as far as booting is concerned, it isregarded as part of the data area for simplicity.%%beginskip$$\begin{tabular}{|c|c|}  \hline  Boot sector & \hbox to 1.5in{\hfil} \\  \cline{1-1}  \multicolumn{2}{|c|}{} \\  \multicolumn{2}{|c|}{Data area} \\  \multicolumn{2}{|c|}{} \\  \hline  \end{tabular}$$%%endskip%:\begin{verbatim}%;    +---------------------------+%;    |Boot sector|               |%;    |-----------+               |%;    |                           |%;    |         Data area         |%;    |                           |%;    |                           |%;    +---------------------------+%:\end{verbatim}The entire disk appears as one device (e.g. \path{/dev/fd0}) on Linux.The MS-DOS boot sector has the following structure:%%beginskip$$\begin{tabular}{r|c|}  \cline{2-2}  \tt 0x000 & Jump to the program code\\  \cline{2-2}  \tt 0x003 & \\  & Disk parameters \\  & \\  \cline{2-2}  \tt 0x02C/0x03E & \\  & Program code \\  & \\  & \\  \cline{2-2}  \tt 0x1FE & Magic number (0xAA55)\\  \cline{2-2}\end{tabular}$$%%endskip%:\begin{verbatim}%;            +------------------------+%;      0x000 |Jump to the program code|%;            |------------------------|%;      0x003 |                        |%;            |    Disk parameters     |%;            |                        |%;            |------------------------|%;0x02C/0x03E |                        |%;            |      Program code      |%;            |                        |%;            |                        |%;            |------------------------|%;      0x1FE | Magic number (0xAA55)  |%;            +------------------------+%:\end{verbatim}\LILO\ uses a similar boot sector, but it does not contain the diskparameters part. This is no problem for Minix, Ext2 or similar file systems,becausethey don't look at the boot sector, but putting a \LILO\ boot sector on anMS-DOS file system would make it inaccessible for MS-DOS.Hard disks are organized in a more complex way than floppy disks. Theycontain several data areas called partitions. Up to four so-calledprimary partitions can exist on an MS-DOS hard disk. If more partitionsare needed, one primary partition is used as an extended partition thatcontains several logical partitions.The first sector of each hard disk contains a partition table, and anextended partition and \emphasize{each} logical partition contains a partitiontable too.%%beginskip$$\begin{tabular}{|l|l|l|}  \hline  \multicolumn{3}{|l|}{Partition table\hbox to 2in{\hfil\tt /dev/hda~}} \\  \cline{2-3}  & \multicolumn{2}{l|}{Partition 1\hfill {\tt /dev/hda1}} \\  & \multicolumn{2}{l|}{} \\  \cline{2-3}  & \multicolumn{2}{l|}{Partition 2\hfill {\tt /dev/hda2}} \\  & \multicolumn{2}{l|}{} \\  \hline\end{tabular}$$%%endskip%:\begin{verbatim}%;+--------------------------------------------+%;| Partition table                  /dev/hda  |%;| +------------------------------------------|%;| | Partition 1                    /dev/hda1 |%;| |                                          |%;| |------------------------------------------|%;| | Partition 2                    /dev/hda2 |%;| |                                          |%;+--------------------------------------------+%:\end{verbatim}The entire disk can be accessed as \path{/dev/hda}, \path{/dev/hdb},\path{/dev/sda}, etc. The primary partitions are \path{/dev/hda1 $\ldots$/dev/hda4}.%%beginskip$$\begin{tabular}{|l|l|l|}  \hline  \multicolumn{3}{|l|}{Partition table\hbox to 2in{\hfil\tt /dev/hda~}} \\  \cline{2-3}  & \multicolumn{2}{l|}{Partition 1\hfill {\tt /dev/hda1}} \\  & \multicolumn{2}{l|}{} \\  \cline{2-3}  & \multicolumn{2}{l|}{Partition 2\hfill {\tt /dev/hda2}} \\  & \multicolumn{2}{l|}{} \\  \cline{2-3}  & \multicolumn{2}{l|}{Extended partition\hfill {\tt /dev/hda3}} \\  \cline{3-3}  & & Extended partition table \\  \cline{3-3}  & & Partition 3\hfill {\tt /dev/hda5}\\  & & \\  \cline{3-3}  & & Extended partition table \\  \cline{3-3}& & Partition 4\hfill {\tt /dev/hda6}\\  & & \\  \hline\end{tabular}$$%%endskip%:\begin{verbatim}%;+--------------------------------------------+%;| Partition table                  /dev/hda  |%;| +------------------------------------------|%;| | Partition 1                    /dev/hda1 |%;| |                                          |%;| |------------------------------------------|%;| | Partition 2                    /dev/hda2 |%;| |                                          |%;| |------------------------------------------|%;| | Extended partition             /dev/hda3 |%;| | +----------------------------------------|%;| | | Extended partition table               |%;| | |----------------------------------------|%;| | | Partition 3                  /dev/hda5 |%;| | |                                        |%;| | |----------------------------------------|%;| | | Extended partition table               |%;| | |----------------------------------------|%;| | | Partition 4                  /dev/hda6 |%;| | |                                        |%;+--------------------------------------------+%:\end{verbatim}This hard disk has two primary partitions and an extended partitionthat contains two logical partitions. They are accessed as\path{/dev/hda5 $\ldots$}Note that the partition tables of logical partitions are not accessibleas the first blocks of some devices, while the main partition table,all boot sectors and the partition tables of extended partitions are.Partition tables are stored in partition boot sectors. Normally, only thepartition boot sector of the entire disk is used as a boot sector. It isalso frequently called the master boot record (MBR). Its structure is asfollows:%%beginskip$$\begin{tabular}{r|c|}  \cline{2-2}  \tt 0x000 & \\  & Program code \\  & \\  & \\  \cline{2-2}  \tt 0x1BE & Partition table \\  & \\  \cline{2-2}  \tt 0x1FE & Magic number (0xAA55) \\  \cline{2-2}\end{tabular}$$%%endskip%:\begin{verbatim}%;            +------------------------+%;      0x000 |                        |%;            |      Program code      |%;            |                        |%;            |                        |%;            |------------------------|%;      0x1BE |    Partition table     |%;            |                        |%;            |------------------------|%;      0x1FE | Magic number (0xAA55)  |%;            +------------------------+%:\end{verbatim}The \LILO\ boot sector is designed to be usable as a partition boot sector.(I.e. there is room for the partition table.)Therefore, the \LILO\ boot sector can be stored at the following locations:\begin{itemize}  \item boot sector of a Linux floppy disk. (\path{/dev/fd0}, $\ldots$)  \item MBR of the first hard disk. (\path{/dev/hda}, \path{/dev/sda}, $\ldots$)  \item boot sector of a primary Linux file system partition on the first hard    disk. (\path{/dev/hda1}, $\ldots$)  \item partition boot sector of an extended partition on the first hard disk.    (\path{/dev/hda1}, $\ldots$)\footnote{Most FDISK-type programs don't      believe in booting from an extended partition and refuse to      activate it. \LILO\ is accompanied by a simple program      (\name{activate}) that doesn't have this restriction. Linux \name{fdisk}      also supports activating extended partitions.}\end{itemize}It \emphasize{can't} be stored at any of the following locations:\begin{itemize}  \item boot sector of a non-Linux floppy disk or primary partition.  \item a Linux swap partition.  \item boot sector of a logical partition in an extended partition.%\footnote{\LILO\ can be forced to put the boot sector on such a partition by using the \raw{-b} option or the \craw{boot} variable. However, only few programs that operate as master boot records support booting from a logical partition.}  \item on the second hard disk. (Unless for backup installations,    if the current first disk will be removed or disabled, or if some    other boot loader is used, that is capable of loading boot sectors from    other drives.)\end{itemize}Although \LILO\ tries to detect attempts to put its boot sector at aninvalid location, you should not rely on that.\subsection{Booting basics}When booting from a floppy disk, the first sector of the disk, the so-calledboot sector, is loaded. That boot sector contains a small program that loadsthe respective operating system. MS-DOS boot sectors also contain a data area, where disk and file system parameters (cluster size, number ofsectors, number of heads, etc.) are stored.When booting from a hard disk, the very first sector of that disk, theso-called master boot record (MBR) is loaded. This sector contains aloader program and the partition table of the disk. The loader programusually loads the boot sector, as if the system was booting from a floppy.Note that there is no functional difference between the MBR and the bootsector other than that the MBR contains the partition information butdoesn't contain any file system-specific information (e.g. MS-DOS diskparameters).The first 446 (0x1BE) bytes of the MBR are used by the loader program.They are followed by the partition table, with a length of 64 (0x40)bytes. The last two bytes contain a magic number that is sometimes used toverify that a given sector really is a boot sector.There is a large number of possible boot configurations. The most commonones are described in the following sections.\subsubsection{MS-DOS alone}%%beginskip\bootthree{DOS-MBR \sep MS-DOS \sep COMMAND.COM}%%endskip%:\begin{verbatim}%;+-------------------------------------------------------+%;| Master Boot Record    Boot sector    Operating system |%;|-------------------------------------------------------|%;| DOS-MBR ------------> MS-DOS ------> COMMAND.COM      |%;+-------------------------------------------------------+%:\end{verbatim}This is what usually happens when MS-DOS boots from a hard disk: the DOS-MBRdetermines the active partition and loads the MS-DOS boot sector. This bootsector loads MS-DOS and finally passes control to \path{COMMAND.COM}. (This isgreatly simplified.)\subsubsection{LOADLIN}%%beginskip\bootfour{DOS-MBR \sep MS-DOS \sep COMMAND.COM \empty \\  \empty \branch LOADLIN \sep Linux}%%endskip%:\begin{verbatim}%4+------------------------------------------------------------+%4| Master Boot Record    Boot sector    Operating system      |%4|------------------------------------------------------------|%4| DOS-MBR ------------> MS-DOS ------> COMMAND.COM           |%4|                                 ---> LOADLIN ------> Linux |%4+------------------------------------------------------------+%:\end{verbatim}A typical \name{LOADLIN} setup: everything happens like when booting MS-DOS,but in \path{CONFIG.SYS} or \path{AUTOEXEC.BAT}, LOADLIN is invoked. Typically,a program like \path{BOOT.SYS} is used to choose among configuration sectionsin \path{CONFIG.SYS} and \path{AUTOEXEC.BAT}.This approach has the pleasant property that no boot

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -