Product SiteDocumentation Site

4.2. 安装,一步一步来

4.2.1. 引导和开始安装

一旦 BIOS 开始从 CD-/DVD-ROM 引导,就出现 Isolinux 引导程序界面。这时, Linux 内核还没有加载;菜单让你选择内核开始引导,同时可以加上参数以满足你的需求。
For a standard installation, you only need to choose “Install” or “Graphical install” (with the arrow keys), then press the Enter key to initiate the remainder of the installation process. If the DVD-ROM is a “Multi-arch” disk, and the machine has an Intel or AMD 64 bit processor, the menu options “64 bit install” and “64 bit graphical install” enable the installation of the 64 bit variant (amd64) instead of the default 32 bit variant (i386). In practice, the 64 bit version can almost always be used: most recent processors are 64 bit processors and the 64 bit version deals better with the large amount of RAM that new computers tend to have.
每条菜单项隐藏了一个特定的引导命令行,在验证和引导前,该命令行可以用 TAB 键补全可能的设备或文件名。Help 菜单项显示了旧的命令行接口,按键 F1F10 显示了不同的各种可选提示的帮助屏幕。在特定情况下你会选择相应的选项。
The “expert” mode (accessible in the “Advanced options” menu) details all possible options in the process of installation, and allows navigation between the various steps without them happening automatically in sequence. Be careful, this very verbose mode can be confusing due to the multitude of configuration choices that it offers.

图 4.1. 引导界面

Once booted, the installation program guides you step by step throughout the process. This section presents each of these steps in detail. Here we follow the process of an installation from a Multi-Arch DVD-ROM (more specifically, the beta4 version of the installer for Jessie); netinst installations, as well as the final release of the installer, may look slightly different. We will also address installation in graphical mode, but the only difference from “classic” (text-mode) installation is in the visual appearance.

4.2.2. 选择语言

安装程序以英语开始,但第一步允许用户选择后面过程使用的语言。比如选择 Chinese,会提供完全中文的安装界面。这一选项也被用来定义在后续阶段(特别是键盘布局)更相关的默认选择。

图 4.2. 选择语言

4.2.3. 选择国家

第2步为选择国家和地区。该信息能为程序提供最合适的键盘布局,及语言。这也会影响时区设定。在美国,推荐使用标准的 QWERTY 键盘,并选择合适的时区。

图 4.3. 选择国家

4.2.4. 选择键盘布局

所建议的“American English”(美式英语)键盘对应于通常的 QWERTY 键盘布局。

图 4.4. 键盘选择

4.2.5. 检测硬件

在绝大多数情况下,这一步是完全自动的。安装程序探测你的硬件,并试图确定使用的 CD-ROM 驱动器,以访问其内容。加载相应的各种探测到的硬件组件的驱动模块,为了读取它然后 “挂载” CD-ROM。前几项步骤完全包括在安装 CD 的引导镜像里,BIOS 从 CD 引导的时候加载进了内存的一个受限大小的文件。
安装程序可以处理大部分主要的硬盘,特别是标准的 ATAPI 外部设备(有时也叫做 IDE 和 EIDE)。然而,如果探测到 CD-ROM 读取失败,安装程序会提供相应 CD-ROM 驱动器的内核模块选项加载(比如从 U盘 引导)。

4.2.6. 加载组件

With the contents of the CD now available, the installer loads all the files necessary to continue with its work. This includes additional drivers for the remaining hardware (especially the network card), as well as all the components of the installation program.

4.2.7. 检测网络硬件

This automatic step tries to identify the network card and load the corresponding module. If automatic detection fails, you can manually select the module to load. If no module works, it is possible to load a specific module from a removable device. This last solution is usually only needed if the appropriate driver is not included in the standard Linux kernel, but available elsewhere, such as the manufacturer's website.
This step must absolutely be successful for netinst installations, since the Debian packages must be loaded from the network.

4.2.8. 配置网络

In order to automate the process as much as possible, the installer attempts an automatic network configuration by DHCP (for IPv4) and by IPv6 network discovery. If this fails, it offers more choices: try again with a normal DHCP configuration, attempt DHCP configuration by declaring the name of the machine, or set up a static network configuration.
最后选项需要一个 IP 地址,一个子网掩码,一个网关 IP 地址,一个机器名,一个域名。

4.2.9. 管理员密码

The super-user root account, reserved for the machine's administrator, is automatically created during installation; this is why a password is requested. The installer also asks for a confirmation of the password to prevent any input error which would later be difficult to amend.

图 4.5. 管理员密码

4.2.10. 建第一个用户


图 4.6. 第一个用户的名字

4.2.11. 配置时钟

If the network is available, the system's internal clock is updated (in a one-shot way) from an NTP server. This way the timestamps on logs will be correct from the first boot. For them to remain consistently precise over time, an NTP daemon needs to be set up after initial installation (see 第 8.9.2 节 “Time Synchronization”).

4.2.12. 检测磁盘和其他设备

这一步自动检测安装 Debian 的硬盘。下一步将是:分区。

4.2.13. 开始分区的工具

一般来说分区对新用户有一定难度。需要定义各种划分的磁盘分区,在上面建Linux 文件系统和虚拟内存。这是件复杂的任务,如果你想保存这个硬盘上的另一个系统。本质上,你只要确定不要修改分区表(也不要修改分区大小就不会损坏数据)。
Fortunately, the partitioning software has a “guided” mode which recommends partitions for the user to make — in most cases, you can simply validate the software's suggestions.

图 4.7. 分区模式的选择

The first screen in the partitioning tool offers the choice of using an entire hard drive to create various partitions. For a (new) computer which will solely use Linux, this option is clearly the simplest, and you can choose the option “Guided - use entire disk”. If the computer has two hard drives for two operating systems, setting one drive for each is also a solution that can facilitate partitioning. In both of these cases, the next screen offers to choose the disk where Linux will be installed by selecting the corresponding entry (for example, “SCSI1 (0,0,0) (sda) - 12.9 GB ATA VBOX HARDDISK”). You then start guided partitioning.

图 4.8. 使用硬盘分区

分区还可以设置成 LVM 逻辑卷。因为剩下的操作都一样的,所以我们就没有这一项(引导--使用整个硬盘并设置 LVM )。
在其他情况下,当 Linux 必须与其他已经存在分区共存,您就需要手动分区了。 引导分区


图 4.9. 引导分区

The first method is called “All files in one partition”. The entire Linux system tree is stored in a single filesystem, corresponding to the root / directory. This simple and robust partitioning fits perfectly for personal or single-user systems. In fact, two partitions will be created: the first will house the complete system, the second the virtual memory (swap).
第二个方法, “单独的 /home/ 分区”,很类似,但文件系统层次分成两个;一个包含了 Linux 系统(/),第二个包含了 “home 文件夹”(意味着用户数据,文件和子文件夹存在于 /home/ 下面)。
The last partitioning method, called “Separate /home, /var, and /tmp partitions”, is appropriate for servers and multi-user systems. It divides the file tree into many partitions: in addition to the root (/) and user accounts (/home/) partitions, it also has partitions for server software data (/var/), and temporary files (/tmp/). These divisions have several advantages. Users can not lock up the server by consuming all available hard drive space (they can only fill up /tmp/ and /home/). The daemon data (especially logs) can no longer clog up the rest of the system.
After choosing the type of partition, the software calculates a suggestion, and describes it on the screen; the user can then modify it if needed. You can, in particular, choose another filesystem if the standard choice (ext4) isn't appropriate. In most cases, however, the proposed partitioning is reasonable and it can be accepted by selecting the “Finish partitioning and write changes to disk” entry.

图 4.10. 验证分区 手动分区

手动分区更加灵活,允许用户选择每个分区的用途和大小。进一步的话,如果你希望使用软件 RAID 这个步骤是不可避免的。
首先显示可用硬盘,它们的分区,没被分区的可用的剩余空间。你可以选择每个显示的分支;按下 Enter 键,然后列出了可选操作。
When selecting free space on a disk, you can manually create a new partition. You can also do this with guided partitioning, which is an interesting solution for a disk that already contains another operating system, but which you may wish to partition for Linux in a standard manner. See 第 节 “引导分区” for more details on guided partitioning.
When choosing a partition, you can indicate the manner in which you are going to use it:
  • 格式化并在文件树下选择挂载点
  • 使用为它作为交换分区;
  • 使之成为 “加密的物理卷” (特定分区上的数据保密,见下文);
  • 使用它作为“ LVM 的物理卷”(本章稍后对此概念作详细讨论)
  • 使用它作为 RAID 设备(见本章以下内容)
  • you can also choose not to use it, and therefore leave it unchanged. 配置多磁盘设备(软件 RAID)

某些 RAID 类型允许在硬盘上存储重复数据以防其中一块硬盘出现故障导致数据丢失。 RAID 1 保持一块磁盘对另一块硬盘进行简单,相同的复制(镜像),而 RAID 5 把冗余数据分到多块磁盘上,因此任何一块硬盘出现问题都可以完整的重建。
这里我们仅描述 RAID 1,是最简单的实现。第一个步骤是在两块不同的硬盘上创建两个相同大小的分区位于,为他们标上 “物理卷 RAID”。
You must then choose “Configure software RAID” in the partitioning tool to combine these two partitions into a new virtual disk and select “Create MD device” in the configuration screen. You then need to answer a series of questions about this new device. The first question asks about the RAID level to use, which in our case will be “RAID1”. The second question asks about the number of active devices — two in our case, which is the number of partitions that need to be included in this MD device. The third question is about the number of spare devices — 0; we have not planned any additional disk to take over for a possible defective disk. The last question requires you to choose the partitions for the RAID device — these would be the two that we have set aside for this purpose (make sure you only select the partitions that explicitly mention “raid”).
返回主菜单,一个新的虚拟 "RAID" 盘会出现。这个虚拟盘显示为一个分区,它不能被删除,但我们可以把它当作其他任何分区一样使用。
For further details on RAID functions, please refer to 第 12.1.1 节 “软 RAID”. 配置逻辑卷管理 (LVM)

LVM allows you to create “virtual” partitions that span over several disks. The benefits are twofold: the size of the partitions are no longer limited by individual disks but by their cumulative volume, and you can resize existing partitions at any time, possibly after adding an additional disk when needed.
LVM 使用了特别的技术:一块虚拟的分区是一个 “逻辑卷”,是 “逻辑卷组” 的一部分,或者是一些 “物理卷” 的组合。实际上每一个术语都对应着一个 “真正” 的分区(或一个软件 RAID 设备)。
这项技术工作方式很简单:每个卷,不管是物理卷还是逻辑卷,对应到 LVM 它们都被划成相同大小的块。增加新硬盘以创建新的物理卷,这些新的块被关联到任意的卷组。所有卷组上的分区会因而扩展更多空间。
The partitioning tool configures LVM in several steps. First you must create on the existing disks the partitions that will be “physical volumes for LVM”. To activate LVM, you need to choose “Configure the Logical Volume Manager (LVM)”, then on the same configuration screen “Create a volume group”, to which you will associate the existing physical volumes. Finally, you can create logical volumes within this volume group. Note that the automatic partitioning system can perform all these steps automatically.
The usage of LVM is described in further detail in 第 12.1.2 节 “LVM(逻辑卷管理)”. 设置加密分区

为了保证您的数据的保密性,例如,在您的计算机或硬盘丢失或被盗的情况下,某些分区上的数据可进行加密。这个特性可以在任何文件系统下添加,拿 LVM 来说, Linux (更多特别是 dm-crypt 驱动) 使用 Device Mapper 创建虚拟分区(内容受保护),是基于以加密形式(感谢 LUKS,Linux 的统一密钥设置,一种标准格式,以加密的数据存储,元数据显示了被使用的加密算法)。
To create an encrypted partition, you must first assign an available partition for this purpose. To do so, select a partition and indicate that it is to be used as a “physical volume for encryption”. After partitioning the disk containing the physical volume to be made, choose “Configure encrypted volumes”. The software will then propose to initialize the physical volume with random data (making the localization of the real data more difficult), and will ask you to enter an “encryption passphrase”, which you will have to enter every time you boot your computer in order to access the content of the encrypted partition. Once this step has been completed, and you have returned to the partitioning tool menu, a new partition will be available in an “encrypted volume”, which you can then configure just like any other partition. In most cases, this partition is used as a physical volume for LVM so as to protect several partitions (LVM logical volumes) with the same encryption key, including the swap partition (see sidebar 安全 加密交换分区).

4.2.14. 安装基本系统

This step, which doesn't require any user interaction, installs the Debian “base system” packages. This includes the dpkg and apt tools, which manage Debian packages, as well as the utilities necessary to boot the system and start using it.

图 4.11. 安装基本系统

4.2.15. 配置包管理 (apt)

为了能够安装附加软件, APT 需要配置以便知道到何处寻找 Debian 软件包。这一步是尽可能自动化的。开始会提问是否必须使用软件包的网络源,或者仅仅在 CD-ROM 里寻找所需软件。
If getting packages from the network is requested, the next two questions allow to choose a server from which to download these packages, by choosing first a country, then a mirror available in that country (a mirror is a public server hosting copies of all the files of the Debian master archive).
选择 Debian 镜像

图 4.12. 选择 Debian 镜像

最后,会提示使用 HTTP 代理。如果没有,将直接连接互联网。如果你输入, APT 会使用 Falcot proxy/cache, 一个 “Squid” 程序。你能通过连到相同网络的另一台计算机找到这些设置。
文件 Packages.gzSources.gz 然后自动被 APT 下载并更新包列表。

4.2.16. Debian 软件包流行度竞赛

Debian 系统有一个称做 popularity-contest 的软件包,它的目的是计算软件包的使用程度统计。每周,这个程序收集已经安装的和最近被使用的软件包的信息,并把这些信息匿名发送给 Debian 的该项目服务器。该项目可以使用这些信息决定每个包的相关重要性,通过影响授予的权重。特别是,最 “流行” 的软件包会包含在 CD-ROM 安装盘里,以便那些不想下载或购买整套CD的用户。

4.2.17. 选择安装包

Some packages are also automatically installed according to the hardware detected (thanks to the program discover-pkginstall from the discover package). For instance, if a VirtualBox virtual machine is detected, the program will install the virtualbox-guest-dkms package, allowing for better integration of the virtual machine with the host system.

图 4.13. 安装选择

4.2.18. 安装 GRUB 引导程序

引导程序是 BIOS 开始的第一个程序。它把 Linux 内核加载进内存然后执行。通常提供给用户一个内核选择菜单去加载引导操作系统。
By default, the menu proposed by GRUB contains all the installed Linux kernels, as well as any other operating systems that were detected. This is why you should accept the offer to install it in the Master Boot Record. Since keeping older kernel versions preserves the ability to boot the same system if the most recently installed kernel is defective or poorly adapted to the hardware, it often makes sense to keep a few older kernel versions installed.
由于 GRUB 的技术优势,GRUB 是 Debian 的默认引导程序:它能识别大部分的文件系统,因此在每次安装新内核之后无须作更新,这是由于引导时 GRUB 是通过读取配置文件找到新内核的实际位置的。版本 1 的 GRUB (又被称为"Grub Legacy")不能处理有 LVM 和 软件 RAID 的情况;版本 2 默认支持,更全面。某些情况推荐使用LILO(另一种引导程序),安装程序会自动提示的。
For more information on configuring GRUB, please refer to 第 8.8.3 节 “GRUB 2 Configuration”.

4.2.19. 完成安装并重启