一台没有软件运行的电脑只是一堆发热的电子器件。当计算机起电启动开始的第一件 事情就是运行一个叫做“操作系统”的特殊程序。操作系统的作用就是帮助其他的程序能够 的控制和访问计算机硬件。
装入操作系统的步骤叫作引导(booting)。(从严格意义上说，引导和自我检查的 处理步骤叫做“自检”)。您的计算机知道如何去引导，因为在其具体的操作方法已经 集成在一块称做 BIOS(或者叫基本输入输出系统)的芯片中了。
BIOS 芯片告诉计算机查看一个合适的地方引导系统，通常这个地方在编号最小的磁盘 上(引导盘)。一个称做引导器的程序(在 linux 下通常是 Grub 或者是 LILO)会被装入 内存，并且启动。引导器的作用就是装入真正的操作系统。
接下来引导器会寻找一个内核，并将它装入内存后运行它。当你启动 Linux 的时候， LILO 会在系统屏幕上打印出一些小点，这说明它正在装入内核。(每一个点的意思就是已经 引导读取了磁盘上所指向内核的簇)。
(你可能会感到困惑，为什么 BIOS 不会直接引导系统，而舍直求曲的分成两个步骤呢？ 事实上 BIOS 不是非常的智能，甚至可以说是有点木讷。因此 Linux 内核会在引导以后不再 使用它。这是因为这个程序是为有八字节限制的 PC 而写的，并且 BIOS 容量也有限制。 所以可能在引导的时候不能读取磁盘的後余的扇区。与此相比，引导程序却可以允许你引 导磁盘上不只一个操作系统。(虽然它可以引导其他的 UNIX 系统，但是通常不会这么 做。)
当内核启动以后，它会自动检查和初始化硬件，并且准备运行程序。它通过一些 I/O 端口、 特殊的总线查找硬件，而非一般的内存地址。这是因为这些总线通常它们会有控制卡监听并 执行相应的命令。内核检查硬件不是随机的，它有一套内建的机制去处理它：哪里去寻找硬件， 怎样控制正常使用的硬件等等。这个步骤称为自动检查(autoprobing)。
在内核自检的时候你会从屏幕上看到很多的信息，这是内核正在通过上述的 I/O 端口自动检查硬件，指出你的机器上有哪些可用的硬件并组织好它们。Linux 非常擅长于做 这些事情，这个功能相对来说比一些其他的 UNIX 系统要好，和 DOS 或者 Windows 来说要 好的多。事实上，许多 Linux 老用户会认为内核并不需要那么智能的检查硬件(即使这样可 以容易安装系统)，这是因为他们有一个非常好的理由让那些吹毛求丝的用户跳出的无聊的 自由代码实验。
但是内核完全载入并且运行完毕并不是引导的结束；这仅仅是第一个阶段(有时被称做 运行级别一，run level 1)。在运行完运行级别一以后，内核回将控制权转交给一个 叫做 init 的程序，它将启动一些用户进程。
Init 进程所做的第一件事情就检查你磁盘的完整性。磁盘文件系统是一个非常重要的； 如果它们因为硬件问题或者是突然断电，那就有一个非常好的理由在 UNIX 系统引导前 检查并且修复它们。我们会等会详细的讨论文件系统为什么会损坏。
Init 接下来的事情就是启动一些精灵进程(daemon)，比如打印控制控制系统、邮件 监听器、或者是一个 WWW 服务器。精灵进程会在后台(background)运行，监视指定所要做的 事情。这些特殊的程序经常会相互处理所需要的请求，避免冲突。 它们之所以是精灵进程， 是因为它们容易写成一个程序集合用来应答和处理所有需要的服务，而非为了一个同样的请求 又去启动另外一个新的进程。精灵程序所生成的每一个进程将处理一个任务并且同时运行，而 不影响别的进程。在每个系统上运行的精灵程序是不同的，但是通常都有一个打印监视进程 (一个控制你打印机的精灵进程)。
下一步就是为用户准备了。Init 开启一个名叫 getty 的进程监视你的控制台(console)(也 许是一个拨号接入的端口)。这个程序会在你的终端提供一个登陆符让您登陆系统。当所有的精 灵进程和 getty 进程在每个终端启动完毕，我们就处在了运行级别二(run level 2)。这时，在 这个级别下你可以登陆并且运行程序了。
但是事情并没有完，下一步就时开启一些别的有用的程序，比如网络和其他的一些服务。 当这些全部完成以后，我们所处在的是级别三运行模式(run level 3)，并且这时系统就 完全可以使用了。
What happens when you switch on a computer?
A computer without a program running is just an inert hunk of electronics. The first thing a computer has to do when it is turned on is start up a special program called an operating system. The operating system's job is to help other computer programs to work by handling the messy details of controlling the computer's hardware.
The process of bringing up the operating system is called booting (originally this was bootstrapping and alluded to the process of pulling yourself up "by your bootstraps"). Your computer knows how to boot because instructions for booting are built into one of its chips, the BIOS (or Basic Input/Output System) chip.
The BIOS chip tells it to look in a fixed place, usually on the lowest-numbered hard disk (the boot disk) for a special program called a boot loader (under Linux the boot loader is called Grub or LILO). The boot loader is pulled into memory and started. The boot loader's job is to start the real operating system.
The loader does this by looking for a kernel, loading it into memory, and starting it. When you boot Linux and see "LILO" on the screen followed by a bunch of dots, it is loading the kernel. (Each dot means it has loaded another disk block of kernel code.)
(You may wonder why the BIOS doesn't load the kernel directly ? why the two-step process with the boot loader? Well, the BIOS isn't very smart. In fact it's very stupid, and Linux doesn't use it at all after boot time. It was originally written for primitive 8-bit PCs with tiny disks, and literally can't access enough of the disk to load the kernel directly. The boot loader step also lets you start one of several operating systems off different places on your disk, in the unlikely event that Unix isn't good enough for you.)
Once the kernel starts, it has to look around, find the rest of the hardware, and get ready to run programs. It does this by poking not at ordinary memory locations but rather at I/O ports ? special bus addresses that are likely to have device controller cards listening at them for commands. The kernel doesn't poke at random; it has a lot of built-in knowledge about what it's likely to find where, and how controllers will respond if they're present. This process is called autoprobing.
Most of the messages you see at boot time are the kernel autoprobing your hardware through the I/O ports, figuring out what it has available to it and adapting itself to your machine. The Linux kernel is extremely good at this, better than most other Unixes and much better than DOS or Windows. In fact, many Linux old-timers think the cleverness of Linux's boot-time probes (which made it relatively easy to install) was a major reason it broke out of the pack of free-Unix experiments to attract a critical mass of users.
But getting the kernel fully loaded and running isn't the end of the boot process; it's just the first stage (sometimes called run level 1). After this first stage, the kernel hands control to a special process called 慽nit? which spawns several housekeeping processes.
The init process's first job is usually to check to make sure your disks are OK. Disk file systems are fragile things; if they've been damaged by a hardware failure or a sudden power outage, there are good reasons to take recovery steps before your Unix is all the way up. We'll go into some of this later on when we talk about how file systems can go wrong.
Init's next step is to start several daemons. A daemon is a program like a print spooler, a mail listener or a WWW server that lurks in the background, waiting for things to do. These special programs often have to coordinate several requests that could conflict. They are daemons because it's often easier to write one program that runs constantly and knows about all requests than it would be to try to make sure that a flock of copies (each processing one request and all running at the same time) don't step on each other. The particular collection of daemons your system starts may vary, but will almost always include a print spooler (a gatekeeper daemon for your printer).
The next step is to prepare for users. Init starts a copy of a program called getty to watch your console (and maybe more copies to watch dial-in serial ports). This program is what issues the login prompt to your console. Once all daemons and getty processes for each terminal are started, we're at run level 2. At this level, you can log in and run programs.
But we're not done yet. The next step is to start up various daemons that support networking and other services. Once that's done, we're at run level 3 and the system is fully ready for use.
Because...nobody really uses an operating system,
people use...programs...on their computer.
And the only mission in life of an operating system is to helps those programs run.